-
Notifications
You must be signed in to change notification settings - Fork 698
Add coding examples for context #1165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add coding examples for context #1165
Conversation
|
||
|
||
async def main(): | ||
span = tracer.start_span(name="span", parent=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent is no longer a valid parameter here as of #1146, the parent is always passed in via the context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the examples are really close, just some changes due to #1146
with tracer.start_as_current_span(name="root span", parent=None) as root_span: | ||
parent_ctx = baggage.set_baggage("context", "parent") | ||
with tracer.start_as_current_span( | ||
name="child span", parent=root_span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name="child span", parent=root_span | |
name="child span", context=parent_ctx |
docs/faq-and-cookbook.rst
Outdated
from opentelemetry import trace | ||
|
||
tracer = trace.get_tracer(__name__) | ||
with tracer.start_as_current_span(name="root span", parent=None) as root_span: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with tracer.start_as_current_span(name="root span", parent=None) as root_span: | |
with tracer.start_as_current_span(name="root span", context=None) as root_span: |
docs/faq-and-cookbook.rst
Outdated
tracer = trace.get_tracer(__name__) | ||
with tracer.start_as_current_span(name="root span", parent=None) as root_span: | ||
parent_ctx = baggage.set_baggage("context", "parent") | ||
with tracer.start_as_current_span(name="child span", parent=root_span) as child_span: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above here, you'll want to pass in the context, rather than the span
eb3a27c
to
997f88d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
The branch will need to be updated before merging. |
Description
This PR adds coding samples in the documentation highlighting context behaviour.
Fixes #1140
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist: