-
Notifications
You must be signed in to change notification settings - Fork 662
Allow ability to add attributes to span with otelhttp span #6769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Your request is rather unclear. span := trace.SpanFromContext(req.Context())
span.SetAttributes(attribute.Bool("isTrue", true), attribute.String("stringAttr", "hi!")) So all you need to add custom attributes to the current span in HTTP, is a custom handler/middleware that retrieves the span and does what you wish to do. |
@dmathieu i could customize the span name of the span created by otelhttp (instrumentationScopeName: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp) and (kind: client), the one like below
When I try to add like below it is adding the attributes to the parent span, but not to the one above. |
If you're talking about the span for an outgoing HTTP call, it's even easier. client := http.Client{
Transport: otelhttp.NewTransport(
http.DefaultTransport,
otelhttp.WithSpanOptions(
trace.WithAttributes(
attribute.Bool("isTrue", true),
attribute.String("stringAttr", "hi!"),
),
),
),
} |
Is there a way to add per request span attributes. for example. i want to extract some fields from request body and set them as span attributes. the above is while initializing the http.Client |
A custom HTTP transport would allow you to hook into the middle of the request, and modify the span. |
Problem Statement
Add ability to add custom span attributes to the span with instrumentationScopeName go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp and kind client
Proposed Solution
A clear and concise description of what you want to happen.
Alternatives
A clear and concise description of any alternative solutions or features you've considered.
Prior Art
A clear and concise list of any similar and existing solutions from other projects that provide context to possible solutions.
Additional Context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: