explicit span management using with

This commit is contained in:
Dinesh Yeduguru 2024-11-25 13:07:43 -08:00
parent 6411007024
commit b3021ea2da
3 changed files with 114 additions and 96 deletions

View file

@ -253,3 +253,11 @@ class SpanContextManager:
def span(name: str, attributes: Dict[str, Any] = None):
return SpanContextManager(name, attributes)
def get_current_span() -> Optional[Span]:
global CURRENT_TRACE_CONTEXT
context = CURRENT_TRACE_CONTEXT
if context:
return context.get_current_span()
return None