add thread details for declarative config#15209
add thread details for declarative config#15209zeitlinger wants to merge 6 commits intoopen-telemetry:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for configuring thread details (thread ID and thread name) as span attributes through declarative configuration in the instrumentation API. When enabled via configuration, an AttributesExtractor automatically adds thread information to spans created by instrumenters.
- Adds
ThreadDetailsAttributesExtractortoInstrumenterBuilderto capture thread ID and name - Integrates with declarative configuration under
instrumentation/java/thread_details/enabled - Adds comprehensive test coverage for both enabled and disabled states
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
InstrumenterBuilder.java |
Implements thread details extraction logic and configuration parsing |
AddThreadDetailsTest.java |
Tests thread details functionality with parameterized enabled/disabled scenarios |
build.gradle.kts |
Adds test dependency for declarative configuration support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../opentelemetry/javaagent/tooling/config/ThreadDetailsInstrumenterCustomizerProviderTest.java
Outdated
Show resolved
Hide resolved
...api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java
Outdated
Show resolved
Hide resolved
.../opentelemetry/javaagent/tooling/config/ThreadDetailsInstrumenterCustomizerProviderTest.java
Outdated
Show resolved
Hide resolved
6fb9796 to
29883b5
Compare
...api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java
Outdated
Show resolved
Hide resolved
...api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java
Outdated
Show resolved
Hide resolved
...api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java
Outdated
Show resolved
Hide resolved
trask
left a comment
There was a problem hiding this comment.
can you update the PR description with a summary of the relationship between this and the existing thread details span processor? and mention it's off by default when using declarative config (and we can consider making it off by default in 3.0 for others)
acdc794 to
dd2b211
Compare
created #15334 |
|
@trask please check again |
There was a problem hiding this comment.
@jaydeluca can you take a look also?
let's also figure out where to document this, ideally in same place as other declarative config "common" attributes
|
@trask please have another look |
fff4d30 to
8c8a96c
Compare
|
@trask please have another look |
46e9ee9 to
aaea68d
Compare
...t/java/io/opentelemetry/instrumentation/kafkaconnect/v2_6/MongoKafkaConnectSinkTaskTest.java
Show resolved
Hide resolved
|
@trask please have a look |
.../io/opentelemetry/instrumentation/api/incubator/thread/ThreadDetailsAttributesExtractor.java
Outdated
Show resolved
Hide resolved
|
discussed in Java declarative config SIG: let's move configuration under java agent and spring starter nodes, since this is something controlled by them as opposed to controlled by individual instrumentations |
OK waiting on #15822 then |
afa0353 to
babfd95
Compare
|
Rebased onto main and reworked based on SIG feedback:
All previous review comments should be addressed by this rework. |
Thread details (thread.id, thread.name) are now added via InstrumenterCustomizer instead of SpanProcessor, allowing native instrumentations to opt in. Configuration moves under distribution nodes: - javaagent: distribution.javaagent.thread_details_enabled (DC) / otel.javaagent.add-thread-details (env var, default true) - spring starter: instrumentation.spring_starter.thread_details.enabled (DC, default false) Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…rTest Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
33a00b1 to
6b0e17a
Compare
Java8RuntimeMetricsProvider and Java17RuntimeMetricsProvider are not @configuration classes and should not be registered as Spring auto-configurations. Their presence causes Spring AOT processing to fail with FileNotFoundException when the classes are not on the classpath. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…nfig registries Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
The Spring Boot starter's ThreadDetailsInstrumenterCustomizerProvider reads from the declarative config path spring_starter > thread_details > enabled, but the ConfigPropertiesBackedDeclarativeConfigProperties bridge only handles paths starting with "java." or explicitly listed in SPECIAL_MAPPINGS. This caused the property otel.instrumentation.common.thread-details.enabled to have no effect in non-declarative-config mode, breaking smoke tests. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Part of #14087
Alternative for #14564
Summary
Moves thread details (
thread.id,thread.name) from theAddThreadDetailsSpanProcessorto anInstrumenterCustomizer-based approach usingThreadDetailsAttributesExtractor. This means thread attributes are added viaAttributesExtractorat instrumentation build time rather than viaSpanProcessorat span start time.The existing
AddThreadDetailsSpanProcessoris still used for non-declarative-config agent mode (where it remains on by default viaotel.javaagent.add-thread-details=true). The newInstrumenterCustomizerpath is used for declarative config, where it is off by default — users must explicitly enable it:thread_details_enabled: trueunder thejava_agentdistribution node (default: false)thread_details.enabled: trueunderspring_starterinstrumentation config (default: false)otel.javaagent.add-thread-details(default: true, unchanged)Making it off by default in 3.0 for non-declarative-config users is tracked in #15334.
Approach
ThreadDetailsAttributesExtractorininstrumentation-api-incubatorcapturesthread.idandthread.nameon span startInstrumenterCustomizerProviderimplementations (one for agent, one for spring starter) register the extractor when enabledAgentDistributionConfig.isThreadDetailsEnabled()ExtendedOpenTelemetry.getInstrumentationConfig("spring_starter")instrumentation.common) per SIG feedback — this is controlled by agent/starter, not individual instrumentationsAddThreadDetailsSpanProcessorregistration is removed fromAgentTracerProviderConfigurer(the processor class itself is retained for non-DC use)