Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement stop method for probes #612

Merged
merged 1 commit into from
Feb 14, 2022
Merged

Conversation

unflxw
Copy link
Contributor

@unflxw unflxw commented Feb 11, 2022

Implement a .stop method on the BaseProbes class and on the Probes interface, along with a read-only .isRunning property.

The new BaseProbes object handles only the stopping logic. The actual behaviour of the probes is delegated to two private classes: BaseProbeRunner (which used to be BaseProbes) and NoopProbeRunner (which used to be NoopProbes). Both of these implement the ProbeRunner private interface. Stopping the probes permanently switches the implementation used.

NoopProbes no longer exists, but BaseProbes({ run: false }) can be used to initialise it in the stopped state, which is functionally equivalent.

Call metrics().probes().stop() from the BaseClient.stop() method, ensuring the probes system is stopped when AppSignal is stopped.

Fixes #418 and closes #569.

packages/nodejs/src/interfaces/probes.ts Outdated Show resolved Hide resolved
packages/nodejs/src/probes/index.ts Show resolved Hide resolved
packages/nodejs/src/probes/index.ts Outdated Show resolved Hide resolved
packages/nodejs/src/probes/index.ts Outdated Show resolved Hide resolved
packages/nodejs/src/probes/index.ts Outdated Show resolved Hide resolved
packages/nodejs/src/__tests__/client.test.ts Outdated Show resolved Hide resolved
@unflxw unflxw force-pushed the implement-probes-stop-method branch from 1a92d5f to 9b4f269 Compare February 11, 2022 15:36
@unflxw unflxw requested a review from tombruijn February 11, 2022 15:38
@unflxw unflxw force-pushed the implement-probes-stop-method branch 2 times, most recently from 6b47eb5 to 58a597e Compare February 11, 2022 16:40
unflxw added a commit that referenced this pull request Feb 11, 2022
These tests would assert the opposite behaviour of that which they
claimed to test. The test itself was broken, as it was spying on
a previously created client object, then creating a new client
object and performing actions on it, [as pointed out by @tombruijn
in #612][comment].

This commit fixes the existing tests so they perform the right
assertions, and adds a new one for the behaviour implied by the
tests.

[comment]: #612 (comment)
@unflxw unflxw mentioned this pull request Feb 11, 2022
Implement a `.stop` method on the `BaseProbes` class and on the
`Probes` interface, along with a read-only `.isRunning` property.

The new `BaseProbes` object handles only the stopping logic. The
actual behaviour of the probes is delegated to two private classes:
`BaseProbeRunner` (which used to be `BaseProbes`) and
`NoopProbeRunner` (which used to be `NoopProbes`). Both of these
implement the `ProbeRunner` private interface. Stopping the probes
permanently switches the implementation used.

`NoopProbes` no longer exists, but `BaseProbes({ run: false })`
can be used to initialise it in the stopped state, which is
functionally equivalent.

Call `metrics().probes().stop()` from the `BaseClient.stop()`
method, ensuring the probes system is stopped when AppSignal is
stopped.

Fixes #418 and closes #569.
@unflxw unflxw force-pushed the implement-probes-stop-method branch from 58a597e to afe221e Compare February 14, 2022 16:02
@unflxw unflxw merged commit ecb8bed into main Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Probes.stop behavior Appsignal is not stopping correctly
4 participants