Implement heartbeat check-ins #962
Merged
+435
−83
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.
Part of https://github.com/appsignal/integration-guide/issues/169.
Add an
Appsignal.CheckIn.heartbeathelper that emits a single heartbeat for the check-in identifier given.When called with
continuous: trueas the second argument, it starts and links a separate Elixir process that emits a heartbeat every thirty seconds.Unlike the equivalent functionality in the Ruby integration, which spawns a thread that will stay alive for the lifetime of the Ruby process, the Elixir process is linked to the process that spawned it, meaning it will be shut down when its parent process is shut down. This allows it to be used to track the lifetime of individual Elixir processes.
Additionally, it is also possible to add
Appsignal.CheckIn.Heartbeatas a child process to a supervisor, meaning its lifetime will be tied to that of the other processes supervised by it.Finally, the functionality seen in the Ruby integration could also be achieved by manually calling
Appsignal.CheckIn.Heartbeat.start/1, keeping the process unlinked and therefore alive for the entirety of the Elixir node's lifetime, though this is unlikely to be the preferred usage under the Elixir process model.