Skip to content

opentelemetry-instrumentation-asgi: always set status code on duration attributes #2627

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update is_recording for set_status
  • Loading branch information
lzchen authored Jul 11, 2024
commit c75e732ac435354c2e1f24d8c98e99a8d4fa8c97
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ def _set_status(
):
if status_code < 0:
if _report_new(sem_conv_opt_in_mode):
span.set_attribute(ERROR_TYPE, status_code_str)
if span.is_recording():
span.set_attribute(ERROR_TYPE, status_code_str)
metrics_attributes[ERROR_TYPE] = status_code_str

span.set_status(
Expand All @@ -369,13 +370,16 @@ def _set_status(
status = http_status_to_status_code(status_code, server_span=True)

if _report_old(sem_conv_opt_in_mode):
span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, status_code)
if span.is_recording():
span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, status_code)
metrics_attributes[SpanAttributes.HTTP_STATUS_CODE] = status_code
if _report_new(sem_conv_opt_in_mode):
span.set_attribute(HTTP_RESPONSE_STATUS_CODE, status_code)
if span.is_recording():
span.set_attribute(HTTP_RESPONSE_STATUS_CODE, status_code)
metrics_attributes[HTTP_RESPONSE_STATUS_CODE] = status_code
if status == StatusCode.ERROR:
span.set_attribute(ERROR_TYPE, status_code_str)
if span.is_recording():
span.set_attribute(ERROR_TYPE, status_code_str)
metrics_attributes[ERROR_TYPE] = status_code_str
span.set_status(Status(status))

Expand Down
Loading