always need map converter (#13224)
Co-authored-by: Jean Bisutti <jean.bisutti@gmail.com>
This commit is contained in:
parent
36e1e14ee7
commit
081415e6b1
|
@ -7,7 +7,7 @@ package io.opentelemetry.instrumentation.spring.autoconfigure;
|
|||
|
||||
import io.opentelemetry.api.OpenTelemetry;
|
||||
import io.opentelemetry.api.trace.TracerProvider;
|
||||
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.MapConverter;
|
||||
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.OtelMapConverter;
|
||||
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.SdkEnabled;
|
||||
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtelResourceProperties;
|
||||
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtelSpringProperties;
|
||||
|
@ -64,9 +64,9 @@ public class OpenTelemetryAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
public MapConverter mapConverter() {
|
||||
public OtelMapConverter otelMapConverter() {
|
||||
// needed for otlp exporter headers and OtelResourceProperties
|
||||
return new MapConverter();
|
||||
return new OtelMapConverter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -133,6 +133,17 @@ public class OpenTelemetryAutoConfiguration {
|
|||
@ConditionalOnProperty(name = "otel.sdk.disabled", havingValue = "true")
|
||||
static class DisabledOpenTelemetrySdkConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
// Duplicated in OpenTelemetrySdkConfig and DisabledOpenTelemetrySdkConfig to not expose the
|
||||
// converter in the public API
|
||||
public OtelMapConverter otelMapConverter() {
|
||||
// needed for otlp exporter headers and OtelResourceProperties
|
||||
// we need this converter, even if the SDK is disabled,
|
||||
// because the properties are parsed before the SDK is disabled
|
||||
return new OtelMapConverter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OpenTelemetry openTelemetry() {
|
||||
return OpenTelemetry.noop();
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.springframework.core.convert.converter.Converter;
|
|||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
|
||||
* at any time.
|
||||
*/
|
||||
public class MapConverter implements Converter<String, Map<String, String>> {
|
||||
public class OtelMapConverter implements Converter<String, Map<String, String>> {
|
||||
|
||||
public static final String KEY = "key";
|
||||
|
|
@ -156,7 +156,9 @@ class OpenTelemetryAutoConfigurationTest {
|
|||
void shouldInitializeNoopOpenTelemetryWhenSdkIsDisabled() {
|
||||
this.contextRunner
|
||||
.withConfiguration(AutoConfigurations.of(OpenTelemetryAutoConfiguration.class))
|
||||
.withPropertyValues("otel.sdk.disabled=true")
|
||||
.withPropertyValues(
|
||||
"otel.sdk.disabled=true",
|
||||
"otel.resource.attributes=service.name=workflow-backend-dev,service.version=3c8f9ce9")
|
||||
.run(
|
||||
context ->
|
||||
assertThat(context).getBean("openTelemetry").isEqualTo(OpenTelemetry.noop()));
|
||||
|
|
Loading…
Reference in New Issue