@codefresh-io/cf-telemetry 2.3.0-alpha.6 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ Base utils for monitoring.
|
|
|
4
4
|
|
|
5
5
|
Includes:
|
|
6
6
|
|
|
7
|
-
* [Logs](./src/logs/README.md).
|
|
8
|
-
* [MongoDB](./src/metrics/mongodb/README.md) client monitoring.
|
|
9
|
-
* [OpenTelemetry](./src/otel/README.md) auto instrumentation.
|
|
7
|
+
* [Logs](./src/logs/README.md), fast and well-structured.
|
|
8
|
+
* [MongoDB](./src/metrics/mongodb/README.md) client monitoring helper.
|
|
9
|
+
* [OpenTelemetry](./src/otel/README.md) auto instrumentation, API and helpers.
|
|
10
10
|
* [Prometheus](./src/metrics/prometheus/README.md) server and custom metrics.
|
|
11
11
|
* [Pyroscope](./src/profiles/README.md) to profile CPU and memory.
|
|
12
12
|
|
|
@@ -23,6 +23,33 @@ import '@codefresh-io/cf-telemetry/init'
|
|
|
23
23
|
// ↓ Keep one blank line below to prevent automatic import reordering
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
### Lifecycle notices
|
|
27
|
+
|
|
28
|
+
> [!IMPORTANT]
|
|
29
|
+
> Please read this section carefully to understand how this library handles application lifecycle events and how it affects application lifecycle.
|
|
30
|
+
|
|
31
|
+
This library registers listeners for `SIGINT`, `SIGTERM` and `beforeExit` events to gracefully terminate instrumentation, which may include flushing logs, metrics, and profiles.
|
|
32
|
+
|
|
33
|
+
#### Effect on application lifecycle
|
|
34
|
+
|
|
35
|
+
As this library registers listeners for `SIGINT` and `SIGTERM` events, Node.js' default handlers for such signals will be removed: Node.js will no longer exit on non-Windows platforms on such signals. [More details in the doc](https://nodejs.org/api/process.html#signal-events).
|
|
36
|
+
|
|
37
|
+
**Please make sure you add your own exit handlers for these signals.**
|
|
38
|
+
|
|
39
|
+
#### Instrumentation shutdown
|
|
40
|
+
|
|
41
|
+
None of the events above happens if `proces.exit()` is called directly. This means that if you call `process.exit()` in your application, the library will not be able to gracefully terminate instrumentation. This may lead to loss of logs, metrics, and other telemetry data.
|
|
42
|
+
|
|
43
|
+
Please ensure calling `terminate()` method of this library before calling `process.exit()` to ensure graceful termination of instrumentation.
|
|
44
|
+
|
|
45
|
+
```TS
|
|
46
|
+
import { terminate } from '@codefresh-io/cf-telemetry/init'
|
|
47
|
+
|
|
48
|
+
// ...your application logic
|
|
49
|
+
await terminate(); // Ensure graceful termination of instrumentation
|
|
50
|
+
process.exit(0); // Now it's safe to exit the process
|
|
51
|
+
```
|
|
52
|
+
|
|
26
53
|
## Environment variables
|
|
27
54
|
|
|
28
55
|
| Variable | Required | Default value | Description |
|