class NatWorkflowTracer(Tracer):
"""Tracer that joins SDK spans to the active NAT workflow trace when possible."""
def __init__(self, delegate: Tracer) -> None:
self._delegate = delegate
def start_span(
self,
name: str,
context: otel_context.Context | None = None,
kind: SpanKind = SpanKind.INTERNAL,
attributes: Attributes = None,
links: Link | None = None,
start_time: int | None = None,
record_exception: bool = True,
set_status_on_exception: bool = True,
) -> Span:
with use_nat_workflow_trace_context():
return self._delegate.start_span(
name,
context=context,
kind=kind,
attributes=attributes,
links=links,
start_time=start_time,
record_exception=record_exception,
set_status_on_exception=set_status_on_exception,
)
def start_as_current_span(
self,
name: str,
context: otel_context.Context | None = None,
kind: SpanKind = SpanKind.INTERNAL,
attributes: Attributes = None,
links: Link | None = None,
start_time: int | None = None,
record_exception: bool = True,
set_status_on_exception: bool = True,
end_on_exit: bool = True,
) -> AbstractContextManager[Span]:
return _NatWorkflowSpanContextManager(
self._delegate.start_as_current_span(
name,
context=context,
kind=kind,
attributes=attributes,
links=links,
start_time=start_time,
record_exception=record_exception,
set_status_on_exception=set_status_on_exception,
end_on_exit=end_on_exit,
)
)