You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
DeclarativeConfigLoggingExporterAutoConfiguration is missing from both auto-configuration
registration files (AutoConfiguration.imports and spring.factories), so Spring Boot never
discovers it and its DeclarativeConfigurationCustomizerProvider bean is never created. This is
the same omission as Register LoggingExporterAutoConfiguration so otel.spring-starter.debug works #19725, which fixes the properties-mode counterpart.
Registering it is not sufficient. SpanLoggingCustomizerProvider.isEnabled reads the flag via
the upstream SdkConfigProvider:
In the Spring starter, EmbeddedConfigFile builds the declarative model from Map<String, String>, so every scalar arrives as a String. getBoolean("debug", false)
does not coerce, and returns false for a configured debug: true.
That is exactly why this module already carries SpringConfigProvider and SpringDeclarativeConfigProperties, whose Javadoc says it "tries to coerce types, because
spring doesn't tell what the original type was" — but isEnabled does 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.
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 isEnabled read through the Spring-aware coercing provider
(SpringConfigProvider / SpringDeclarativeConfigProperties) instead of SdkConfigProvider.
Preserve scalar types in EmbeddedConfigFile instead of flattening everything to String.
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.
Describe the bug
In declarative configuration mode,
instrumentation/development/java/spring_starter/debugnevertakes effect, so span logging cannot be enabled at all on that path.
Two things combine:
DeclarativeConfigLoggingExporterAutoConfigurationis missing from both auto-configurationregistration files (
AutoConfiguration.importsandspring.factories), so Spring Boot neverdiscovers it and its
DeclarativeConfigurationCustomizerProviderbean is never created. This isthe same omission as Register LoggingExporterAutoConfiguration so otel.spring-starter.debug works #19725, which fixes the properties-mode counterpart.
Registering it is not sufficient.
SpanLoggingCustomizerProvider.isEnabledreads the flag viathe upstream
SdkConfigProvider:In the Spring starter,
EmbeddedConfigFilebuilds the declarative model fromMap<String, String>, so every scalar arrives as aString.getBoolean("debug", false)does not coerce, and returns
falsefor a configureddebug: true.That is exactly why this module already carries
SpringConfigProviderandSpringDeclarativeConfigProperties, whose Javadoc says it "tries to coerce types, becausespring doesn't tell what the original type was" — but
isEnableddoes 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"whilegetBoolean("debug", false)→false.Steps to reproduce
Use the Spring Boot starter with declarative configuration and set
instrumentation/development/java/spring_starter/debug: true. NoLoggingSpanExporterisinstalled and no spans are printed.
Expected behavior
Enabling the declarative
spring_starter.debugflag installs the logging span exporter, matchingthe behaviour of
otel.spring-starter.debugin properties mode.Actual behavior
The flag is ignored. Even with the auto-configuration registered,
isEnabledevaluates tofalsebecause the configured value is a
StringandgetBooleandoes not coerce it.Javaagent or library instrumentation version
main(verified at 4225fbe)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:
isEnabledread through the Spring-aware coercing provider(
SpringConfigProvider/SpringDeclarativeConfigProperties) instead ofSdkConfigProvider.EmbeddedConfigFileinstead of flattening everything toString.getBooleancoerce string values —SpringDeclarativeConfigPropertieshas aTODO pointing at DeclarativeConfigProperties: no way to coerce types without triggering warnings opentelemetry-java#8101, which looks related.
Whichever direction is preferred, the registration entries for
DeclarativeConfigLoggingExporterAutoConfigurationneed to be added as part of it. Happy tosend a PR once the direction is settled.