Search in sources :

Example 1 with SpanExporter

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

the class OtlpHttpRetryTest method configureSpanExporterRetryPolicy.

@Test
@SuppressLogger(OkHttpGrpcExporter.class)
void configureSpanExporterRetryPolicy() {
    Map<String, String> props = new HashMap<>();
    props.put("otel.exporter.otlp.traces.protocol", "http/protobuf");
    props.put("otel.exporter.otlp.traces.endpoint", "https://localhost:" + server.httpsPort() + "/v1/traces");
    props.put("otel.exporter.otlp.traces.certificate", server.selfSignedCertificate.certificate().getPath());
    props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
    try (SpanExporter spanExporter = SpanExporterConfiguration.configureExporter("otlp", DefaultConfigProperties.createForTest(props), NamedSpiManager.createEmpty(), MeterProvider.noop())) {
        testRetryableStatusCodes(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
        testDefaultRetryPolicy(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
    }
}
Also used : SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) HashMap(java.util.HashMap) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) Test(org.junit.jupiter.api.Test)

Example 2 with SpanExporter

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

the class ConfigurableSpanExporterTest method configureSpanExporters_spiExporter.

@Test
void configureSpanExporters_spiExporter() {
    ConfigProperties config = DefaultConfigProperties.createForTest(ImmutableMap.of("test.option", "true", "otel.traces.exporter", "testExporter"));
    Map<String, SpanExporter> exportersByName = SpanExporterConfiguration.configureSpanExporters(config, SpanExporterConfiguration.class.getClassLoader(), MeterProvider.noop(), (a, unused) -> a);
    assertThat(exportersByName).hasSize(1).containsKey("testExporter").extracting(map -> map.get("testExporter")).isInstanceOf(TestConfigurableSpanExporterProvider.TestSpanExporter.class).extracting("config").isSameAs(config);
}
Also used : ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) ImmutableMap(com.google.common.collect.ImmutableMap) ZipkinSpanExporter(io.opentelemetry.exporter.zipkin.ZipkinSpanExporter) BatchSpanProcessor(io.opentelemetry.sdk.trace.export.BatchSpanProcessor) URL(java.net.URL) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) Test(org.junit.jupiter.api.Test) URLClassLoader(java.net.URLClassLoader) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) LoggingSpanExporter(io.opentelemetry.exporter.logging.LoggingSpanExporter) SimpleSpanProcessor(io.opentelemetry.sdk.trace.export.SimpleSpanProcessor) Map(java.util.Map) MeterProvider(io.opentelemetry.api.metrics.MeterProvider) Collections(java.util.Collections) ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) ZipkinSpanExporter(io.opentelemetry.exporter.zipkin.ZipkinSpanExporter) OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) LoggingSpanExporter(io.opentelemetry.exporter.logging.LoggingSpanExporter) Test(org.junit.jupiter.api.Test)

Example 3 with SpanExporter

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

the class ConfigurableSpanExporterTest method configureSpanProcessors_multipleExportersWithLogging.

@Test
void configureSpanProcessors_multipleExportersWithLogging() {
    SpanExporter loggingExporter = LoggingSpanExporter.create();
    SpanExporter zipkinExporter = ZipkinSpanExporter.builder().build();
    ConfigProperties properties = DefaultConfigProperties.createForTest(Collections.singletonMap("otel.traces.exporter", "logging,zipkin"));
    assertThat(TracerProviderConfiguration.configureSpanProcessors(properties, ImmutableMap.of("logging", loggingExporter, "zipkin", zipkinExporter), MeterProvider.noop())).hasSize(2).hasAtLeastOneElementOfType(SimpleSpanProcessor.class).hasAtLeastOneElementOfType(BatchSpanProcessor.class);
}
Also used : SimpleSpanProcessor(io.opentelemetry.sdk.trace.export.SimpleSpanProcessor) ZipkinSpanExporter(io.opentelemetry.exporter.zipkin.ZipkinSpanExporter) OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) LoggingSpanExporter(io.opentelemetry.exporter.logging.LoggingSpanExporter) ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) Test(org.junit.jupiter.api.Test)

Example 4 with SpanExporter

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

the class ConfigurableSpanExporterTest method configureSpanProcessors_batchSpanProcessor.

@Test
void configureSpanProcessors_batchSpanProcessor() {
    String exporterName = "zipkin";
    Map<String, String> propMap = Collections.singletonMap("otel.traces.exporter", exporterName);
    SpanExporter exporter = ZipkinSpanExporter.builder().build();
    ConfigProperties properties = DefaultConfigProperties.createForTest(propMap);
    assertThat(TracerProviderConfiguration.configureSpanProcessors(properties, ImmutableMap.of(exporterName, exporter), MeterProvider.noop())).hasSize(1).first().isInstanceOf(BatchSpanProcessor.class);
}
Also used : ZipkinSpanExporter(io.opentelemetry.exporter.zipkin.ZipkinSpanExporter) OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) LoggingSpanExporter(io.opentelemetry.exporter.logging.LoggingSpanExporter) ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) Test(org.junit.jupiter.api.Test)

Example 5 with SpanExporter

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

the class OtlpExporterIntegrationTest method testOtlpGrpcTraceExport.

@ParameterizedTest
@ValueSource(strings = { "gzip", "none" })
void testOtlpGrpcTraceExport(String compression) {
    SpanExporter otlpGrpcTraceExporter = OtlpGrpcSpanExporter.builder().setEndpoint("http://" + collector.getHost() + ":" + collector.getMappedPort(COLLECTOR_OTLP_GRPC_PORT)).setCompression(compression).build();
    testTraceExport(otlpGrpcTraceExporter);
}
Also used : OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) OtlpHttpSpanExporter(io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SpanExporter (io.opentelemetry.sdk.trace.export.SpanExporter)22 Test (org.junit.jupiter.api.Test)16 OtlpGrpcSpanExporter (io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter)9 ConfigProperties (io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties)9 HashMap (java.util.HashMap)9 LoggingSpanExporter (io.opentelemetry.exporter.logging.LoggingSpanExporter)7 ZipkinSpanExporter (io.opentelemetry.exporter.zipkin.ZipkinSpanExporter)7 SimpleSpanProcessor (io.opentelemetry.sdk.trace.export.SimpleSpanProcessor)6 Collections (java.util.Collections)6 Map (java.util.Map)6 MeterProvider (io.opentelemetry.api.metrics.MeterProvider)4 OtlpHttpSpanExporter (io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter)4 ConfigurationException (io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 GlobalOpenTelemetry (io.opentelemetry.api.GlobalOpenTelemetry)2 OpenTelemetry (io.opentelemetry.api.OpenTelemetry)2 AttributeKey.stringKey (io.opentelemetry.api.common.AttributeKey.stringKey)2 Span (io.opentelemetry.api.trace.Span)2 SpanId (io.opentelemetry.api.trace.SpanId)2