diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java index 17299f1d24a1..5fac851d6dfc 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java @@ -76,7 +76,7 @@ public MapConverter mapConverter() { return new MapConverter(); } - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean public SdkTracerProvider sdkTracerProvider( SamplerProperties samplerProperties, @@ -94,7 +94,7 @@ public SdkTracerProvider sdkTracerProvider( .build(); } - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean public SdkLoggerProvider sdkLoggerProvider( ObjectProvider> loggerExportersProvider, Resource otelResource) { @@ -112,7 +112,7 @@ public SdkLoggerProvider sdkLoggerProvider( return loggerProviderBuilder.build(); } - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean public SdkMeterProvider sdkMeterProvider( MetricExportProperties properties, diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfiguration.java index fb24424fa9da..3d92ad45df75 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfiguration.java @@ -25,7 +25,7 @@ @ConditionalOnClass(LoggingMetricExporter.class) public class LoggingMetricExporterAutoConfiguration { - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance public LoggingMetricExporter otelLoggingMetricExporter() { return LoggingMetricExporter.create(); } diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfiguration.java index bff163a842d0..3d3038312e84 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfiguration.java @@ -25,7 +25,7 @@ @ConditionalOnClass(LoggingSpanExporter.class) public class LoggingSpanExporterAutoConfiguration { - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean public LoggingSpanExporter otelLoggingSpanExporter() { return LoggingSpanExporter.create(); diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpLoggerExporterAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpLoggerExporterAutoConfiguration.java index ec84b545397e..99a50d675ebf 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpLoggerExporterAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpLoggerExporterAutoConfiguration.java @@ -27,7 +27,7 @@ @ConditionalOnClass(OtlpGrpcLogRecordExporter.class) public class OtlpLoggerExporterAutoConfiguration { - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean({OtlpGrpcLogRecordExporter.class, OtlpHttpLogRecordExporter.class}) public LogRecordExporter otelOtlpLogRecordExporter(OtlpExporterProperties properties) { diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpMetricExporterAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpMetricExporterAutoConfiguration.java index c0df49ffbec5..3450b4051fa0 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpMetricExporterAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpMetricExporterAutoConfiguration.java @@ -29,7 +29,7 @@ @ConditionalOnClass(OtlpGrpcMetricExporter.class) public class OtlpMetricExporterAutoConfiguration { - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean({OtlpGrpcMetricExporter.class, OtlpHttpMetricExporter.class}) public MetricExporter otelOtlpMetricExporter(OtlpExporterProperties properties) { return OtlpExporterUtil.applySignalProperties( diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfiguration.java index 6c9f0307933f..f4b35980b74a 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfiguration.java @@ -41,7 +41,7 @@ public OtlpHttpSpanExporterBuilder otelOtlpHttpSpanExporterBuilder() { return OtlpHttpSpanExporter.builder(); } - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean({OtlpGrpcSpanExporter.class, OtlpHttpSpanExporter.class}) public SpanExporter otelOtlpSpanExporter( OtlpExporterProperties properties, OtlpHttpSpanExporterBuilder otlpHttpSpanExporterBuilder) { diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/zipkin/ZipkinSpanExporterAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/zipkin/ZipkinSpanExporterAutoConfiguration.java index 7ffd203d4123..2912f7f041b9 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/zipkin/ZipkinSpanExporterAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/zipkin/ZipkinSpanExporterAutoConfiguration.java @@ -30,7 +30,7 @@ @ConditionalOnClass(ZipkinSpanExporter.class) public class ZipkinSpanExporterAutoConfiguration { - @Bean + @Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance @ConditionalOnMissingBean public ZipkinSpanExporter otelZipkinSpanExporter(ZipkinSpanExporterProperties properties) { diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java index 6b63da22d9ef..690300485a4f 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfigurationTest.java @@ -75,13 +75,18 @@ void initializeOpenTelemetryWithCustomProviders() { .withBean( "customTracerProvider", SdkTracerProvider.class, - () -> SdkTracerProvider.builder().build()) + () -> SdkTracerProvider.builder().build(), + bd -> bd.setDestroyMethodName("")) .withBean( - "customMeterProvider", SdkMeterProvider.class, () -> SdkMeterProvider.builder().build()) + "customMeterProvider", + SdkMeterProvider.class, + () -> SdkMeterProvider.builder().build(), + bd -> bd.setDestroyMethodName("")) .withBean( "customLoggerProvider", SdkLoggerProvider.class, - () -> SdkLoggerProvider.builder().build()) + () -> SdkLoggerProvider.builder().build(), + bd -> bd.setDestroyMethodName("")) .withConfiguration(AutoConfigurations.of(OpenTelemetryAutoConfiguration.class)) .run( context -> diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfigurationTest.java b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfigurationTest.java index 54449e437cbc..89b8e3185442 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfigurationTest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpSpanExporterAutoConfigurationTest.java @@ -155,7 +155,10 @@ void useHttpWhenAnUnknownProtocolIsSet() { @DisplayName("logging exporter can still be configured") void loggingExporter() { this.contextRunner - .withBean(LoggingSpanExporter.class, LoggingSpanExporter::create) + .withBean( + LoggingSpanExporter.class, + LoggingSpanExporter::create, + bd -> bd.setDestroyMethodName("")) .run( context -> assertThat(