Skip to content

Commit

Permalink
Docs: fix span links in python example (open-telemetry#2553)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikek authored Mar 29, 2023
1 parent 8a7d2fb commit f05cc7f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions content/en/docs/instrumentation/python/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,18 @@ causally link it to another span. A link needs a span context to be created.
```python
from opentelemetry import trace

ctx = trace.get_current_span().get_span_context()

link_from_current = trace.Link(ctx)
tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("new-span", links=[link_from_current]) as new_span:
# do something that 'new_span' tracks
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)

# The link in 'new_span' casually associated it with the previous one,
with tracer.start_as_current_span("span-2", links=[link_from_span_1]):
# Do something that 'span-2' tracks.
# The link in 'span-2' is casually associated it with the 'span-1',
# but it is not a child span.
pass
```

### Set span status
Expand Down

0 comments on commit f05cc7f

Please sign in to comment.