Description
Describe the bug
Failure to disable resource properties from a structured log message.
I want to log only resource attributes I set in the configuration YAML, so I added
otel:
java:
enabled:
resource:
providers: io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider
Which almost did the job, I still get:
"telemetry": {
"sdk": {
"name": "opentelemetry",
"language": "java",
"version": "1.42.1"
}
}
I tried using:
otel:
experimental:
resource:
disabled:
keys: [ telemetry.sdk.language, telemetry.sdk.name, telemetry.sdk.version ] not working
Steps to reproduce
Create a project using Spring Boot Starter and configure otlp export to collector through grpc.
Produce a log message.
Observe the log message in elastic through the elastic exporter.
What did you expect to see?
When specifying io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider
I expected to see only
"Resource": {
"environment": "dev",
"service": {
"name": "PoC-OpenTelemetry-SP3-Webflux-REST"
}
}
since this is what I have set in the application yaml.
What did you see instead?
I saw an additional resource in the structured log message:
"telemetry": {
"sdk": {
"name": "opentelemetry",
"language": "java",
"version": "1.42.1"
}
}
Full YAML config:
# Simulated environment variable injection
APP_ENV: dev
LOGBACK_EXPERIMENTAL_LOG_ATTRIBUTES: false # Enable the capture of experimental log attributes thread.name and thread.id
LOGBACK_CAPTURE_MDC_ATTRIBUTES: "*" # Comma separated list of MDC attributes to capture. Use the wildcard character * to capture all attributes.
LOGBACK_CAPTURE_CODE_ATTRIBUTES: false # Enable the capture of source code attributes. Note that capturing source code attributes at logging sites might add a performance overhead.
LOGBACK_CAPTURE_MARKER_ATTRIBUTE: false # Enable the capture of Logback markers as attributes.
LOGBACK_CAPTURE_LOGGER_CONTEXT_ATTRIBUTES: false # Enable the capture of Logback logger context properties as attributes. (This feature adds MDC properties as top level attributes instead of nested in _source)
LOGBACK_CAPTURE_KEY_VALUE_PAIR_ATTRIBUTES: false # Enable the capture of Logback key value pairs as attributes.
OTLP_PROTOCOL: grpc
OTLP_ENDPOINT: http://localhost:4317
otel:
exporter:
otlp:
endpoint: ${OTLP_ENDPOINT}
protocol: ${OTLP_PROTOCOL}
metrics:
exporter: [ otlp ]
traces:
exporter: [ otlp ]
propagators: [ tracecontext ]
resource:
attributes:
environment: ${APP_ENV}
instrumentation:
logback-appender:
experimental-log-attributes: ${LOGBACK_EXPERIMENTAL_LOG_ATTRIBUTES}
experimental:
capture-mdc-attributes: ${LOGBACK_CAPTURE_MDC_ATTRIBUTES}
capture-code-attributes: ${LOGBACK_CAPTURE_CODE_ATTRIBUTES}
capture-marker-attribute: ${LOGBACK_CAPTURE_MARKER_ATTRIBUTE}
capture-logger-context-attributes: ${LOGBACK_CAPTURE_LOGGER_CONTEXT_ATTRIBUTES}
capture-key-value-pair-attributes: ${LOGBACK_CAPTURE_KEY_VALUE_PAIR_ATTRIBUTES}
java:
enabled:
resource:
providers: io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider
experimental:
resource:
disabled:
keys: [ telemetry.sdk.language, telemetry.sdk.name, telemetry.sdk.version ]
service:
name: ${spring.application.name}
What version and what artifacts are you using?
How did you reference these artifacts? pom.xml
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
</dependency>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-bom</artifactId>
<version>2.8.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Environment
Compiler: coretto-21.0.4
OS: Windows 11
Additional context
Just to note: io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider
is not described here: https://opentelemetry.io/docs/languages/java/configuration/#resourceprovider
Also, can you please tell me how can I toggle all the other attributes present in the structured log:
For example, I don't want:
- TraceFlags
- SeverityText
- SeverityNumber
- data_stream.type