Skip to content

Commit

Permalink
Make requests span attributes available to samplers
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Feb 27, 2022
1 parent 1080b04 commit 1319498
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `opentelemetry-instrumentation-dbapi` add experimental sql commenter capability
([#908](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/908))
- `opentelemetry-instrumentation-requests` make span attribute available to samplers
([#931](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/931))

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ def _instrumented_requests_call(

url = remove_url_credentials(url)

span_attributes = {
SpanAttributes.HTTP_METHOD: method,
SpanAttributes.HTTP_URL: url,
}

with tracer.start_as_current_span(
span_name, kind=SpanKind.CLIENT
span_name, kind=SpanKind.CLIENT, attributes=span_attributes
) as span, set_ip_on_next_http_connection(span):
exception = None
if span.is_recording():
span.set_attribute(SpanAttributes.HTTP_METHOD, method)
span.set_attribute(SpanAttributes.HTTP_URL, url)

headers = get_or_create_headers()
inject(headers)
Expand Down

0 comments on commit 1319498

Please sign in to comment.