@codefresh-io/cf-telemetry 2.3.0-alpha.6 → 3.0.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/dist/otel/config.d.ts +1 -0
- package/dist/otel/config.js +1 -0
- package/dist/otel/config.js.map +1 -1
- package/dist/otel/disable-http-instrumentation.d.ts +1 -0
- package/dist/otel/disable-http-instrumentation.js +17 -0
- package/dist/otel/disable-http-instrumentation.js.map +1 -0
- package/dist/otel/sdk.js +9 -0
- package/dist/otel/sdk.js.map +1 -1
- 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 |
|
package/dist/otel/config.d.ts
CHANGED
package/dist/otel/config.js
CHANGED
|
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.config = void 0;
|
|
4
4
|
exports.config = {
|
|
5
5
|
enabled: process.env['CF_TELEMETRY_OTEL_ENABLE'] === 'true',
|
|
6
|
+
allowHttpInstrumentation: process.env['CF_TELEMETRY_OTEL_ALLOW_HTTP_INSTRUMENTATION'] === 'true',
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=config.js.map
|
package/dist/otel/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/otel/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,KAAK,MAAM;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/otel/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,KAAK,MAAM;IAC3D,wBAAwB,EAAE,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,KAAK,MAAM;CACxF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const disableHttpInstrumentation: () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.disableHttpInstrumentation = void 0;
|
|
4
|
+
const disableHttpInstrumentation = () => {
|
|
5
|
+
const disabledOtelInstrumentations = new Set(process.env['OTEL_NODE_DISABLED_INSTRUMENTATIONS']
|
|
6
|
+
?.split(',')
|
|
7
|
+
.reduce((acc, instrumentation) => {
|
|
8
|
+
const trimmed = instrumentation.trim();
|
|
9
|
+
if (trimmed)
|
|
10
|
+
acc.push(trimmed);
|
|
11
|
+
return acc;
|
|
12
|
+
}, []));
|
|
13
|
+
disabledOtelInstrumentations.add('http');
|
|
14
|
+
process.env['OTEL_NODE_DISABLED_INSTRUMENTATIONS'] = [...disabledOtelInstrumentations].join(',');
|
|
15
|
+
};
|
|
16
|
+
exports.disableHttpInstrumentation = disableHttpInstrumentation;
|
|
17
|
+
//# sourceMappingURL=disable-http-instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable-http-instrumentation.js","sourceRoot":"","sources":["../../src/otel/disable-http-instrumentation.ts"],"names":[],"mappings":";;;AAAO,MAAM,0BAA0B,GAAG,GAAS,EAAE;IACnD,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAC1C,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;QAChD,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,MAAM,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE;QAC/B,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,OAAO;YAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAc,CAAC,CACrB,CAAC;IACF,4BAA4B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,GAAG,CAAC,GAAG,4BAA4B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnG,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC"}
|
package/dist/otel/sdk.js
CHANGED
|
@@ -9,6 +9,15 @@ const sdk_node_1 = require("@opentelemetry/sdk-node");
|
|
|
9
9
|
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
10
10
|
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
11
11
|
const global_config_1 = require("../global-config");
|
|
12
|
+
const config_1 = require("./config");
|
|
13
|
+
const disable_http_instrumentation_1 = require("./disable-http-instrumentation");
|
|
14
|
+
/**
|
|
15
|
+
* HTTP instrumentation is disabled by default because of potential security issues.
|
|
16
|
+
* In particular, it adds span attributes with request query parameters (`url.full` and `url.query`),
|
|
17
|
+
* which may contain sensitive information.
|
|
18
|
+
*/
|
|
19
|
+
if (config_1.config.allowHttpInstrumentation !== true)
|
|
20
|
+
(0, disable_http_instrumentation_1.disableHttpInstrumentation)();
|
|
12
21
|
exports.sdk = new sdk_node_1.NodeSDK({
|
|
13
22
|
serviceName: global_config_1.globalConfig.serviceName,
|
|
14
23
|
autoDetectResources: true,
|
package/dist/otel/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/otel/sdk.ts"],"names":[],"mappings":";;;AAAA,0FAAwF;AACxF,kFAAqG;AACrG,sFAA4E;AAC5E,wDAAkE;AAClE,sDAAkD;AAClD,kEAAmE;AACnE,8EAA8F;AAC9F,oDAAgD;
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/otel/sdk.ts"],"names":[],"mappings":";;;AAAA,0FAAwF;AACxF,kFAAqG;AACrG,sFAA4E;AAC5E,wDAAkE;AAClE,sDAAkD;AAClD,kEAAmE;AACnE,8EAA8F;AAC9F,oDAAgD;AAChD,qCAAkC;AAClC,iFAA4E;AAE5E;;;;GAIG;AACH,IAAI,eAAM,CAAC,wBAAwB,KAAK,IAAI;IAAE,IAAA,yDAA0B,GAAE,CAAC;AAE9D,QAAA,GAAG,GAAG,IAAI,kBAAO,CAAC;IAC7B,WAAW,EAAE,4BAAY,CAAC,WAAW;IACrC,mBAAmB,EAAE,IAAI;IACzB,QAAQ,EAAE,IAAA,kCAAsB,EAAC;QAC/B,CAAC,wCAAiB,CAAC,EAAE,4BAAY,CAAC,WAAW;QAC7C,CAAC,2CAAoB,CAAC,EAAE,4BAAY,CAAC,cAAc;KACpD,CAAC;IACF,cAAc,EAAE;QACd,IAAI,mCAAkB,CAAC,IAAI,4CAAiB,EAAE,CAAC;QAC/C,wDAAwD;QACxD,IAAI,6CAAoB,CAAC,+CAAsB,CAAC;KACjD;IACD,gBAAgB,EAAE,CAAC,IAAA,wDAA2B,EAAC;YAC7C,qCAAqC,EAAE;gBACrC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;oBAC/B,IAAI,WAAW,IAAI,QAAQ;wBAAE,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,CAAC;gBAC7F,CAAC;aACF;SACF,CAAC,CAAC;CACJ,CAAC,CAAC"}
|