Make span attributes available to sampler in aiohttp_client (#1072)

This commit is contained in:
Nina Stawski
2022-04-28 13:47:30 -07:00
committed by GitHub
parent 9e539391b2
commit a8edcf6a52
2 changed files with 13 additions and 14 deletions

View File

@ -8,6 +8,8 @@ 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
([1072](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1072))
- `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))

View File

@ -180,27 +180,24 @@ def create_trace_config(
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,
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)
)