Skip to content

Commit 34ea942

Browse files
committed
Add a way to retrieve current context of active span
1 parent 4bfca0b commit 34ea942

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

instana/tracer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class InstanaTracer(BasicTracer):
1616
sensor = None
17+
current_span = None
1718

1819
def __init__(self, options=o.Options()):
1920
self.sensor = instana.global_sensor
@@ -57,14 +58,19 @@ def start_span(
5758
ctx.sampled = self.sampler.sampled(ctx.trace_id)
5859

5960
# Tie it all together
60-
return BasicSpan(
61+
self.current_span = BasicSpan(
6162
self,
6263
operation_name=operation_name,
6364
context=ctx,
6465
parent_id=(None if parent_ctx is None else parent_ctx.span_id),
6566
tags=tags,
6667
start_time=start_time)
6768

69+
return self.current_span
70+
71+
def current_context(self):
72+
return self.current_span.context
73+
6874
def inject(self, span_context, format, carrier):
6975
if format in self._propagators:
7076
self._propagators[format].inject(span_context, carrier)

0 commit comments

Comments
 (0)