Skip to content

Commit 27d6706

Browse files
authored
Pass request attributes to Sampler in Django (#1730)
1 parent 4e059b1 commit 27d6706

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
([#1645](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1645))
2020
- Add `excluded_urls` functionality to `urllib` and `urllib3` instrumentations
2121
([#1733](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1733))
22+
- Make Django request span attributes available for `start_span`.
23+
([#1730](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1730))
2224

2325
### Fixed
2426

instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/otel_middleware.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def process_request(self, request):
212212
carrier_getter = wsgi_getter
213213
collect_request_attributes = wsgi_collect_request_attributes
214214

215+
attributes = collect_request_attributes(carrier)
215216
span, token = _start_internal_or_server_span(
216217
tracer=self._tracer,
217218
span_name=self._get_span_name(request),
@@ -220,9 +221,9 @@ def process_request(self, request):
220221
),
221222
context_carrier=carrier,
222223
context_getter=carrier_getter,
224+
attributes=attributes,
223225
)
224226

225-
attributes = collect_request_attributes(carrier)
226227
active_requests_count_attrs = _parse_active_request_count_attrs(
227228
attributes
228229
)

0 commit comments

Comments
 (0)