Skip to content

Commit

Permalink
Fix tornado instrumentation's usage of Span Status
Browse files Browse the repository at this point in the history
Tornado will only set Status description if the accompanying status_code
is an error status.
  • Loading branch information
owais committed May 22, 2021
1 parent c8ec25a commit f792f1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 25b6746af2eac3a3ca72ab91d332cf8d317f9540
CORE_REPO_SHA: 32baf0672d3631e6c99e69502a5d5ffa81f610d3

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.2.0-0.21b0...HEAD)

- Fixed cases where description was used with non-error status code when creating Status objects.
([#503](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/503))

### Added
- `opentelemetry-instrumentation-botocore` now supports
context propagation for lambda invoke via Payload embedded headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def client_resposne_hook(span, future):
)
from opentelemetry.propagate import extract
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace.status import Status
from opentelemetry.trace.status import Status, StatusCode
from opentelemetry.util._time import _time_ns
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs

Expand Down Expand Up @@ -299,12 +299,11 @@ def _finish_span(tracer, handler, error=None):

if ctx.span.is_recording():
ctx.span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, status_code)
ctx.span.set_status(
Status(
status_code=http_status_to_status_code(status_code),
description=reason,
)
)
otel_status_code = http_status_to_status_code(status_code)
otel_status_description = None
if otel_status_code == StatusCode.ERROR:
otel_status_description = reason
ctx.span.set_status(Status(status_code=otel_status_code, description=otel_status_description))

ctx.activation.__exit__(*finish_args) # pylint: disable=E1101
context.detach(ctx.token)
Expand Down

0 comments on commit f792f1e

Please sign in to comment.