This repository was archived by the owner on Sep 17, 2025. It is now read-only.
Remove span_stack and store parent_span in span object#52
Merged
liyanhui1228 merged 7 commits intocensus-instrumentation:masterfrom Oct 31, 2017
Merged
Remove span_stack and store parent_span in span object#52liyanhui1228 merged 7 commits intocensus-instrumentation:masterfrom
liyanhui1228 merged 7 commits intocensus-instrumentation:masterfrom
Conversation
duggelz
reviewed
Oct 31, 2017
| parent_span_id = self.span_context.span_id | ||
| parent_span = self.current_span() | ||
|
|
||
| if parent_span is None: |
There was a problem hiding this comment.
Can you add a comment describing the django case you explained to me?
| return | ||
|
|
||
| cur_span.finish() | ||
| self.span_context.span_id = cur_span.parent_span.span_id |
There was a problem hiding this comment.
Is it valid to manually create a span like Span(parent_span=None,...)? In that case, we would need to check for None here, and set span_id to 0 or something. It seems like we have 3 cases:
- parent_span is a Span object
- parent_span is a NullContextManager because we got the span_id from an HTTP header
- parent_span is None because we manually created a root span.
Contributor
Author
There was a problem hiding this comment.
Yes we have these 3 cases, I added check for parent_span in span constructor and documented that user should start and end span using RequestTracer instead of directly using the span class.
duggelz
approved these changes
Oct 31, 2017
| labels = {} | ||
|
|
||
| # Do not manipulate spans directly using the methods in Span Class, | ||
| # make usre to use the RequestTracer. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add get/set_current_span methods in execution_context, use the current span as the parent span when creating new spans. Remove span_stack, and instead use the parent_span object in span to record the relationship between spans.
Closes #51