Skip to content

Commit a8d707e

Browse files
committed
always need map converter
1 parent 860c805 commit a8d707e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,20 @@ public class OpenTelemetryAutoConfiguration {
5757

5858
public OpenTelemetryAutoConfiguration() {}
5959

60+
@Bean
61+
@ConfigurationPropertiesBinding
62+
public MapConverter mapConverter() {
63+
// needed for otlp exporter headers and OtelResourceProperties
64+
// we need this converter, even if the SDK is disabled,
65+
// because the properties are parsed before the SDK is disabled
66+
return new MapConverter();
67+
}
68+
6069
@Configuration
6170
@Conditional(SdkEnabled.class)
6271
@ConditionalOnMissingBean(OpenTelemetry.class)
6372
static class OpenTelemetrySdkConfig {
6473

65-
@Bean
66-
@ConfigurationPropertiesBinding
67-
public MapConverter mapConverter() {
68-
// needed for otlp exporter headers and OtelResourceProperties
69-
return new MapConverter();
70-
}
71-
7274
@Bean
7375
public OpenTelemetrySdkComponentLoader openTelemetrySdkComponentLoader(
7476
ApplicationContext applicationContext) {

instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ void shouldInitializeSdkWhenNotDisabled() {
156156
void shouldInitializeNoopOpenTelemetryWhenSdkIsDisabled() {
157157
this.contextRunner
158158
.withConfiguration(AutoConfigurations.of(OpenTelemetryAutoConfiguration.class))
159-
.withPropertyValues("otel.sdk.disabled=true")
159+
.withPropertyValues(
160+
"otel.sdk.disabled=true",
161+
"otel.resource.attributes=service.name=workflow-backend-dev,service.version=3c8f9ce9")
160162
.run(
161163
context ->
162164
assertThat(context).getBean("openTelemetry").isEqualTo(OpenTelemetry.noop()));

0 commit comments

Comments
 (0)