open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Declarative spring_starter.debug never enables span logging
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Describe the bug
In declarative configuration mode, instrumentation/development/java/spring_starter/debug never
takes effect, so span logging cannot be enabled at all on that path.
Two things combine:
-
DeclarativeConfigLoggingExporterAutoConfigurationis missing from both auto-configuration
registration files (AutoConfiguration.importsandspring.factories), so Spring Boot never
discovers it and itsDeclarativeConfigurationCustomizerProviderbean is never created. This is
the same omission as #19725, which fixes the properties-mode counterpart. -
Registering it is not sufficient.
SpanLoggingCustomizerProvider.isEnabledreads the flag via
the upstreamSdkConfigProvider:return SdkConfigProvider.create(DeclarativeConfiguration.toConfigProperties(model)) .getInstrumentationConfig("spring_starter") .getBoolean("debug", false);In the Spring starter,
EmbeddedConfigFilebuilds the declarative model from
Map<String, String>, so every scalar arrives as aString.getBoolean("debug", false)
does not coerce, and returnsfalsefor a configureddebug: true.That is exactly why this module already carries
SpringConfigProviderand
SpringDeclarativeConfigProperties, whose Javadoc says it "tries to coerce types, because
spring doesn't tell what the original type was" — butisEnableddoes not go through them.
Observed while working on #19725: with the class registered, the provider bean is created and
consumed, but the exporter is still not installed. Reading the same key directly shows
getString("debug") → "true" while getBoolean("debug", false) → false.
Steps to reproduce
Use the Spring Boot starter with declarative configuration and set
instrumentation/development/java/spring_starter/debug: true. No LoggingSpanExporter is
installed and no spans are printed.
Expected behavior
Enabling the declarative spring_starter.debug flag installs the logging span exporter, matching
the behaviour of otel.spring-starter.debug in properties mode.
Actual behavior
The flag is ignored. Even with the auto-configuration registered, isEnabled evaluates to false
because the configured value is a String and getBoolean does not coerce it.
Javaagent or library instrumentation version
main (verified at 4225fbe18e)
Environment
JDK 21, Spring Boot 3.2.4 / 2.6.15
Additional context
There seem to be at least three ways to fix this, and I did not want to pick one without
maintainer input, which is why #19725 deliberately leaves the declarative class out:
- Have
isEnabledread through the Spring-aware coercing provider
(SpringConfigProvider/SpringDeclarativeConfigProperties) instead ofSdkConfigProvider. - Preserve scalar types in
EmbeddedConfigFileinstead of flattening everything toString. - Make the upstream
getBooleancoerce string values —SpringDeclarativeConfigPropertieshas a
TODO pointing at open-telemetry/opentelemetry-java#8101, which looks related.
Whichever direction is preferred, the registration entries for
DeclarativeConfigLoggingExporterAutoConfiguration need to be added as part of it. Happy to
send a PR once the direction is settled.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with DeclarativeConfigLoggingExporterAutoConfiguration and compare its AutoConfiguration.imports and spring.factories registration with the properties-mode counterpart in #19725. Trace SpanLoggingCustomizerProvider.isEnabled through SdkConfigProvider, EmbeddedConfigFile, SpringConfigProvider, and SpringDeclarativeConfigProperties to confirm how the declarative debug value is read. Done means declarative spring_starter.debug: true installs LoggingSpanExporter and prints spans, with coverage for the supported configuration path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100