Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Calling shutdown() multiple times warning in spring starter #10222

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -94,7 +94,7 @@ public SdkTracerProvider sdkTracerProvider(
.build();
}

@Bean
@Bean(destroyMethod = "") // SDK components are shutdown from the OpenTelemetry instance
@ConditionalOnMissingBean
public SdkLoggerProvider sdkLoggerProvider(
ObjectProvider<List<LogRecordExporter>> loggerExportersProvider, Resource otelResource) {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading