-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
gcp/observability: fix End() to cleanup global state correctly #5623
Conversation
gcp/observability/observability.go
Outdated
@@ -80,4 +85,18 @@ func Start(ctx context.Context) error { | |||
// Note: this method should only be invoked once. | |||
func End() { | |||
defaultLogger.Close() | |||
if exporter != nil { |
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.
Let's create a stopOpenCensus
function that does the cleanup needed due to startOpenCensus
, and put it right next to it so we can be sure everything pairs up between start/end.
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.
Done. Thanks.
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.
Thanks for the review :D!
gcp/observability/opencensus.go
Outdated
trace.UnregisterExporter(exporter) | ||
view.UnregisterExporter(exporter) | ||
|
||
if sdExporter, ok := exporter.(*stackdriver.Exporter); ok { |
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.
Why not define Flush
and Close
methods on tracingMetricsExporter
instead? Does it make the tests unnecessarily complex?
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.
Done.
Previously, our metrics and tracing calls would not have the buffer flushed in observability.End(), and also keep the exporters registered globally in another package. Thus, tracing and metrics data would possibly not get uploaded to a backend properly. Also, our tests would break when run more than once due to the trailing exporter.
Fixes #5423, #5558, #5559
RELEASE NOTES: