Skip to content

Commit 8e9076b

Browse files
committed
isolate map converter
1 parent 83525bc commit 8e9076b

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@
5454
* <p>Updates the sampler probability for the configured {@link TracerProvider}.
5555
*/
5656
@Configuration
57-
@EnableConfigurationProperties({
58-
OtlpExporterProperties.class,
59-
OtelResourceProperties.class,
60-
OtelSpringProperties.class
61-
})
6257
public class OpenTelemetryAutoConfiguration {
6358
private static final Logger logger =
6459
LoggerFactory.getLogger(OpenTelemetryAutoConfiguration.class);
@@ -87,6 +82,11 @@ public ResourceProvider otelDistroVersionResourceProvider() {
8782
}
8883

8984
@Configuration
85+
@EnableConfigurationProperties({
86+
OtlpExporterProperties.class,
87+
OtelResourceProperties.class,
88+
OtelSpringProperties.class
89+
})
9090
@ConditionalOnProperty(name = "otel.file_format", matchIfMissing = true, havingValue = "never")
9191
static class PropertiesConfig {
9292

@@ -102,7 +102,7 @@ public AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk(
102102
OtlpExporterProperties otlpExporterProperties,
103103
OtelResourceProperties resourceProperties,
104104
OtelSpringProperties otelSpringProperties,
105-
OpenTelemetrySdkComponentLoader componentLoader) {
105+
ComponentLoader componentLoader) {
106106

107107
return AutoConfigureUtil.setComponentLoader(
108108
AutoConfigureUtil.setConfigPropertiesCustomizer(
@@ -143,7 +143,14 @@ public ConfigProperties otelProperties(
143143

144144
@Configuration
145145
@ConditionalOnProperty(name = "otel.file_format")
146-
static class OpenTelemetrySdkEmbeddedConfigFileConfig {
146+
static class EmbeddedConfigFileConfig {
147+
148+
@Bean
149+
public OpenTelemetryConfigurationModel openTelemetryConfigurationModel(
150+
Environment environment) {
151+
// todo declarative configuration
152+
return null;
153+
}
147154

148155
@Bean
149156
public OpenTelemetry openTelemetry() {
@@ -165,7 +172,6 @@ public OpenTelemetry openTelemetry() {
165172
*/
166173
@Bean
167174
public ConfigProperties otelProperties(OpenTelemetryConfigurationModel model) {
168-
// todo component loader
169175
return DeclarativeConfigPropertiesBridge.create(
170176
DeclarativeConfiguration.toConfigProperties(model));
171177
}
@@ -183,12 +189,6 @@ private static void logStart() {
183189
@ConditionalOnProperty(name = "otel.sdk.disabled", havingValue = "true")
184190
static class DisabledOpenTelemetrySdkConfig {
185191

186-
@Bean
187-
@ConfigurationPropertiesBinding
188-
OtelMapConverter otelMapConverter() {
189-
return new OtelMapConverter();
190-
}
191-
192192
@Bean
193193
public OpenTelemetry openTelemetry() {
194194
logger.info("OpenTelemetry Spring Boot starter has been disabled");

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
* <p>This is the expected format for the <code>OTEL_RESOURCE_ATTRIBUTES</code> and <code>
1818
* OTEL_EXPORTER_OTLP_HEADERS</code> environment variables.
1919
*
20-
* <p>We need this converter, even if the SDK is disabled, because the properties are parsed before
21-
* the SDK is disabled.
22-
*
23-
* <p>We also need this converter if the OpenTelemetry bean is user supplied, because the
24-
* environment variables may still contain a value that needs to be converted, even if the SDK is
25-
* disabled (and the value thus ignored).
26-
*
2720
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
2821
* at any time.
2922
*/

instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/properties/SpringConfigPropertiesTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ void mapFlatHeadersWithUserSuppliedOtelBean(String key) {
8686
.withSystemProperties(key + "=a=1,b=2")
8787
.withBean(OpenTelemetry.class, OpenTelemetry::noop)
8888
.run(
89-
context ->
90-
assertThat(getConfig(context).getMap(key))
91-
.containsExactly(entry("a", "1"), entry("b", "2")));
89+
context -> {
90+
// don't crash if OpenTelemetry bean is provided
91+
});
9292
}
9393

9494
@ParameterizedTest
@@ -105,7 +105,6 @@ void mapObjectHeaders(String key) {
105105

106106
public static Stream<Arguments> listProperties() {
107107
return Stream.of(
108-
Arguments.of("otel.experimental.metrics.view.config", Arrays.asList("a", "b")),
109108
Arguments.of("otel.experimental.resource.disabled.keys", Arrays.asList("a", "b")),
110109
Arguments.of("otel.propagators", Arrays.asList("baggage", "b3")),
111110
Arguments.of("otel.logs.exporter", Collections.singletonList("console")),

instrumentation/spring/spring-boot-autoconfigure/src/test/resources/application.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
otel:
22
experimental:
3-
metrics:
4-
view:
5-
config: [ a,b ]
63
resource:
74
disabled:
85
keys: [ a,b ]

0 commit comments

Comments
 (0)