Skip to content

Commit 20c1cb9

Browse files
authored
When Flask activation is missing, do not emit a log message (#253)
If a Flask request doesn't have an active span, it just means that it was initialized via a mechanism that doesn't run `before_request`, like `app.test_request_context` or even manually. It is okay and instrumentation still works.
1 parent dc24b9d commit 20c1cb9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
([#236](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/236))
3636
- `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-falcon`, `opentelemetry-instrumentation-flask`, `opentelemetry-instrumentation-pyramid`, `opentelemetry-instrumentation-wsgi` Renamed `host.port` attribute to `net.host.port`
3737
([#242](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/242))
38+
- `opentelemetry-instrumentation-flask` Do not emit a warning message for request contexts created with `app.test_request_context`
39+
([#253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/253))
3840

3941
## [0.16b1](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.16b1) - 2020-11-26
4042

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,9 @@ def _teardown_request(exc):
149149

150150
activation = flask.request.environ.get(_ENVIRON_ACTIVATION_KEY)
151151
if not activation:
152-
_logger.warning(
153-
"Flask environ's OpenTelemetry activation missing"
154-
"at _teardown_flask_request(%s)",
155-
exc,
156-
)
152+
# This request didn't start a span, maybe because it was created in a
153+
# way that doesn't run `before_request`, like when it is created with
154+
# `app.test_request_context`.
157155
return
158156

159157
if exc is None:

0 commit comments

Comments
 (0)