Search in sources :

Example 1 with BatchSpanProcessor

use of io.opentelemetry.sdk.trace.export.BatchSpanProcessor in project opentelemetry-java by open-telemetry.

the class OtlpPipelineStressTest method setupSdk.

private void setupSdk() {
    Resource resource = Resource.create(Attributes.builder().put(ResourceAttributes.SERVICE_NAME, "PerfTester").put(ResourceAttributes.SERVICE_VERSION, "1.0.1-RC-1").build());
    // set up the metric exporter and wire it into the SDK and a timed reader.
    meterProvider = SdkMeterProvider.builder().setResource(resource).registerMetricReader(PeriodicMetricReader.builder(metricExporter).setInterval(Duration.ofSeconds(1)).newMetricReaderFactory()).build();
    // set up the span exporter and wire it into the SDK
    OtlpGrpcSpanExporter spanExporter = OtlpGrpcSpanExporter.builder().setMeterProvider(meterProvider).setEndpoint("http://" + toxiproxyContainer.getHost() + ":" + toxiproxyContainer.getMappedPort(COLLECTOR_PROXY_PORT)).build();
    BatchSpanProcessor spanProcessor = BatchSpanProcessor.builder(spanExporter).setMeterProvider(meterProvider).build();
    SdkTracerProvider tracerProvider = SdkTracerProvider.builder().addSpanProcessor(spanProcessor).build();
    openTelemetry = OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).buildAndRegisterGlobal();
    sdkTracerProvider = tracerProvider;
}
Also used : Resource(io.opentelemetry.sdk.resources.Resource) SdkTracerProvider(io.opentelemetry.sdk.trace.SdkTracerProvider) OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) BatchSpanProcessor(io.opentelemetry.sdk.trace.export.BatchSpanProcessor)

Example 2 with BatchSpanProcessor

use of io.opentelemetry.sdk.trace.export.BatchSpanProcessor in project opentelemetry-java by open-telemetry.

the class TracerProviderConfigurationTest method configureBatchSpanProcessor_empty.

@Test
void configureBatchSpanProcessor_empty() {
    BatchSpanProcessor processor = TracerProviderConfiguration.configureBatchSpanProcessor(EMPTY, mockSpanExporter, MeterProvider.noop());
    try {
        assertThat(processor).extracting("worker").satisfies(worker -> {
            assertThat(worker).extracting("scheduleDelayNanos").isEqualTo(TimeUnit.MILLISECONDS.toNanos(5000));
            assertThat(worker).extracting("exporterTimeoutNanos").isEqualTo(TimeUnit.MILLISECONDS.toNanos(30000));
            assertThat(worker).extracting("maxExportBatchSize").isEqualTo(512);
            assertThat(worker).extracting("queue").isInstanceOfSatisfying(Queue.class, queue -> assertThat(JcTools.capacity(queue)).isEqualTo(2048));
            assertThat(worker).extracting("spanExporter").isEqualTo(mockSpanExporter);
        });
    } finally {
        processor.shutdown();
    }
}
Also used : BatchSpanProcessor(io.opentelemetry.sdk.trace.export.BatchSpanProcessor) Test(org.junit.jupiter.api.Test)

Example 3 with BatchSpanProcessor

use of io.opentelemetry.sdk.trace.export.BatchSpanProcessor in project opentelemetry-java by open-telemetry.

the class TracerProviderConfigurationTest method configureBatchSpanProcessor_configured.

@Test
void configureBatchSpanProcessor_configured() {
    Map<String, String> properties = new HashMap<>();
    properties.put("otel.bsp.schedule.delay", "100000");
    properties.put("otel.bsp.max.queue.size", "2");
    properties.put("otel.bsp.max.export.batch.size", "3");
    properties.put("otel.bsp.export.timeout", "4");
    BatchSpanProcessor processor = TracerProviderConfiguration.configureBatchSpanProcessor(DefaultConfigProperties.createForTest(properties), mockSpanExporter, MeterProvider.noop());
    try {
        assertThat(processor).extracting("worker").satisfies(worker -> {
            assertThat(worker).extracting("scheduleDelayNanos").isEqualTo(TimeUnit.MILLISECONDS.toNanos(100000));
            assertThat(worker).extracting("exporterTimeoutNanos").isEqualTo(TimeUnit.MILLISECONDS.toNanos(4));
            assertThat(worker).extracting("maxExportBatchSize").isEqualTo(3);
            assertThat(worker).extracting("queue").isInstanceOfSatisfying(Queue.class, queue -> assertThat(JcTools.capacity(queue)).isEqualTo(2));
            assertThat(worker).extracting("spanExporter").isEqualTo(mockSpanExporter);
        });
    } finally {
        processor.shutdown();
    }
}
Also used : HashMap(java.util.HashMap) BatchSpanProcessor(io.opentelemetry.sdk.trace.export.BatchSpanProcessor) Test(org.junit.jupiter.api.Test)

Aggregations

BatchSpanProcessor (io.opentelemetry.sdk.trace.export.BatchSpanProcessor)3 Test (org.junit.jupiter.api.Test)2 OtlpGrpcSpanExporter (io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter)1 Resource (io.opentelemetry.sdk.resources.Resource)1 SdkTracerProvider (io.opentelemetry.sdk.trace.SdkTracerProvider)1 HashMap (java.util.HashMap)1