相对远程测量
用于监测的基特利斯.
包括:
使用量
添加 import '@codefresh-io/cf-telemetry/init' 语句,在应用程序生命周期之初.
关于进一步的配置和使用细节,请参见上文单独的文件.
// index.ts
// ↓ Should be imported first
import '@codefresh-io/cf-telemetry/init'
// ↓ Keep one blank line below to prevent automatic import reordering
生命周期通知
此库只登记终止收听器 beforeExit 事件以优雅地终止仪器,其中可能包括冲出日志、度量衡和配置.
[大 请确保呼叫
terminate()此库调用前的方法process.exit(),或者将它纳入处理的应用程序逻辑中SIGINT编号 :SIGTERM信号,以确保优雅地终止仪器.
import { terminate } from '@codefresh-io/cf-telemetry/init'
// ...your application logic
await terminate(); // Ensure graceful termination of instrumentation
process.exit(0); // Now it's safe to exit the process
import { terminate } from '@codefresh-io/cf-telemetry/init'
process.on('SIGINT', async () => {
await terminate(); // Ensure graceful termination of instrumentation
process.exit(130); // Now it's safe to exit the process
});
process.on('SIGTERM', async () => {
await terminate(); // Ensure graceful termination of instrumentation
process.exit(143); // Now it's safe to exit the process
});
环境变量
| 变量 | 需求 | 默认值 | 说明 |
|---|---|---|---|
CF_SERVICE_NAME | 选项 | unknown_service:node | 设置 OpenTeleometry, Pyroscope 和 Prometheus 的服务名称. |
CF_SERVICE_VERSION | 选项 | unknown | 设定OpenTeleometry,平面镜和普罗米修斯的服务版本. |