Skip to content

Commit bbde08c

Browse files
committed
fix: add custom span name param
Param `span_name` already used in the docs! So let it works! ;) open-telemetry#848
1 parent d01efe5 commit bbde08c

File tree

1 file changed

+3
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client

1 file changed

+3
-1
lines changed

Diff for: instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def create_trace_config(
146146
request_hook: _RequestHookT = None,
147147
response_hook: _ResponseHookT = None,
148148
tracer_provider: TracerProvider = None,
149+
span_name: typing.Optional[str] = None,
149150
) -> aiohttp.TraceConfig:
150151
"""Create an aiohttp-compatible trace configuration.
151152
@@ -173,6 +174,7 @@ def create_trace_config(
173174
:param Callable request_hook: Optional callback that can modify span name and request params.
174175
:param Callable response_hook: Optional callback that can modify span name and response params.
175176
:param tracer_provider: optional TracerProvider from which to get a Tracer
177+
:param span_name: Optional custom span name
176178
177179
:return: An object suitable for use with :py:class:`aiohttp.ClientSession`.
178180
:rtype: :py:class:`aiohttp.TraceConfig`
@@ -198,7 +200,7 @@ async def on_request_start(
198200
return
199201

200202
http_method = params.method.upper()
201-
request_span_name = f"HTTP {http_method}"
203+
request_span_name = f"HTTP {http_method}" if span_name is None else span_name
202204

203205
trace_config_ctx.span = trace_config_ctx.tracer.start_span(
204206
request_span_name,

0 commit comments

Comments
 (0)