Add coding examples for context#1165
Merged
codeboten merged 4 commits intoopen-telemetry:masterfrom Oct 22, 2020
Merged
Conversation
codeboten
reviewed
Oct 14, 2020
|
|
||
|
|
||
| async def main(): | ||
| span = tracer.start_span(name="span", parent=None) |
Contributor
There was a problem hiding this comment.
The parent is no longer a valid parameter here as of #1146, the parent is always passed in via the context
codeboten
suggested changes
Oct 14, 2020
| 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 |
Contributor
There was a problem hiding this comment.
Suggested change
| 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: |
Contributor
There was a problem hiding this comment.
Suggested change
| 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: |
Contributor
There was a problem hiding this comment.
Same comment as above here, you'll want to pass in the context, rather than the span
lzchen
approved these changes
Oct 14, 2020
eb3a27c to
997f88d
Compare
codeboten
approved these changes
Oct 22, 2020
Contributor
codeboten
left a comment
There was a problem hiding this comment.
Thanks for the update!
Contributor
|
The branch will need to be updated before merging. |
srikanthccv
pushed a commit
to srikanthccv/opentelemetry-python
that referenced
this pull request
Nov 1, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: