Java Code Examples for io.opencensus.exporter.stats.stackdriver.StackdriverStatsExporter#unregister()

The following examples show how to use io.opencensus.exporter.stats.stackdriver.StackdriverStatsExporter#unregister() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SinkBigQueryIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 6 votes vote down vote up
@Test
public void canFileLoad() throws Exception {
  createTablesAndPublishInputs(ImmutableList.of(SIMPLE_MESSAGE));

  Map<String, String> sinkEnv = ImmutableMap.<String, String>builder()
      .put("BATCH_MAX_DELAY", "0s") //
      .put("BIG_QUERY_OUTPUT_MODE", "file_loads") //
      .put("INPUT_SUBSCRIPTION", pubsub.getSubscription(0)) //
      .put("OUTPUT_BUCKET", gcs.bucket) //
      .put("OUTPUT_TABLE",
          bq.project + "." + bq.dataset + ".${document_type}_v${document_version}") //
      .put("OUTPUT_TOPIC", pubsub.getTopic(1)) //
      .build();
  sinkEnv.forEach(environmentVariables::set);
  BoundedSink.run(1, 30);
  checkResult(ImmutableList.of());

  sinkEnv.keySet().forEach(environmentVariables::clear);
  environmentVariables.set("INPUT_SUBSCRIPTION", pubsub.getSubscription(1));
  environmentVariables.set("LOAD_MAX_DELAY", "0s");
  // unregister stackdriver stats exporter so BoundedSink can register another one
  StackdriverStatsExporter.unregister();
  BoundedSink.run(1, 30);
  checkResult(ImmutableList.of(SIMPLE_MESSAGE_ROW));
}
 
Example 2
Source File: SinkGcsIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void unregisterStackdriver() {
  // unregister stackdriver stats exporter in case a previous test already registered one.
  StackdriverStatsExporter.unregister();
}
 
Example 3
Source File: SinkBigQueryIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void unregisterStackdriver() {
  // unregister stackdriver stats exporter in case a previous test already registered one.
  StackdriverStatsExporter.unregister();
}
 
Example 4
Source File: SinkBigQueryIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
@Test
public void canStreamSpecificDoctypes() throws Exception {
  final List<PubsubMessage> streamingInput = ImmutableList.of(
      SIMPLE_MESSAGE.toBuilder().putAttributes("document_namespace", "namespace_0").build(),
      SIMPLE_MESSAGE.toBuilder().putAttributes("document_namespace", "namespace_0")
          .putAttributes("document_type", "bar").build(),
      SIMPLE_MESSAGE.toBuilder().putAttributes("document_namespace", "namespace_1")
          .putAttributes("document_version", "2").build());
  final List<List<String>> streamingExpected = ImmutableList.of(
      ImmutableList.of("foo", "1", SUBMISSION_TIMESTAMP, "x", "foo_v1"),
      ImmutableList.of("bar", "1", SUBMISSION_TIMESTAMP, "x", "bar_v1"),
      ImmutableList.of("foo", "2", SUBMISSION_TIMESTAMP, "x", "foo_v2"));
  createTablesAndPublishInputs(streamingInput);

  final List<PubsubMessage> nonStreamingInput = ImmutableList.of(
      SIMPLE_MESSAGE.toBuilder().putAttributes("document_namespace", "namespace_1")
          .putAttributes("document_type", "bar").putAttributes("document_version", "2").build(),
      SIMPLE_MESSAGE.toBuilder().putAttributes("document_namespace", "namespace_2")
          .putAttributes("document_version", "3").build(),
      SIMPLE_MESSAGE.toBuilder().putAttributes("document_namespace", "namespace_2")
          .putAttributes("document_type", "bar").putAttributes("document_version", "3").build());
  final List<List<String>> nonStreamingExpected = ImmutableList.of(
      ImmutableList.of("bar", "2", SUBMISSION_TIMESTAMP, "x", "bar_v2"),
      ImmutableList.of("foo", "3", SUBMISSION_TIMESTAMP, "x", "foo_v3"),
      ImmutableList.of("bar", "3", SUBMISSION_TIMESTAMP, "x", "bar_v3"));
  createTablesAndPublishInputs(nonStreamingInput);

  Map<String, String> sinkEnv = ImmutableMap.<String, String>builder()
      .put("BATCH_MAX_DELAY", "0s") //
      .put("BIG_QUERY_OUTPUT_MODE", "mixed") //
      .put("INPUT_SUBSCRIPTION", pubsub.getSubscription(0)) //
      .put("OUTPUT_BUCKET", gcs.bucket) //
      .put("OUTPUT_TABLE",
          bq.project + "." + bq.dataset + ".${document_type}_v${document_version}") //
      .put("OUTPUT_TOPIC", pubsub.getTopic(1)) //
      .put("STREAMING_BATCH_MAX_DELAY", "0s") //
      .put("STREAMING_DOCTYPES", "namespace-0/.*|namespace-1/foo") //
      .build();
  sinkEnv.forEach(environmentVariables::set);
  BoundedSink.run(streamingInput.size() + nonStreamingInput.size(), 30);
  checkResult(streamingExpected);

  sinkEnv.keySet().forEach(environmentVariables::clear);
  environmentVariables.set("INPUT_SUBSCRIPTION", pubsub.getSubscription(1));
  environmentVariables.set("LOAD_MAX_DELAY", "0s");
  // unregister stackdriver stats exporter so BoundedSink can register another one
  StackdriverStatsExporter.unregister();
  BoundedSink.run(nonStreamingInput.size(), 30);
  checkResult(Iterables.concat(streamingExpected, nonStreamingExpected));
}
 
Example 5
Source File: SinkPubsubIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void unregisterStackdriver() {
  // unregister stackdriver stats exporter in case a previous test already registered one.
  StackdriverStatsExporter.unregister();
}
 
Example 6
Source File: StackDriverConfigurator.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
  Metrics.getExportComponent().getMetricProducerManager().remove(producer);
  StackdriverStatsExporter.unregister();
}