Skip to content

Commit 640b117

Browse files
author
Alex Boten
authored
fix non-recording bug (#999)
1 parent 8fc95ca commit 640b117

File tree

3 files changed

+12
-8
lines changed
  • instrumentation
    • opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask
    • opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado

3 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.10.0-0.29b0...HEAD)
99

10-
## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0-0.29b0) - 2022-03-10
11-
10+
- `opentelemetry-instrumentation-flask` Fix non-recording span bug
11+
([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999)
12+
- `opentelemetry-instrumentation-tornado` Fix non-recording span bug
13+
([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999)
1214

15+
## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0-0.29b0) - 2022-03-10
1316

1417
- `opentelemetry-instrumentation-wsgi` Capture custom request/response headers in span attributes
1518
([#925])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/925)
16-
1719
- `opentelemetry-instrumentation-flask` Flask: Capture custom request/response headers in span attributes
1820
([#952])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/952)
19-
2021
- `opentelemetry-instrumentation-tornado` Tornado: Capture custom request/response headers in span attributes
2122
([#950])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/950)
2223

instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def _start_response(status, response_headers, *args, **kwargs):
153153
otel_wsgi.add_response_attributes(
154154
span, status, response_headers
155155
)
156-
if span.kind == trace.SpanKind.SERVER:
156+
if (
157+
span.is_recording()
158+
and span.kind == trace.SpanKind.SERVER
159+
):
157160
otel_wsgi.add_custom_response_headers(
158161
span, response_headers
159162
)
@@ -204,7 +207,7 @@ def _before_request():
204207
] = flask.request.url_rule.rule
205208
for key, value in attributes.items():
206209
span.set_attribute(key, value)
207-
if span.kind == trace.SpanKind.SERVER:
210+
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
208211
otel_wsgi.add_custom_request_headers(
209212
span, flask_request_environ
210213
)

instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def _start_span(tracer, handler, start_time) -> _TraceContext:
340340
for key, value in attributes.items():
341341
span.set_attribute(key, value)
342342
span.set_attribute("tornado.handler", _get_full_handler_name(handler))
343-
if span.kind == trace.SpanKind.SERVER:
343+
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
344344
_add_custom_request_headers(span, handler.request.headers)
345345

346346
activation = trace.use_span(span, end_on_exit=True)
@@ -395,7 +395,7 @@ def _finish_span(tracer, handler, error=None):
395395
description=otel_status_description,
396396
)
397397
)
398-
if ctx.span.kind == trace.SpanKind.SERVER:
398+
if ctx.span.is_recording() and ctx.span.kind == trace.SpanKind.SERVER:
399399
_add_custom_response_headers(ctx.span, handler._headers)
400400

401401
ctx.activation.__exit__(*finish_args) # pylint: disable=E1101

0 commit comments

Comments
 (0)