diff --git a/CHANGELOG.md b/CHANGELOG.md index 3449b5e72b..8874dca278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,16 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.10.0-0.29b0...HEAD) -## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0-0.29b0) - 2022-03-10 - +- `opentelemetry-instrumentation-flask` Fix non-recording span bug + ([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999) +- `opentelemetry-instrumentation-tornado` Fix non-recording span bug + ([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999) +## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0-0.29b0) - 2022-03-10 - `opentelemetry-instrumentation-wsgi` Capture custom request/response headers in span attributes ([#925])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/925) - - `opentelemetry-instrumentation-flask` Flask: Capture custom request/response headers in span attributes ([#952])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/952) - - `opentelemetry-instrumentation-tornado` Tornado: Capture custom request/response headers in span attributes ([#950])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/950) diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py index 1db768a2c0..272b0d934b 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -153,7 +153,10 @@ def _start_response(status, response_headers, *args, **kwargs): otel_wsgi.add_response_attributes( span, status, response_headers ) - if span.kind == trace.SpanKind.SERVER: + if ( + span.is_recording() + and span.kind == trace.SpanKind.SERVER + ): otel_wsgi.add_custom_response_headers( span, response_headers ) @@ -204,7 +207,7 @@ def _before_request(): ] = flask.request.url_rule.rule for key, value in attributes.items(): span.set_attribute(key, value) - if span.kind == trace.SpanKind.SERVER: + if span.is_recording() and span.kind == trace.SpanKind.SERVER: otel_wsgi.add_custom_request_headers( span, flask_request_environ ) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py index cec7662a29..fed27dfeac 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py @@ -340,7 +340,7 @@ def _start_span(tracer, handler, start_time) -> _TraceContext: for key, value in attributes.items(): span.set_attribute(key, value) span.set_attribute("tornado.handler", _get_full_handler_name(handler)) - if span.kind == trace.SpanKind.SERVER: + if span.is_recording() and span.kind == trace.SpanKind.SERVER: _add_custom_request_headers(span, handler.request.headers) activation = trace.use_span(span, end_on_exit=True) @@ -395,7 +395,7 @@ def _finish_span(tracer, handler, error=None): description=otel_status_description, ) ) - if ctx.span.kind == trace.SpanKind.SERVER: + if ctx.span.is_recording() and ctx.span.kind == trace.SpanKind.SERVER: _add_custom_response_headers(ctx.span, handler._headers) ctx.activation.__exit__(*finish_args) # pylint: disable=E1101