Skip to content

Commit ceb8801

Browse files
committed
Make requests span attributes available to samplers
1 parent 1080b04 commit ceb8801

File tree

2 files changed

+8
-4
lines changed
  • instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests

2 files changed

+8
-4
lines changed

CHANGELOG.md

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

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

1517
### Fixed
1618

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,15 @@ def _instrumented_requests_call(
162162

163163
url = remove_url_credentials(url)
164164

165+
span_attributes = {
166+
SpanAttributes.HTTP_METHOD: method,
167+
SpanAttributes.HTTP_URL: url,
168+
}
169+
165170
with tracer.start_as_current_span(
166-
span_name, kind=SpanKind.CLIENT
171+
span_name, kind=SpanKind.CLIENT, attributes=span_attributes
167172
) as span, set_ip_on_next_http_connection(span):
168173
exception = None
169-
if span.is_recording():
170-
span.set_attribute(SpanAttributes.HTTP_METHOD, method)
171-
span.set_attribute(SpanAttributes.HTTP_URL, url)
172174

173175
headers = get_or_create_headers()
174176
inject(headers)

0 commit comments

Comments
 (0)