Skip to content

Commit

Permalink
Request Flask attributes passed to Sampler (#1784)
Browse files Browse the repository at this point in the history
* Request Flask attributes passed to Sampler

* Update changelog

* Lint

* Fix botocore test keyerror

* Revert "Fix botocore test keyerror"

This reverts commit fd03c55.

* botocore test does get_queue_url

* Revert "botocore test does get_queue_url"

This reverts commit 9530cd2.

* Update changelog

---------

Co-authored-by: Srikanth Chekuri <[email protected]>
Co-authored-by: Shalev Roda <[email protected]>
  • Loading branch information
3 people authored Jun 16, 2023
1 parent f9f7b01 commit 7292bee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,27 +375,26 @@ def _before_request():
flask_request_environ = flask.request.environ
span_name = get_default_span_name()

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
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():
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
for key, value in attributes.items():
span.set_attribute(key, value)
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
Expand Down

0 comments on commit 7292bee

Please sign in to comment.