cf-telemetry
Base utils for monitoring.
Includes:
Usage
Add import '@codefresh-io/cf-telemetry/init' statement at the very beginning of the application lifecycle.
Please refer to the separate docs above for further configuration and usage details.
import '@codefresh-io/cf-telemetry/init'
Lifecycle notices
[!IMPORTANT]
Please read this section carefully to understand how this library handles application lifecycle events and how it affects application lifecycle.
This library registers listeners for SIGINT, SIGTERM and beforeExit events to gracefully terminate instrumentation, which may include flushing logs, metrics, and profiles.
Effect on application lifecycle
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.
Please make sure you add your own exit handlers for these signals.
Instrumentation shutdown
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.
Please ensure calling terminate() method of this library before calling process.exit() to ensure graceful termination of instrumentation.
import { terminate } from '@codefresh-io/cf-telemetry/init'
await terminate();
process.exit(0);
Environment variables
CF_SERVICE_NAME | optional | unknown_service:node | Sets service name for OpenTelemetry, Pyroscope and Prometheus. |
CF_SERVICE_VERSION | optional | unknown | Sets service name for OpenTelemetry, Pyroscope and Prometheus. |