Skip to content

Commit f9f7b01

Browse files
Fix falcon usage of Span Status (#1840)
* Fix falcon usage of Span Status to only set the description if the status code is ERROR * Update changelog * Update CHANGELOG.md Co-authored-by: Srikanth Chekuri <[email protected]> * fix lint * Use fewer variables to satisfy R0914 lint rule --------- Co-authored-by: Srikanth Chekuri <[email protected]>
1 parent 743ac64 commit f9f7b01

File tree

2 files changed

+14
-6
lines changed
  • instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon

2 files changed

+14
-6
lines changed

Diff for: CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Fix falcon instrumentation's usage of Span Status to only set the description if the status code is ERROR.
11+
([#1840](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1840))
1012
- Instrument all httpx versions >= 0.18. ([#1748](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1748))
1113

1214
## Version 1.18.0/0.39b0 (2023-05-10)
@@ -23,9 +25,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2325
([#1778](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1778))
2426
- Add `excluded_urls` functionality to `urllib` and `urllib3` instrumentations
2527
([#1733](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1733))
26-
- Make Django request span attributes available for `start_span`.
28+
- Make Django request span attributes available for `start_span`.
2729
([#1730](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1730))
28-
- Make ASGI request span attributes available for `start_span`.
30+
- Make ASGI request span attributes available for `start_span`.
2931
([#1762](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1762))
3032
- `opentelemetry-instrumentation-celery` Add support for anonymous tasks.
3133
([#1407](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1407))

Diff for: instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def response_hook(span, req, resp):
208208
from opentelemetry.metrics import get_meter
209209
from opentelemetry.semconv.metrics import MetricInstruments
210210
from opentelemetry.semconv.trace import SpanAttributes
211-
from opentelemetry.trace.status import Status
211+
from opentelemetry.trace.status import Status, StatusCode
212212
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs
213213

214214
_logger = getLogger(__name__)
@@ -461,11 +461,17 @@ def process_response(
461461
try:
462462
status_code = int(status)
463463
span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, status_code)
464+
otel_status_code = http_status_to_status_code(
465+
status_code, server_span=True
466+
)
467+
468+
# set the description only when the status code is ERROR
469+
if otel_status_code is not StatusCode.ERROR:
470+
reason = None
471+
464472
span.set_status(
465473
Status(
466-
status_code=http_status_to_status_code(
467-
status_code, server_span=True
468-
),
474+
status_code=otel_status_code,
469475
description=reason,
470476
)
471477
)

0 commit comments

Comments
 (0)