Skip to content

Commit 80b6ce7

Browse files
committed
tornado: pass request attributes at span creation
To ease sampling.
1 parent ea03d20 commit 80b6ce7

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado

instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -754,22 +754,21 @@ def _get_full_handler_name(handler):
754754

755755

756756
def _start_span(tracer, handler, sem_conv_opt_in_mode) -> _TraceContext:
757+
attributes = _get_attributes_from_request(
758+
handler.request, sem_conv_opt_in_mode
759+
)
757760
span, token = _start_internal_or_server_span(
758761
tracer=tracer,
759762
span_name=_get_default_span_name(handler.request),
760763
start_time=time_ns(),
761764
context_carrier=handler.request.headers,
762765
context_getter=textmap.default_getter,
766+
attributes=attributes,
763767
)
764768

765769
if span.is_recording():
766-
attributes = _get_attributes_from_request(
767-
handler.request, sem_conv_opt_in_mode
768-
)
769-
for key, value in attributes.items():
770-
span.set_attribute(key, value)
771770
span.set_attribute("tornado.handler", _get_full_handler_name(handler))
772-
if span.is_recording() and span.kind == trace.SpanKind.SERVER:
771+
if span.kind == trace.SpanKind.SERVER:
773772
custom_attributes = _collect_custom_request_headers_attributes(
774773
handler.request.headers
775774
)

0 commit comments

Comments
 (0)