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 appsignal/integration-guide#169.
Implement check-in scheduler
Implement a check-in event scheduler, which schedules check-in events
to be transmitted in a separate thread, with a minimum wait period
of ten seconds between requests, and a wait period of a tenth of a
second before the first request, referred to as "debounce" periods.
This is a relatively minor improvement for the existing cron
check-ins, but it is a requirement for the heartbeat check-ins, both
to avoid slowing down customers' applications with blocking requests,
and to avoid misuse of the feature from spamming our servers.
The scheduler also acts as a deduplicator, removing "similar enough"
check-in events -- again, not particularly interesting for cron
check-ins, but a requirement to minimise damage when heartbeat
check-ins are misused.
Implement utility functions for serialising and deserialising NDJSON
payloads.
When an event is scheduled, the scheduler sets a timeout for the
duration of the timeout period, after which the events stored in
the scheduler are transmitted.
When
Appsignal.stop
is called and awaited, the scheduler isgracefully stopped, awaiting the transmission of all scheduled
check-in events. During this time, new check-in events cannot be
scheduled.
Avoid probes interval blocking shutdown
The probes instance starts an interval timer on initialisation.
By default, timers cause the Node.js engine to await their
completion on shutdown -- which, this being an interval timer, is
never actually completed. (See #418)
We fixed this in the past by implementing
Appsignal.stop
, whichclears the interval. But a preferable solution is to mark the
probes' interval as
.unref()
, telling the Node.js engine that itdoes not need to be awaited.