open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Instrumentation config add traceid to http server response header
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Is your feature request related to a problem? Please describe.
The scenario is to expect that the response header can be added quickly in the service close to the frontend without extending HttpServerResponseCustomizer
Does this requirement involve sepcs?
Describe the solution you'd like
The configuration is probably like this,default value is null
otel.instrumentation.common.http.server.tracei.header.name=X-Test-TraceId
Similar behavior to below
@AutoService(HttpServerResponseCustomizer.class)
public class TestAgentHttpResponseCustomizer implements HttpServerResponseCustomizer {
@Override
public <T> void customize(
Context serverContext, T response, HttpServerResponseMutator<T> responseMutator) {
SpanContext spanContext = Span.fromContext(serverContext).getSpanContext();
String traceId = spanContext.getTraceId();
responseMutator.appendHeader(response, "X-Test-TraceId", traceId);
}
}
Describe alternatives you've considered
No response
Additional context
No response
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 by tracing the existing HttpServerResponseCustomizer entry point and how instrumentation configuration keys are defined and consumed. Check whether the proposed otel.instrumentation.common.http.server.tracei.header.name setting can apply across HTTP server instrumentations, then verify the configured header and trace ID behavior with the relevant HTTP response tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100