open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.99k stars 869 forks source link

I want to get http.requestbody in span #5832

Closed Rutik333 closed 2 years ago

Rutik333 commented 2 years ago

Is there any way to get http. Requestbody in trace span I'm using servlet

laurit commented 2 years ago

It is possible to capture servlet request parameters as span attributes. See https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/ It is not possible to capture the whole request body out of the box, but you can implement it yourself.

Rutik333 commented 2 years ago

@laurit I go through that article but I don't understand how to do that do you have any sample example?

I tried with @WithSpan and @SpanAttribute from https://opentelemetry.io/docs/instrumentation/java/automatic/annotations/ after adding that I'm getting request body but I don't want to do changes in my code please help me on this

laurit commented 2 years ago

If you do not wish to change you own code then you could use an agent extension https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/examples/extension or build a custom agent.

laurit commented 2 years ago

Feel free to reopen if you have more questions.

Cirilla-zmh commented 7 months ago

It is possible to capture servlet request parameters as span attributes. See https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/ It is not possible to capture the whole request body out of the box, but you can implement it yourself.

@laurit Hello, I was wondering if there are any considerations within the roadmap of java-instrumentation to include recording of the HTTP request body as a default or experimental attribute?

If not, is this due to the limit of performance/attribute value length, or other factors?

Thanks for your attention!

trask commented 7 months ago

hi @Cirilla-zmh, check out #8778