mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-01 09:13:23 +08:00
Make requests span attributes available to samplers (#931)
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -162,13 +162,15 @@ def _instrument(
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user