-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
tracing: add SpanFinalizer and test and use NullSpan #1029
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8e59030
tracing: adopt NullSpan and add finalizer
goaway 3e83c33
checkpoint: compiles
goaway 4ea0ef7
checkpoint: tests pass
goaway 53ec11b
minor fix
goaway 1ffcde9
updates for comments
goaway 0956877
improve test
goaway 8fc3d01
delete stray comment
goaway a67ef7c
update tests
goaway 469f3c3
asan and tsan failurse
goaway a70d244
remove comment.
RomanDzhabarov 5d7d560
Merge branch 'master' into nullspan
RomanDzhabarov 27b0875
fix
mattklein123 5b91a78
pass header map *
RomanDzhabarov 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 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 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -166,10 +166,16 @@ TEST_F(LightStepDriverTest, FlushSeveralSpans) { | |
.WillOnce(Return(5000U)); | ||
|
||
SpanPtr first_span = driver_->startSpan(request_headers_, operation_name_, start_time_); | ||
first_span->finishSpan(); | ||
// MockFinalizer finalizer; | ||
NullFinalizer finalizer; | ||
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. why not MockFinalizer, we could check later on that finalize is called on this mock |
||
|
||
// EXPECT_CALL(finalizer, finalize(*first_span)); | ||
first_span->finishSpan(finalizer); | ||
|
||
SpanPtr second_span = driver_->startSpan(request_headers_, operation_name_, start_time_); | ||
second_span->finishSpan(); | ||
|
||
// EXPECT_CALL(finalizer, finalize(*second_span)); | ||
second_span->finishSpan(finalizer); | ||
|
||
Http::MessagePtr msg(new Http::ResponseMessageImpl( | ||
Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{":status", "200"}}})); | ||
|
@@ -203,7 +209,8 @@ TEST_F(LightStepDriverTest, FlushSpansTimer) { | |
.WillOnce(Return(5)); | ||
|
||
SpanPtr span = driver_->startSpan(request_headers_, operation_name_, start_time_); | ||
span->finishSpan(); | ||
NullFinalizer finalizer; | ||
span->finishSpan(finalizer); | ||
|
||
// Timer should be re-enabled. | ||
EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(1000))); | ||
|
@@ -244,7 +251,8 @@ TEST_F(LightStepDriverTest, FlushOneSpanGrpcFailure) { | |
.WillOnce(Return(5000U)); | ||
|
||
SpanPtr span = driver_->startSpan(request_headers_, operation_name_, start_time_); | ||
span->finishSpan(); | ||
NullFinalizer finalizer; | ||
span->finishSpan(finalizer); | ||
|
||
Http::MessagePtr msg(new Http::ResponseMessageImpl( | ||
Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{":status", "200"}}})); | ||
|
Oops, something went wrong.
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.
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.
Is it worth constructing the finalizer here in the common case (e.g. when not tracing) that
active_span_
isNullSpan
?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.
Possibly not, especially given it's not all that cheap to construct. I can't think of a super clean way to check that here though. I mean we could have an isNull check on the Span itself, though that doesn't seem all that great. Any suggestions?
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 we all agree that this is not necessary, but it involves 3 ref copies during the creation ultimately we could fix with isNull check if this appears in the perf traces.
Open to suggestions as well
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.
If this is the only place we do this we could consider just keeping track of the tracing decision from where
active_span_
was set, but then you're essentially going back to treating this as nullptr. In general though it seems that there is the pattern of "some setup work; do something on a span that might be null;", so it would be useful to have a cheap way to know if actively tracing.iSNull
seems reasonable in the absence of some other object with trace context info.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 @RomanDzhabarov has a fair point - all the really expensive stuff is in the actual finalize() call, which gets skipped entirely in the case of a NullSpan (I for some reason was thinking for a moment that more of it was in the constructor, but now recall I deliberately pushed it all into the finalize call for that reason).
I'm leaning slightly towards sticking with the unnecessary instantiation for now, since it keeps things a little tidier. No very strong feelings about it though.
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.
OK, it's fine for now, we can solve this issue further down the track if/when the unnecessary work ends up being larger.