Differences in Starting Spans #2856
-
The other day I was working with a team mate on instrumenting some code and I noticed that he was using So, my question is: Why use one over the other? In looking at the docstrings for both, they sound more or less the same to me. In the docstring for with tracer.start_as_current_span("one") as parent:
parent.add_event("parent's event")
with trace.start_as_current_span("two") as child:
child.add_event("child's event")
trace.get_current_span() # returns child
trace.get_current_span() # returns parent
trace.get_current_span() # returns previously active span Is there any particular reason we would need to use Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Beta Was this translation helpful? Give feedback.
https://opentelemetry-python.readthedocs.io/en/latest/api/trace.html#opentelemetry.trace.Tracer.start_span
h…