-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use the new configuration bridge in spring boot starter #15714
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
Changes from all commits
7eaf6f3
6bc1c0f
277d5e8
9137432
3af7e85
3b81610
d3d35f6
b245582
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,13 @@ | |
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| import io.opentelemetry.api.OpenTelemetry; | ||
| import io.opentelemetry.api.incubator.ExtendedOpenTelemetry; | ||
| import io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import io.opentelemetry.api.trace.TracerProvider; | ||
| import io.opentelemetry.common.ComponentLoader; | ||
| import io.opentelemetry.instrumentation.api.incubator.config.internal.InstrumentationConfig; | ||
| import io.opentelemetry.instrumentation.api.internal.EmbeddedInstrumentationProperties; | ||
| import io.opentelemetry.instrumentation.config.bridge.ConfigPropertiesBackedConfigProvider; | ||
| import io.opentelemetry.instrumentation.config.bridge.DeclarativeConfigPropertiesBridgeBuilder; | ||
| import io.opentelemetry.instrumentation.spring.autoconfigure.internal.DeclarativeConfigDisabled; | ||
| import io.opentelemetry.instrumentation.spring.autoconfigure.internal.DeclarativeConfigEnabled; | ||
|
|
@@ -125,9 +127,12 @@ public AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk( | |
|
|
||
| @Bean | ||
| public OpenTelemetry openTelemetry( | ||
| AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk) { | ||
| AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk, | ||
| ConfigProperties otelProperties) { | ||
| logStart(); | ||
| return autoConfiguredOpenTelemetrySdk.getOpenTelemetrySdk(); | ||
| OpenTelemetrySdk openTelemetry = autoConfiguredOpenTelemetrySdk.getOpenTelemetrySdk(); | ||
| ConfigProvider configProvider = ConfigPropertiesBackedConfigProvider.create(otelProperties); | ||
| return new SpringOpenTelemetrySdk(openTelemetry, configProvider); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A test failed when I just implemented
I guess it could be considered a breaking change if anyone is relying on it really being an instance of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the test was just meant to assert that it's not the noop instance |
||
| } | ||
|
|
||
| @Bean | ||
|
|
@@ -171,9 +176,11 @@ public OpenTelemetry openTelemetry( | |
| return sdk; | ||
| } | ||
|
|
||
| // TODO remove once ConfigProperties usage is removed from remaining | ||
| // spring boot starter instrumentations | ||
| @Bean | ||
| public ConfigProvider configProvider(OpenTelemetryConfigurationModel model) { | ||
| return SpringConfigProvider.create(model); | ||
| public ConfigProvider configProvider(OpenTelemetry openTelemetry) { | ||
| return ((ExtendedOpenTelemetry) openTelemetry).getConfigProvider(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -182,12 +189,16 @@ public ConfigProvider configProvider(OpenTelemetryConfigurationModel model) { | |
| * <p>Not using spring boot properties directly, because declarative configuration does not | ||
| * integrate with spring boot properties. | ||
| */ | ||
| // TODO remove once ConfigProperties usage is removed from remaining | ||
| // spring boot starter instrumentations | ||
| @Bean | ||
| public ConfigProperties otelProperties(ConfigProvider configProvider) { | ||
| return new DeclarativeConfigPropertiesBridgeBuilder() | ||
| .buildFromInstrumentationConfig(configProvider.getInstrumentationConfig()); | ||
| } | ||
|
|
||
| // TODO remove once ConfigProperties usage is removed from remaining | ||
| // spring boot starter instrumentations | ||
| @Bean | ||
| public InstrumentationConfig instrumentationConfig( | ||
| ConfigProperties properties, ConfigProvider configProvider) { | ||
|
|
||
This file was deleted.
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.
This change preserves boolean values across the bridge
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.
Is this needed for this PR?
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.
yeah. the reason it worked before is that all of the spring boot starter config access was done via ConfigProperties which is string based anyways
and I've updated some places in this PR to now access config via Declarative Config API (which ignores properties if they're not the requested type instead of converting them)
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.
spring was using type coercion before - because I thought it was necessary.
I'll play around with this PR a little more to get a better picture.
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 figured it out: the wrong config provider was used: trask#101
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.
left a question: https://github.com/trask/opentelemetry-java-instrumentation/pull/101/changes#r2648454257