Docs: fix span links in python example (#2553)
This commit is contained in:
parent
8a7d2fba54
commit
f05cc7f5de
|
@ -210,15 +210,18 @@ causally link it to another span. A link needs a span context to be created.
|
||||||
```python
|
```python
|
||||||
from opentelemetry import trace
|
from opentelemetry import trace
|
||||||
|
|
||||||
ctx = trace.get_current_span().get_span_context()
|
tracer = trace.get_tracer(__name__)
|
||||||
|
|
||||||
link_from_current = trace.Link(ctx)
|
with tracer.start_as_current_span("span-1"):
|
||||||
|
# Do something that 'span-1' tracks.
|
||||||
|
ctx = trace.get_current_span().get_span_context()
|
||||||
|
link_from_span_1 = trace.Link(ctx)
|
||||||
|
|
||||||
with tracer.start_as_current_span("new-span", links=[link_from_current]) as new_span:
|
with tracer.start_as_current_span("span-2", links=[link_from_span_1]):
|
||||||
# do something that 'new_span' tracks
|
# Do something that 'span-2' tracks.
|
||||||
|
# The link in 'span-2' is casually associated it with the 'span-1',
|
||||||
# The link in 'new_span' casually associated it with the previous one,
|
|
||||||
# but it is not a child span.
|
# but it is not a child span.
|
||||||
|
pass
|
||||||
```
|
```
|
||||||
|
|
||||||
### Set span status
|
### Set span status
|
||||||
|
|
Loading…
Reference in New Issue