diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfiguration.java index f63d93eb8955..7bf656efefba 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfiguration.java @@ -8,6 +8,7 @@ import io.opentelemetry.context.propagation.ContextPropagators; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import java.util.Collections; import java.util.List; import org.springframework.beans.factory.BeanFactory; @@ -24,6 +25,7 @@ @EnableConfigurationProperties(PropagationProperties.class) @AutoConfigureBefore(OpenTelemetryAutoConfiguration.class) @ConditionalOnProperty(prefix = "otel.propagation", name = "enabled", matchIfMissing = true) +@SuppressWarnings("deprecation") public class PropagationAutoConfiguration { @Bean @@ -41,9 +43,11 @@ static class PropagatorsConfiguration { @Bean TextMapPropagator compositeTextMapPropagator( - BeanFactory beanFactory, PropagationProperties properties) { + BeanFactory beanFactory, + PropagationProperties properties, + ConfigProperties configProperties) { return CompositeTextMapPropagatorFactory.getCompositeTextMapPropagator( - beanFactory, properties.getType()); + beanFactory, configProperties.getList("otel.propagators", properties.getType())); } } } diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationProperties.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationProperties.java index 9aa5c072ab65..ccc873b43578 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationProperties.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationProperties.java @@ -11,6 +11,7 @@ /** Configuration for propagators. */ @ConfigurationProperties(prefix = "otel.propagation") +@Deprecated // use otel.propagators instead public final class PropagationProperties { private List type = Arrays.asList("tracecontext", "baggage"); diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/resources/SpringConfigProperties.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/resources/SpringConfigProperties.java index 60210ba60991..95c9ca90fff1 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/resources/SpringConfigProperties.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/resources/SpringConfigProperties.java @@ -71,7 +71,8 @@ public Double getDouble(String name) { @SuppressWarnings("unchecked") @Override public List getList(String name) { - return (List) environment.getProperty(name, List.class); + List value = environment.getProperty(name, List.class); + return value == null ? Collections.emptyList() : value; } @Nullable diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/instrumentation/spring/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 07ca3e93af70..587aadc4c0ba 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -197,6 +197,30 @@ "description": "The Zipkin endpoint to connect to.
Currently only HTTP is supported.", "defaultValue": "http://localhost:9411/api/v2/spans" }, + { + "name": "otel.instrumentation.annotations.enabled", + "type": "java.lang.Boolean", + "description": "Enable the @WithSpan annotation.", + "defaultValue": true + }, + { + "name": "otel.instrumentation.kafka.enabled", + "type": "java.lang.Boolean", + "description": "Enable the Kafka instrumentation.", + "defaultValue": true + }, + { + "name": "otel.instrumentation.log4j-appender.enabled", + "type": "java.lang.Boolean", + "description": "Enable the Log4J2 appender instrumentation.", + "defaultValue": true + }, + { + "name": "otel.instrumentation.logback-appender.enabled", + "type": "java.lang.Boolean", + "description": "Enable the Logback appender instrumentation.", + "defaultValue": true + }, { "name": "otel.instrumentation.logback-appender.experimental.capture-code-attributes", "type": "java.lang.Boolean", @@ -229,13 +253,37 @@ }, { "name": "otel.instrumentation.logback-appender.experimental.capture-mdc-attributes", - "type": "java.lang.String", - "description": "Comma separated list of MDC attributes to capture. Use the wildcard character * to capture all attributes." + "type": "java.util.List", + "description": "MDC attributes to capture. Use the wildcard character * to capture all attributes." + }, + { + "name": "otel.instrumentation.micrometer.enabled", + "type": "java.lang.Boolean", + "description": "Enable the Micrometer instrumentation.", + "defaultValue": false + }, + { + "name": "otel.instrumentation.spring-web.enabled", + "type": "java.lang.Boolean", + "description": "Enable the RestTemplate instrumentation.", + "defaultValue": true + }, + { + "name": "otel.instrumentation.spring-webflux.enabled", + "type": "java.lang.Boolean", + "description": "Enable the WebClient instrumentation.", + "defaultValue": true + }, + { + "name": "otel.instrumentation.spring-webmvc.enabled", + "type": "java.lang.Boolean", + "description": "Enable the Servlet instrumentation.", + "defaultValue": true }, { "name": "otel.logs.exporter", - "type": "java.lang.String", - "description": "List of exporters to be used for logs, separated by commas.", + "type": "java.util.List", + "description": "List of exporters to be used for logs.", "defaultValue": "otlp" }, { @@ -246,14 +294,37 @@ }, { "name": "otel.metrics.exporter", - "type": "java.lang.String", - "description": "List of exporters to be used for metrics, separated by commas.", + "type": "java.util.List", + "description": "List of exporters to be used for metrics.", "defaultValue": "otlp" }, + { + "name": "otel.propagators", + "type": "java.util.List", + "description": "List of propagators to be used for context propagation.", + "defaultValue": "tracecontext,baggage" + }, + { + "name": "otel.resource.attributes", + "type": "java.util.Map", + "description": "Resource attributes to be added to all spans. In addition to these attributes, the resource will also include attributes discovered from the runtime, such as host.name and process.id." + }, + { + "name": "otel.sdk.disabled", + "type": "java.lang.Boolean", + "description": "Disable the OpenTelemetry Spring Starter.", + "defaultValue": false + }, + { + "name": "otel.springboot.resource.enabled", + "type": "java.lang.Boolean", + "description": "Enable the resource auto-configuration.", + "defaultValue": true + }, { "name": "otel.traces.exporter", - "type": "java.lang.String", - "description": "List of exporters to be used for tracing, separated by commas.", + "type": "java.util.List", + "description": "List of exporters to be used for tracing.", "defaultValue": "otlp" }, { @@ -339,6 +410,10 @@ { "name": "otel.logs.exporter", "values": [ + { + "value": "logging", + "description": "The logging exporter prints exported logs to stdout. It's mainly used for testing and debugging." + }, { "value": "none", "description": "No autoconfigured exporter." @@ -366,6 +441,39 @@ } ] }, + { + "name": "otel.propagators", + "values": [ + { + "value": "baggage", + "description": "The Baggage propagator propagates baggage using the W3C Baggage format. See https://www.w3.org/TR/baggage/." + }, + { + "value": "b3", + "description": "The B3 propagator propagates trace context using the B3 single-header format: See https://github.com/openzipkin/b3-propagation#single-header." + }, + { + "value": "b3multi", + "description": "The B3 propagator propagates trace context using the B3 multi-header format: See https://github.com/openzipkin/b3-propagation#multiple-headers." + }, + { + "value": "jaeger", + "description": "The Jaeger propagator propagates trace context using the Jaeger format. See https://www.jaegertracing.io/docs/1.21/client-libraries/#propagation-format." + }, + { + "value": "ottrace", + "description": "The OpenTelemetry Trace Context propagator propagates trace context using the OpenTelemetry format. See https://github.com/opentracing/specification/blob/master/rfc/trace_identifiers.md." + }, + { + "value": "tracecontext", + "description": "The Trace Context propagator propagates trace context using the W3C Trace Context format (add `baggage` as well to include W3C baggage). See https://www.w3.org/TR/trace-context/." + }, + { + "value": "xray", + "description": "The AWS X-Ray propagator propagates trace context using the AWS X-Ray format. See https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader." + } + ] + }, { "name": "otel.traces.exporter", "values": [ diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfigurationTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfigurationTest.java index a20162cec993..94c7fa3a8304 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfigurationTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationAutoConfigurationTest.java @@ -91,11 +91,26 @@ void shouldCreateNoop() { }); } + @Test + @DisplayName( + "when propagation is set to some values should contain only supported values - deprecated") + void shouldContainOnlySupportedDeprecated() { + this.contextRunner + .withPropertyValues("otel.propagation.type=invalid,b3") + .run( + context -> { + TextMapPropagator compositePropagator = + context.getBean("compositeTextMapPropagator", TextMapPropagator.class); + + assertThat(compositePropagator.fields()).containsExactly("b3"); + }); + } + @Test @DisplayName("when propagation is set to some values should contain only supported values") void shouldContainOnlySupported() { this.contextRunner - .withPropertyValues("otel.propagation.type=invalid,b3") + .withPropertyValues("otel.propagators=invalid,b3") .run( context -> { TextMapPropagator compositePropagator = diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationPropertiesTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationPropertiesTest.java index 6c746b0c92be..d41c08280769 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationPropertiesTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/propagators/PropagationPropertiesTest.java @@ -14,6 +14,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; +@SuppressWarnings("deprecation") // test for deprecated code public class PropagationPropertiesTest { private final ApplicationContextRunner contextRunner =