Flush OpenTelemetry data when AppSignal stops - #278
Merged
Conversation
Stopping AppSignal stops the check-in scheduler and the agent, and leaves the OpenTelemetry providers alone. They register an exit handler that flushes them when the interpreter shuts down, which is too late in two cases. A process killed by a signal never runs exit handlers. And when the agent is used, it is the endpoint that OpenTelemetry data is sent to, so the exit handler posts to a port that closed when the agent was stopped. The providers are now shut down before the agent, which flushes what they hold. They are tracked as they are started, rather than read back from the global providers: no logger provider is set when the agent is used, an unset tracer provider is a proxy object with no shutdown method, and a provider the application set before ours is not ours to shut down.
|
Hi @unflxw, We've found some issues with your Pull Request.
|
unflxw
marked this pull request as ready for review
August 27, 2026 16:26
|
Hi @unflxw, We've found new issues for this Pull Request. Please see the main comment on this issue for a list of all current warnings. This comment will not be updated to reflect resolved warnings.
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stopping AppSignal stops the check-in scheduler and the agent, and
leaves the OpenTelemetry providers alone. They register an exit handler
that flushes them when the interpreter shuts down, which is too late in
two cases. A process killed by a signal never runs exit handlers. And
when the agent is used, it is the endpoint that OpenTelemetry data is
sent to, so the exit handler posts to a port that closed when the agent
was stopped.
The providers are now shut down before the agent, which flushes what
they hold. They are tracked as they are started, rather than read back
from the global providers: no logger provider is set when the agent is
used, an unset tracer provider is a proxy object with no shutdown
method, and a provider the application set before ours is not ours to
shut down.