-
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 4 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 |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| 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 +126,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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.spring.autoconfigure; | ||
|
|
||
| import io.opentelemetry.api.incubator.ExtendedOpenTelemetry; | ||
| import io.opentelemetry.api.incubator.config.ConfigProvider; | ||
| import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
|
|
||
| final class SpringOpenTelemetrySdk extends OpenTelemetrySdk implements ExtendedOpenTelemetry { | ||
|
|
||
| private final ConfigProvider configProvider; | ||
|
|
||
| SpringOpenTelemetrySdk(OpenTelemetrySdk delegate, ConfigProvider configProvider) { | ||
| super( | ||
| delegate.getSdkTracerProvider(), | ||
| delegate.getSdkMeterProvider(), | ||
| delegate.getSdkLoggerProvider(), | ||
| delegate.getPropagators()); | ||
| this.configProvider = configProvider; | ||
| } | ||
|
|
||
| @Override | ||
| public ConfigProvider getConfigProvider() { | ||
| return configProvider; | ||
| } | ||
| } |
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