-
Notifications
You must be signed in to change notification settings - Fork 714
Parent is now always passed in via Context, intead of Span or SpanContext #1146
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4e87e13
parent is now always passed in via Context, intead of Span or SpanCon…
5180478
Merge branch 'master' into parent-context
9e707e3
fix tests
3493bce
fix one more test
34b6cc1
fix test
3e2ffab
Merge branch 'master' into parent-context
eceae0f
fix lint
865891c
fix more tests
1acb6db
fix import path
01502ca
fix instrumentation tests
42c574f
fix shim
f82bd23
updating docs/changelog
76107e5
Merge branch 'master' into parent-context
b388cd8
rename parent parameter to context
3114a13
fix celery instrumentation
a2dfae9
fix lint
594f9f8
Apply suggestions from code review
aa1e329
Merge branch 'master' into parent-context
a451c4f
rename get_context to get_span_context
c6f5289
rename parent_context to parent_span_context where appropriate
2585e3f
fix test
6a910fa
fix lint
3b49754
Merge branch 'master' into parent-context
bf512da
fix lint
77fba4a
Merge branch 'master' into parent-context
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,7 +346,7 @@ class Span(trace_api.Span): | |
name: The name of the operation this span represents | ||
context: The immutable span context | ||
parent: This span's parent's `opentelemetry.trace.SpanContext`, or | ||
codeboten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
null if this is a root span | ||
None if this is a root span | ||
sampler: The sampler used to create this span | ||
trace_config: TODO | ||
resource: Entity producing telemetry | ||
|
@@ -683,38 +683,34 @@ def __init__( | |
def start_as_current_span( | ||
self, | ||
name: str, | ||
parent: trace_api.ParentSpan = trace_api.Tracer.CURRENT_SPAN, | ||
context: Optional[context_api.Context] = None, | ||
kind: trace_api.SpanKind = trace_api.SpanKind.INTERNAL, | ||
attributes: types.Attributes = None, | ||
links: Sequence[trace_api.Link] = (), | ||
) -> Iterator[trace_api.Span]: | ||
span = self.start_span(name, parent, kind, attributes, links) | ||
span = self.start_span(name, context, kind, attributes, links) | ||
return self.use_span(span, end_on_exit=True) | ||
|
||
def start_span( # pylint: disable=too-many-locals | ||
self, | ||
name: str, | ||
parent: trace_api.ParentSpan = trace_api.Tracer.CURRENT_SPAN, | ||
context: Optional[context_api.Context] = None, | ||
kind: trace_api.SpanKind = trace_api.SpanKind.INTERNAL, | ||
attributes: types.Attributes = None, | ||
links: Sequence[trace_api.Link] = (), | ||
start_time: Optional[int] = None, | ||
set_status_on_exception: bool = True, | ||
) -> trace_api.Span: | ||
if parent is Tracer.CURRENT_SPAN: | ||
parent = trace_api.get_current_span() | ||
|
||
parent_context = parent | ||
if isinstance(parent_context, trace_api.Span): | ||
parent_context = parent.get_context() | ||
parent_context = trace_api.get_current_span(context).get_context() | ||
|
||
if parent_context is not None and not isinstance( | ||
parent_context, trace_api.SpanContext | ||
): | ||
raise TypeError("parent must be a Span, SpanContext or None.") | ||
raise TypeError("parent_context must be a SpanContext or None.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this type validation is still valuable. But practically speaking, this would only be an issue if someone directly manipulates the context, and doesn't use the API functions. Is that a common enough case to even catch here? Alternatively I suppose this is cheap enough. |
||
|
||
if parent_context is None or not parent_context.is_valid: | ||
parent = parent_context = None | ||
parent_context = None | ||
trace_id = self.source.ids_generator.generate_trace_id() | ||
trace_flags = None | ||
trace_state = None | ||
|
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
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.
Uh oh!
There was an error while loading. Please reload this page.