From open-telemetry/opentelemetry-java-instrumentation#15775 (comment)
Problem
YamlDeclarativeConfigProperties logs WARNING-level messages when a getter is called for a type that doesn't match the stored value:
WARNING: Ignoring value for key [foo] because it is Long instead of String
This means we can't build a type-coercing DeclarativeConfigProperties decorator without producing invalid warnings.
Use case
The Spring Boot starter populates OpenTelemetry's declarative config YAML from Spring's property system. Spring flattens its own YAML into key-value pairs and resolves ${} placeholders via Environment.getProperty(), which always returns String. These flat string properties are then converted back into a nested map and fed to Jackson's ObjectMapper.convertValue() to produce an OpenTelemetryConfigurationModel, which ultimately backs a YamlDeclarativeConfigProperties.
The problem is that the resulting types are inconsistent:
- Values from plain YAML (e.g.
int_key: 42) are stored as their native types (Integer, Boolean, Double)
- Values resolved through Spring placeholders (e.g.
int_key: ${INT_ENV:42}) arrive as String ("42")
We'd like to use a type-coercing decorator around DeclarativeConfigProperties to handle both cases transparently, but there is no way to check the actual stored type without triggering the WARNING-level logs, e.g.
- Calling
delegate.getString("int_key") on a natively-typed Integer logs: "Ignoring value for key [int_key] because it is Integer instead of String"
From open-telemetry/opentelemetry-java-instrumentation#15775 (comment)
Problem
YamlDeclarativeConfigPropertieslogsWARNING-level messages when a getter is called for a type that doesn't match the stored value:This means we can't build a type-coercing
DeclarativeConfigPropertiesdecorator without producing invalid warnings.Use case
The Spring Boot starter populates OpenTelemetry's declarative config YAML from Spring's property system. Spring flattens its own YAML into key-value pairs and resolves
${}placeholders viaEnvironment.getProperty(), which always returnsString. These flat string properties are then converted back into a nested map and fed to Jackson'sObjectMapper.convertValue()to produce anOpenTelemetryConfigurationModel, which ultimately backs aYamlDeclarativeConfigProperties.The problem is that the resulting types are inconsistent:
int_key: 42) are stored as their native types (Integer,Boolean,Double)int_key: ${INT_ENV:42}) arrive asString("42")We'd like to use a type-coercing decorator around
DeclarativeConfigPropertiesto handle both cases transparently, but there is no way to check the actual stored type without triggering theWARNING-level logs, e.g.delegate.getString("int_key")on a natively-typedIntegerlogs:"Ignoring value for key [int_key] because it is Integer instead of String"