-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
exporter(stackdriver): fix ExportSpans when ctx is not nil #294
exporter(stackdriver): fix ExportSpans when ctx is not nil #294
Conversation
clsung
commented
Nov 6, 2019
- problem: if ctx is not, calling cancel() will panic
- nil Context already handled in newContextWithTimeout
- add with test
exporter/trace/stackdriver/trace.go
Outdated
if ctx == nil { | ||
ctx, cancel = newContextWithTimeout(e.o.Context, e.o.Timeout) | ||
} | ||
ctx, cancel = newContextWithTimeout(ctx, e.o.Timeout) |
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.
There are ctx == nil
checks all over this code, could you clarify the intention? Testing for a nil context anywhere has a funny smell. I would like to see all the nil context checks removed.
Also, should you add a test for the case where context reaches the timeout and is canceled?
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 as long as ctx is not nil, the cancel() will always be nil. However for batch processing we need a timeout function hence we need a ctx with timeout. I'll check it with timeout tests.
3f2611e
to
475ceab
Compare
Paging @ymotongpoo for review (p.s. we should add him to CODEOWNERS for this directory) |
- problem: if ctx is not, calling cancel() will panic - nil Context already handled in newContextWithTimeout - add with test
- rename blackbox tests package to stackdriver_test - remove context is nil checking, add to initialization - add tests for timeout
475ceab
to
afe0588
Compare