mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 05:04:05 +08:00
Request Flask attributes passed to Sampler (#1784)
* Request Flask attributes passed to Sampler * Update changelog * Lint * Fix botocore test keyerror * Revert "Fix botocore test keyerror" This reverts commit fd03c55a3902b3456afd6a2ecf429afba11b0691. * botocore test does get_queue_url * Revert "botocore test does get_queue_url" This reverts commit 9530cd250dd836b3181a9361decb130e2aae1202. * Update changelog --------- Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com> Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
This commit is contained in:
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- Make Flask request span attributes available for `start_span`.
|
||||
([#1784](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1784))
|
||||
- Fix falcon instrumentation's usage of Span Status to only set the description if the status code is ERROR.
|
||||
([#1840](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1840))
|
||||
- Instrument all httpx versions >= 0.18. ([#1748](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1748))
|
||||
|
@ -375,27 +375,26 @@ def _wrapped_before_request(
|
||||
flask_request_environ = flask.request.environ
|
||||
span_name = get_default_span_name()
|
||||
|
||||
span, token = _start_internal_or_server_span(
|
||||
tracer=tracer,
|
||||
span_name=span_name,
|
||||
start_time=flask_request_environ.get(_ENVIRON_STARTTIME_KEY),
|
||||
context_carrier=flask_request_environ,
|
||||
context_getter=otel_wsgi.wsgi_getter,
|
||||
)
|
||||
|
||||
if request_hook:
|
||||
request_hook(span, flask_request_environ)
|
||||
|
||||
if span.is_recording():
|
||||
attributes = otel_wsgi.collect_request_attributes(
|
||||
flask_request_environ
|
||||
)
|
||||
if flask.request.url_rule:
|
||||
# For 404 that result from no route found, etc, we
|
||||
# don't have a url_rule.
|
||||
attributes[
|
||||
SpanAttributes.HTTP_ROUTE
|
||||
] = flask.request.url_rule.rule
|
||||
attributes[SpanAttributes.HTTP_ROUTE] = flask.request.url_rule.rule
|
||||
span, token = _start_internal_or_server_span(
|
||||
tracer=tracer,
|
||||
span_name=span_name,
|
||||
start_time=flask_request_environ.get(_ENVIRON_STARTTIME_KEY),
|
||||
context_carrier=flask_request_environ,
|
||||
context_getter=otel_wsgi.wsgi_getter,
|
||||
attributes=attributes,
|
||||
)
|
||||
|
||||
if request_hook:
|
||||
request_hook(span, flask_request_environ)
|
||||
|
||||
if span.is_recording():
|
||||
for key, value in attributes.items():
|
||||
span.set_attribute(key, value)
|
||||
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
|
||||
|
Reference in New Issue
Block a user