Skip to content

Commit

Permalink
Merge branch 'main' into zachg/make_baggage_extraction_wsgi_compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
ZStriker19 authored Jan 6, 2025
2 parents 797198a + 81208cd commit f2c0a3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion ddtrace/internal/opentelemetry/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,16 @@ def set_status(self, status, description=None):
return

if isinstance(status, Status):
if description is not None and description != status.description:
log.warning(
"Conflicting descriptions detected. The following description will not be set on the %s span: %s. "
"Ensure `Span.set_status(...)` is called with `(Status(status_code, description), None)` "
"or `(status_code, description)`",
self._ddspan.name,
description,
)
status_code = status.status_code
message = status.description
log.warning("Description %s ignored. Use either `Status` or `(StatusCode, Description)`", description)
else:
status_code = status
message = description
Expand Down
5 changes: 3 additions & 2 deletions tests/opentelemetry/test_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ def test_otel_span_status_with_status_obj(oteltracer, caplog):
assert errspan_dup_des._ddspan.error == 1
assert errspan_dup_des._ddspan.get_tag("error.message") in "main otel err message"
assert (
"Description ot_duplicate_message ignored. Use either `Status` or `(StatusCode, Description)`"
in caplog.text
"Conflicting descriptions detected. The following description will not be set "
"on the otel-error-dup-description span: ot_duplicate_message. Ensure `Span.set_status(...)` "
"is called with `(Status(status_code, description), None)` or `(status_code, description)`" in caplog.text
)

with oteltracer.start_span("set-status-on-otel-span") as span1:
Expand Down

0 comments on commit f2c0a3c

Please sign in to comment.