-
Notifications
You must be signed in to change notification settings - Fork 925
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
don't fail spring application startup if sdk is disabled #10602
don't fail spring application startup if sdk is disabled #10602
Conversation
9919997
to
17f07ca
Compare
@laurit here's the fix 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I woud disable all the autoconfigurations if otel.sdk.disabled=true
: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/spring/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -19,6 +19,10 @@ private ExporterConfigEvaluator() {} | |||
public static boolean isExporterEnabled( | |||
Environment environment, String exportersKey, String wantExporter, boolean defaultValue) { | |||
|
|||
if (environment.getProperty("otel.sdk.disabled", Boolean.class, false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a comment, something like this: the method is used to enable some Spring autoconfigurations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putting this condition on each exporter's @Configuration
could make it more visible and consistent (where we just throw the @SdkEnabled
condition on everything)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea - done 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putting this condition on each exporter's
@Configuration
could make it more visible and consistent (where we just throw the@SdkEnabled
condition on everything)
Should it not be another property configuration allowing to disable the export?
By setting otel.sdk.disabled=true
, I understand disable the OpenTelemtry SDK, and so disable the instrumentation features and the export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
putting this condition on each exporter's
@Configuration
could make it more visible and consistent (where we just throw the@SdkEnabled
condition on everything)Should it not be another property configuration allowing to disable the export?
you still have otel.traces.exporter=none
(similar for logs and metrics)
By setting
otel.sdk.disabled=true
, I understand disable the OpenTelemtry SDK, and so disable the instrumentation features and the export.
yes, otel.sdk.disabled=true
disables everything at once.
...lemetry/instrumentation/spring/autoconfigure/exporters/internal/ExporterConfigEvaluator.java
Outdated
Show resolved
Hide resolved
|
I am also fine with the current implementation if you think it is more explicit |
this wouldn't work, because the exporter beans are required to create the OpenTelemetry instance in OpenTelemetryAutoConfiguration |
@Configuration | ||
public class InstrumentationAnnotationsAutoConfiguration { | ||
|
||
static final class Condition extends AllNestedConditions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why you implemented it this way. Would having
@ConditionalOnProperty(name = "otel.instrumentation.annotations.enabled", matchIfMissing = true)
@Conditional(SdkEnabled.class)
where SdkEnabled
is shared by all auto configuration classes also work? If it would work this way I'd guess it needs a lot less code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea! I hadn't considered that - I'll try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worked!
f9742af
to
af3c2c6
Compare
b129069
to
b0bbbd1
Compare
Fixes #10600