open-telemetry / opentelemetry-java-instrumentation

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

http.status_code attribute in span was not being populated when AWS APIs were returning non-200 status codes #8795

Open scaugrated opened 1 year ago

scaugrated commented 1 year ago

Is your feature request related to a problem? Please describe.

We were attempting to implement logic based on the http.status_code attribute found in spans and observed it was not being populated for spans coming out of the AWS SDK when the AWS APIs were returning non-200 status codes.

Here are the details of the investigation for this issue by @thpierce :

Describe the solution you'd like

Fundamentally, the problem is that the common HTTP instrumentation code assumes that status codes can only be delivered via response objects, but the AWS SDK delivers status codes via exceptions.

We look forward to have a comprehensive solution to solve this problem.

In the short term, we have come up with a solution relying on the fact that the exception thrown by the AWS SDK is stored within the produced spans and is accessible in the AwsSpanMetricsProcessor, where we generate Fault/Error metrics.

Describe alternatives you've considered

No response

Additional context

No response

mateuszrzeszutek commented 1 year ago

This is closely related to https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/8453 If the AWS SDK instrumentation did not attempt to implement the HTTP semconv itself, and simply left it to the underlying HTTP instrumentation, this most likely wouldn't be a problem.