Skip to content

Use the new configuration bridge in spring boot starter#15714

Merged
trask merged 8 commits intoopen-telemetry:mainfrom
trask:declarative-config/spring-step-one
Dec 27, 2025
Merged

Use the new configuration bridge in spring boot starter#15714
trask merged 8 commits intoopen-telemetry:mainfrom
trask:declarative-config/spring-step-one

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Dec 22, 2025

Follow-up PR(s) will migrate other usages of InstrumentationConfig in Spring Boot Starter.

Part of larger effort:

@github-actions github-actions Bot added the test native This label can be applied to PRs to trigger them to run native tests label Dec 22, 2025
@trask trask force-pushed the declarative-config/spring-step-one branch from a676120 to 9137432 Compare December 23, 2025 00:41
@trask trask changed the title Use the one configuration bridge in spring boot starter Use the new configuration bridge in spring boot starter Dec 23, 2025
((EnumerablePropertySource<?>) propertySource).getPropertyNames()) {
if (propertyName.startsWith("otel.")) {
String property = environment.getProperty(propertyName);
Object property = propertySource.getProperty(propertyName);
Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member Author

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)

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return autoConfiguredOpenTelemetrySdk.getOpenTelemetrySdk();
OpenTelemetrySdk openTelemetry = autoConfiguredOpenTelemetrySdk.getOpenTelemetrySdk();
ConfigProvider configProvider = ConfigPropertiesBackedConfigProvider.create(otelProperties);
return new SpringOpenTelemetrySdk(openTelemetry, configProvider);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test failed when I just implemented OpenTelemetry instead of OpenTelemetrySdk

  • OpenTelemetryAutoConfigurationTest.shouldInitializeSdkWhenNotDisabled

I guess it could be considered a breaking change if anyone is relying on it really being an instance of OpenTelemetrySdk, so went with OpenTelemetrySdk instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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

@trask trask marked this pull request as ready for review December 23, 2025 03:13
@trask trask requested a review from a team as a code owner December 23, 2025 03:13
@trask trask merged commit acc60fb into open-telemetry:main Dec 27, 2025
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants