Search in sources :

Example 1 with ConfigProperties

use of io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties in project opentelemetry-java by open-telemetry.

the class OtlpGrpcConfigTest method configureTlsInvalidCertificatePath.

@Test
void configureTlsInvalidCertificatePath() {
    Map<String, String> props = new HashMap<>();
    props.put("otel.exporter.otlp.certificate", Paths.get("foo", "bar", "baz").toString());
    ConfigProperties properties = DefaultConfigProperties.createForTest(props);
    assertThatThrownBy(() -> SpanExporterConfiguration.configureExporter("otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop())).isInstanceOf(ConfigurationException.class).hasMessageContaining("Invalid OTLP certificate path:");
    assertThatThrownBy(() -> MetricExporterConfiguration.configureOtlpMetrics(properties)).isInstanceOf(ConfigurationException.class).hasMessageContaining("Invalid OTLP certificate path:");
    assertThatThrownBy(() -> LogExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop())).isInstanceOf(ConfigurationException.class).hasMessageContaining("Invalid OTLP certificate path:");
}
Also used : ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) HashMap(java.util.HashMap) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigProperties

use of io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties 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 ConfigProperties

use of io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties in project opentelemetry-java by open-telemetry.

the class ConfigurableSpanExporterTest method configureSpanExporters_multipleWithNone.

@Test
void configureSpanExporters_multipleWithNone() {
    ConfigProperties config = DefaultConfigProperties.createForTest(ImmutableMap.of("otel.traces.exporter", "otlp,none"));
    assertThatThrownBy(() -> SpanExporterConfiguration.configureSpanExporters(config, SpanExporterConfiguration.class.getClassLoader(), MeterProvider.noop(), (a, unused) -> a)).isInstanceOf(ConfigurationException.class).hasMessageContaining("otel.traces.exporter contains none along with other exporters");
}
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) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigProperties

use of io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties 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 5 with ConfigProperties

use of io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties in project opentelemetry-java by open-telemetry.

the class ConfigurableSpanExporterTest method configureSpanExporters_duplicates.

@Test
void configureSpanExporters_duplicates() {
    ConfigProperties config = DefaultConfigProperties.createForTest(ImmutableMap.of("otel.traces.exporter", "otlp,otlp,logging"));
    assertThatThrownBy(() -> SpanExporterConfiguration.configureSpanExporters(config, SpanExporterConfiguration.class.getClassLoader(), MeterProvider.noop(), (a, unused) -> a)).isInstanceOf(ConfigurationException.class).hasMessageContaining("otel.traces.exporter contains duplicates: [otlp]");
}
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) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigProperties (io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties)40 Test (org.junit.jupiter.api.Test)30 ConfigurationException (io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException)16 SpanExporter (io.opentelemetry.sdk.trace.export.SpanExporter)12 HashMap (java.util.HashMap)12 MeterProvider (io.opentelemetry.api.metrics.MeterProvider)11 LoggingSpanExporter (io.opentelemetry.exporter.logging.LoggingSpanExporter)10 OtlpGrpcSpanExporter (io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter)10 ZipkinSpanExporter (io.opentelemetry.exporter.zipkin.ZipkinSpanExporter)10 Map (java.util.Map)10 ImmutableMap (com.google.common.collect.ImmutableMap)8 Collections (java.util.Collections)8 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)8 Resource (io.opentelemetry.sdk.resources.Resource)6 SimpleSpanProcessor (io.opentelemetry.sdk.trace.export.SimpleSpanProcessor)6 URLClassLoader (java.net.URLClassLoader)6 MetricExporter (io.opentelemetry.sdk.metrics.export.MetricExporter)5 BatchSpanProcessor (io.opentelemetry.sdk.trace.export.BatchSpanProcessor)5 URL (java.net.URL)5 BiFunction (java.util.function.BiFunction)5