Setting an error in client response #3054
Replies: 2 comments
-
@kenfinnigan That looks basically correct - exceptions are really for things with a stack trace, while whether a span is an error or not is the However, you'll want to leave out the reason phrase generally. If you're instrumenting an HTTP client, you should keep the semantic conventions in mind https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md For example, HTTP Status is defined as ERROR for certain codes, and description should be left out if it just corresponds with the HTTP status code, filled as a separate attribute. And we're working on an instrumentation API to capture these semantic-convention concepts to make it easier to write instrumentation, when it's ready you'll probably want to use it, in the meantime it might give some hints open-telemetry/opentelemetry-java-instrumentation#2596 For example, we have this and we'd expect all HTTP instrumentations to use that and not worry about reimplementing the semantic conventions. |
Beta Was this translation helpful? Give feedback.
-
Handled vs unhandled is determined by the |
Beta Was this translation helpful? Give feedback.
-
When making a request from within a service to another external service I create a child span.
On receiving the response, I was looking at ways to set an error onto the span. I found that I couldn't use
recordException()
as I have an HTTP Response and not a Java Exception. The best I could figure is:Which sets the HTTP Response status reason onto the span status.
Is that sufficient? Am I missing another way to do this?
I was wondering if would be nice to be able to set an exception event onto the span even when there isn't an actual exception?
Beta Was this translation helpful? Give feedback.
All reactions