Skip to content

Commit d66a469

Browse files
authored
Merge branch 'main' into fix-async-redis-client-tracing
2 parents 159d514 + 7292bee commit d66a469

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10-
### Fixed
10+
### Added
11+
1112
- Fix async redis clients not being traced correctly ([#1830](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1830))
13+
- Make Flask request span attributes available for `start_span`.
14+
([#1784](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1784))
1215
- Fix falcon instrumentation's usage of Span Status to only set the description if the status code is ERROR.
1316
([#1840](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1840))
1417
- Instrument all httpx versions >= 0.18. ([#1748](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1748))

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -375,27 +375,26 @@ def _before_request():
375375
flask_request_environ = flask.request.environ
376376
span_name = get_default_span_name()
377377

378+
attributes = otel_wsgi.collect_request_attributes(
379+
flask_request_environ
380+
)
381+
if flask.request.url_rule:
382+
# For 404 that result from no route found, etc, we
383+
# don't have a url_rule.
384+
attributes[SpanAttributes.HTTP_ROUTE] = flask.request.url_rule.rule
378385
span, token = _start_internal_or_server_span(
379386
tracer=tracer,
380387
span_name=span_name,
381388
start_time=flask_request_environ.get(_ENVIRON_STARTTIME_KEY),
382389
context_carrier=flask_request_environ,
383390
context_getter=otel_wsgi.wsgi_getter,
391+
attributes=attributes,
384392
)
385393

386394
if request_hook:
387395
request_hook(span, flask_request_environ)
388396

389397
if span.is_recording():
390-
attributes = otel_wsgi.collect_request_attributes(
391-
flask_request_environ
392-
)
393-
if flask.request.url_rule:
394-
# For 404 that result from no route found, etc, we
395-
# don't have a url_rule.
396-
attributes[
397-
SpanAttributes.HTTP_ROUTE
398-
] = flask.request.url_rule.rule
399398
for key, value in attributes.items():
400399
span.set_attribute(key, value)
401400
if span.is_recording() and span.kind == trace.SpanKind.SERVER:

0 commit comments

Comments
 (0)