Skip to content

Commit

Permalink
Make span attributes available in aiohttp-client
Browse files Browse the repository at this point in the history
Fixes opentelemetry-python-contrib#939
  • Loading branch information
nstawski committed Apr 27, 2022
1 parent 9e53939 commit b977d89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.11.1-0.30b1...HEAD)

### Fixed
- `opentelemetry-instrumentation-aiohttp-client` make span attributes available to sampler
- `opentelemetry-instrumentation-aws-lambda` Fixed an issue - in some rare cases (API GW proxy integration test)
headers are set to None, breaking context propagators.
([#1055](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1055))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,22 @@ async def on_request_start(

http_method = params.method.upper()
request_span_name = f"HTTP {http_method}"
request_url = remove_url_credentials(trace_config_ctx.url_filter(params.url)) if callable(trace_config_ctx.url_filter) else remove_url_credentials(str(params.url)),

span_attributes = {
SpanAttributes.HTTP_METHOD: http_method,
SpanAttributes.HTTP_URL: request_url,
}

trace_config_ctx.span = trace_config_ctx.tracer.start_span(
request_span_name,
kind=SpanKind.CLIENT,
attributes=span_attributes
)

if callable(request_hook):
request_hook(trace_config_ctx.span, params)

if trace_config_ctx.span.is_recording():
attributes = {
SpanAttributes.HTTP_METHOD: http_method,
SpanAttributes.HTTP_URL: remove_url_credentials(
trace_config_ctx.url_filter(params.url)
)
if callable(trace_config_ctx.url_filter)
else remove_url_credentials(str(params.url)),
}
for key, value in attributes.items():
trace_config_ctx.span.set_attribute(key, value)

trace_config_ctx.token = context_api.attach(
trace.set_span_in_context(trace_config_ctx.span)
)
Expand Down

0 comments on commit b977d89

Please sign in to comment.