Avoid writer reinitialization during shutdown #1248
Merged
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.
Fixes #1235
Changes introduced in release 0.38.0 (#1091) allowed the internal worker instance, held by the
Writer
, to be restarted on demand. This is normally ok, except during a shutdown.With the introduction of #1177, in release 0.41.0, the issue has change, as a brand new
Writer
is now created. That newWriter
is then fed a trace, which triggers the lazy initialization of it's internal worker thread.This PR prevents the re-creation of components during shutdown, the most relevant one being the
Writer
.Components are still responsive to method calls after
Datadog.shutdown!
(as to not surface host application errors), but they might not perform their work internally after their resources have been disposed of (e.g.Writer
will not flush any traces after its internal worker thread has been stopped).