@bymax-one/nest-telemetry 1.0.3 → 1.0.4
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/CHANGELOG.md +42 -0
- package/README.md +15 -12
- package/dist/register/index.mjs +59 -8
- package/dist/sdk/index.cjs +59 -8
- package/dist/sdk/index.d.cts +11 -4
- package/dist/sdk/index.d.ts +11 -4
- package/dist/sdk/index.mjs +59 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,47 @@ The `release.yml` workflow extracts the section matching the pushed `vX.Y.Z` tag
|
|
|
8
8
|
as the GitHub Release body, so each released version needs a matching `## [X.Y.Z]`
|
|
9
9
|
heading here.
|
|
10
10
|
|
|
11
|
+
## [1.0.4] - 2026-11-14
|
|
12
|
+
|
|
13
|
+
### Security
|
|
14
|
+
|
|
15
|
+
- **`host.id` is no longer exported by default.** It is dropped from the resource, and `host.name` stays. `unsafe.exportHostId: true`
|
|
16
|
+
keeps it and emits a `SecurityWarning`.
|
|
17
|
+
- **`process.command` is dropped with the command-line attributes.** It is `argv[1]`, which for
|
|
18
|
+
`node -e code ARG` is the first argument. `unsafe.exportProcessCommandArgs: true` keeps it, with
|
|
19
|
+
`process.command_args` and `process.command_line`.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **A batch-processor timer value a timer cannot hold is ignored.** An `OTEL_BSP_SCHEDULE_DELAY` above
|
|
24
|
+
2147483647 ms reached `setTimeout`, which Node clamps to 1 ms, and the SDK exported once per span: 40
|
|
25
|
+
exports in 2 seconds in a measurement, against none at the default. An `OTEL_BSP_EXPORT_TIMEOUT` above it
|
|
26
|
+
became a 1 ms timeout on the processor side. Both are now ignored, the default applies, and
|
|
27
|
+
`BYMAX_TELEMETRY_BSP_VALUE_IGNORED` names the variable. The two sizes are not timers and are not limited.
|
|
28
|
+
- **`instrumentations.sendLogs: false` now keeps winston and bunyan records off the logs pipeline too.** It
|
|
29
|
+
set the log-sending key of pino only, so with `OTEL_LOGS_EXPORTER=otlp` the records of the other two were
|
|
30
|
+
forwarded whatever the option said. One option now sets the key of all three.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- `unsafe.exportHostId` on `UnsafeOptions`.
|
|
35
|
+
- `BYMAX_TELEMETRY_BSP_VALUE_IGNORED`: a timer variable was ignored for being longer than a timer holds.
|
|
36
|
+
|
|
37
|
+
### Apply to a derived backend
|
|
38
|
+
|
|
39
|
+
The declarations gained `unsafe.exportHostId`; a derived backend acts on these behaviours:
|
|
40
|
+
|
|
41
|
+
1. A dashboard, an alert or a join keyed on `host.id` stops matching. Key it on `host.name` or
|
|
42
|
+
`service.instance.id`, or set `unsafe.exportHostId: true` and accept that the machine identifier goes to
|
|
43
|
+
every collector and backend.
|
|
44
|
+
2. A query that reads `process.command` stops matching. `service.name` and `process.executable.path` identify
|
|
45
|
+
the process, or set `unsafe.exportProcessCommandArgs: true`.
|
|
46
|
+
3. An application that set `instrumentations.sendLogs: false` and uses winston or bunyan with
|
|
47
|
+
`OTEL_LOGS_EXPORTER=otlp` stops sending those records to the logs pipeline. Set `sendLogs: true`, or an
|
|
48
|
+
override for the one library, to keep them.
|
|
49
|
+
4. An `OTEL_BSP_SCHEDULE_DELAY` or `OTEL_BSP_EXPORT_TIMEOUT` above 2147483647 now falls back to the default
|
|
50
|
+
with a warning. Set a value up to 2147483647.
|
|
51
|
+
|
|
11
52
|
## [1.0.3] - 2026-11-14
|
|
12
53
|
|
|
13
54
|
### Added
|
|
@@ -166,6 +207,7 @@ First release.
|
|
|
166
207
|
- Verification from the packed tarball: real `node --import` processes in a CommonJS and a native-ESM
|
|
167
208
|
application, with planted secrets absent from the exported body and negative controls.
|
|
168
209
|
|
|
210
|
+
[1.0.4]: https://github.com/bymaxone/nest-telemetry/releases/tag/v1.0.4
|
|
169
211
|
[1.0.3]: https://github.com/bymaxone/nest-telemetry/releases/tag/v1.0.3
|
|
170
212
|
[1.0.2]: https://github.com/bymaxone/nest-telemetry/releases/tag/v1.0.2
|
|
171
213
|
[1.0.1]: https://github.com/bymaxone/nest-telemetry/releases/tag/v1.0.1
|
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ Install it with the OpenTelemetry peers you use: the command is in [Quick Start]
|
|
|
72
72
|
- ✅ **Span-end query redaction** — `url.query` is replaced and the query is cut from `url.full`, `http.url` and `http.target`, on spans from any instrumentation
|
|
73
73
|
- ✅ **Outgoing-URL credential list** — A list of credential-bearing parameters, checked in a test against the SDK's own default list; a host can add names and never drop them
|
|
74
74
|
- ✅ **Redis commands reduced to their name** — for `ioredis` and node-redis (`redis`), arguments and keys never leave the process, `EVAL` and `EVALSHA` payloads included
|
|
75
|
-
- ✅ **Command line kept out of the resource** — `process.command_args` and `process.
|
|
75
|
+
- ✅ **Command line kept out of the resource** — `process.command_args`, `process.command_line` and `process.command` are dropped
|
|
76
76
|
- ✅ **Explicit, loud opt-outs** — Each off switch is a literal `unsafe.*: true` and emits a `SecurityWarning`
|
|
77
77
|
|
|
78
78
|
---
|
|
@@ -172,12 +172,13 @@ Every field is the host's policy, and none is required.
|
|
|
172
172
|
| `serviceVersion` | none | The service version. |
|
|
173
173
|
| `ignoreIncomingRequest` | none | Returns `true` for an incoming request that must produce no server span. `ignorePaths(patterns)` builds one from anchored patterns. |
|
|
174
174
|
| `instrumentations.fs` | `false` | File-system instrumentation. |
|
|
175
|
-
| `instrumentations.sendLogs` | follows `OTEL_LOGS_EXPORTER` | Whether
|
|
175
|
+
| `instrumentations.sendLogs` | follows `OTEL_LOGS_EXPORTER` | Whether the records of pino, winston and bunyan are forwarded to the OpenTelemetry logs pipeline. |
|
|
176
176
|
| `instrumentations.overrides` | none | Per-instrumentation configuration, merged over the library's. Redaction settings cannot be replaced here. |
|
|
177
177
|
| `extraRedactedQueryParams` | none | Names added to the list redacted from outgoing request URLs. They add to the defaults and never replace them. |
|
|
178
178
|
| `unsafe.disableUrlRedaction` | off | Keeps `url.query`, `url.full`, `http.url` and `http.target` as recorded. Literal `true`. Warns. |
|
|
179
179
|
| `unsafe.disableRedisArgumentRedaction` | off | Keeps Redis command arguments in `db.query.text`. Literal `true`. Warns. |
|
|
180
|
-
| `unsafe.exportProcessCommandArgs` | off | Keeps `process.command_args` and `process.
|
|
180
|
+
| `unsafe.exportProcessCommandArgs` | off | Keeps `process.command_args`, `process.command_line` and `process.command` in the resource. Literal `true`. Warns. |
|
|
181
|
+
| `unsafe.exportHostId` | off | Keeps `host.id`, the machine identifier, in the resource. Literal `true`. Warns. |
|
|
181
182
|
| `shutdownTimeoutMs` | `5000` | The longest shutdown waits for the final flush. Past it, shutdown warns and resolves. A value that is not a finite number above zero, or is above `120000`, means the default. |
|
|
182
183
|
| `env` | the process environment | The environment the library reads. The OpenTelemetry SDK itself always reads the process environment. |
|
|
183
184
|
|
|
@@ -185,13 +186,13 @@ Every field is the host's policy, and none is required.
|
|
|
185
186
|
|
|
186
187
|
The library reads these in one source file, and a test fails if any other file names `process.env`:
|
|
187
188
|
|
|
188
|
-
| Variable | Effect
|
|
189
|
-
| ----------------------------------------------------------------------------------------------------------------- |
|
|
190
|
-
| `OTEL_SDK_DISABLED` | `true` disables the SDK, in any letter case and with surrounding whitespace ignored, as the SDK reads it.
|
|
191
|
-
| `OTEL_SERVICE_NAME` | Service name; overrides the option, because the operator's standard variable wins over what the code chose. Blank values count as absent.
|
|
192
|
-
| `OTEL_METRICS_EXPORTER`, `OTEL_LOGS_EXPORTER` | Metrics and logs are exported only when these name an exporter.
|
|
193
|
-
| `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | Mapped onto the batch span processor the library passes; the SDK applies them only to one it builds itself.
|
|
194
|
-
| `OTEL_NODE_RESOURCE_DETECTORS` | Selects resource detectors, under the specification's names (`service`, `host`, `process`) and the SDK's older ones.
|
|
189
|
+
| Variable | Effect |
|
|
190
|
+
| ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
191
|
+
| `OTEL_SDK_DISABLED` | `true` disables the SDK, in any letter case and with surrounding whitespace ignored, as the SDK reads it. |
|
|
192
|
+
| `OTEL_SERVICE_NAME` | Service name; overrides the option, because the operator's standard variable wins over what the code chose. Blank values count as absent. |
|
|
193
|
+
| `OTEL_METRICS_EXPORTER`, `OTEL_LOGS_EXPORTER` | Metrics and logs are exported only when these name an exporter. |
|
|
194
|
+
| `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | Mapped onto the batch span processor the library passes; the SDK applies them only to one it builds itself. A schedule delay or export timeout above 2147483647 ms is ignored with a warning, because a timer cannot hold it. |
|
|
195
|
+
| `OTEL_NODE_RESOURCE_DETECTORS` | Selects resource detectors, under the specification's names (`service`, `host`, `process`) and the SDK's older ones. |
|
|
195
196
|
|
|
196
197
|
The OpenTelemetry SDK reads these itself, and the library never touches them: `OTEL_EXPORTER_OTLP_*`, `OTEL_TRACES_SAMPLER` and `OTEL_TRACES_SAMPLER_ARG`, `OTEL_RESOURCE_ATTRIBUTES`.
|
|
197
198
|
|
|
@@ -215,6 +216,7 @@ The start emits these warnings:
|
|
|
215
216
|
| `BYMAX_TELEMETRY_RESTART_UNSUPPORTED` | `startTelemetry` was called after a shutdown in the same process, and is refused. |
|
|
216
217
|
| `BYMAX_TELEMETRY_SHUTDOWN_TIMEOUT` | The final flush did not finish within `shutdownTimeoutMs`. Shutdown resolved without it, and spans still queued may be lost. With `TelemetryModule` and a bound `TELEMETRY_LOGGER`, it is reported through `errorStructured` under `TRACING_SHUTDOWN_TIMEOUT` instead. |
|
|
217
218
|
| `BYMAX_TELEMETRY_EXPORT_FAILED` | A span export failed, so the batch was dropped. The warning names the exporter and a short error code, never the payload or the endpoint, and repeats at most once a minute. With `TelemetryModule` and a bound `TELEMETRY_LOGGER` that has `warnStructured`, it is reported through it under `TRACING_EXPORT_FAILED` instead. |
|
|
219
|
+
| `BYMAX_TELEMETRY_BSP_VALUE_IGNORED` | An `OTEL_BSP_SCHEDULE_DELAY` or `OTEL_BSP_EXPORT_TIMEOUT` above 2147483647 ms was ignored, because a timer cannot hold it and Node would clamp it to 1 ms. The default applies. |
|
|
218
220
|
|
|
219
221
|
The programmatic `startTelemetry` keeps its rejection when the SDK cannot start, for callers that want it.
|
|
220
222
|
|
|
@@ -313,7 +315,7 @@ The layers are in the [Security Table](#-security-table) below.
|
|
|
313
315
|
|
|
314
316
|
### Exported on purpose
|
|
315
317
|
|
|
316
|
-
The resource carries `host.name`, `os.*`, `process.pid`, `process.owner`, the executable path and runtime facts, and `service.instance.id`. They identify the instance during an incident. If you do not want them, set `OTEL_NODE_RESOURCE_DETECTORS`.
|
|
318
|
+
The resource carries `host.name`, `os.*`, `process.pid`, `process.owner`, the executable path and runtime facts, and `service.instance.id`. They identify the instance during an incident. If you do not want them, set `OTEL_NODE_RESOURCE_DETECTORS`. It does not carry `host.id`, the machine identifier: that is a stable hardware id, the platform UUID or `/etc/machine-id`, and it is dropped unless you set `unsafe.exportHostId`.
|
|
317
319
|
|
|
318
320
|
### How this is verified
|
|
319
321
|
|
|
@@ -330,7 +332,8 @@ What is **not** redacted is listed flat in [What This Library Does NOT Do](#-wha
|
|
|
330
332
|
| Query redaction | `url.query` is replaced by `[redacted]` and the query is cut from `url.full`, `http.url` and `http.target` as each span ends, for any instrumentation |
|
|
331
333
|
| Outgoing URLs | The HTTP instrumentation redacts a credential-parameter list (`token`, `code`, `access_token`, `signature`, `X-Amz-*`, and more); hosts add names, never drop them; a test compares the list with the SDK's own, so a name the SDK adds later is caught |
|
|
332
334
|
| Redis | `db.query.text` holds the command name only, for `ioredis` and node-redis; `EVAL` and `EVALSHA` payloads, which carry `KEYS` and `ARGV`, and every key never leave the process |
|
|
333
|
-
| Process command line | `process.command_args` and `process.
|
|
335
|
+
| Process command line | `process.command_args`, `process.command_line` and `process.command` are dropped from the resource, because command-line arguments are a common carrier of secrets |
|
|
336
|
+
| Host id | `host.id`, the machine identifier (the platform UUID, or `/etc/machine-id`), is dropped from the resource; `host.name` stays |
|
|
334
337
|
| Opt-outs | Literal `unsafe.*: true` options only, each emitting a `SecurityWarning`; no environment variable turns redaction off |
|
|
335
338
|
| Overrides | `instrumentations.overrides` is merged under the library's redaction, which is applied again on top |
|
|
336
339
|
| Environment | Read in one module; a test fails if any other file names `process.env` |
|
package/dist/register/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { register } from 'module';
|
|
|
3
3
|
// src/register/boot.ts
|
|
4
4
|
|
|
5
5
|
// src/sdk/environment.ts
|
|
6
|
+
var MAX_TIMER_MS = 2147483647;
|
|
6
7
|
function readExporterList(raw) {
|
|
7
8
|
return (raw ?? "").split(",").map((name) => name.trim()).filter((name) => name !== "");
|
|
8
9
|
}
|
|
@@ -10,13 +11,30 @@ function readPositiveNumber(raw) {
|
|
|
10
11
|
const value = Number(raw);
|
|
11
12
|
return Number.isFinite(value) && value > 0 ? value : void 0;
|
|
12
13
|
}
|
|
14
|
+
function readTimerMillis(name, raw, oversized) {
|
|
15
|
+
const value = readPositiveNumber(raw);
|
|
16
|
+
if (value !== void 0 && value > MAX_TIMER_MS) {
|
|
17
|
+
oversized.push(name);
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
13
22
|
function readTelemetryEnvironment(source = process.env) {
|
|
14
23
|
const tuning = {};
|
|
15
24
|
const maxQueueSize = readPositiveNumber(source["OTEL_BSP_MAX_QUEUE_SIZE"]);
|
|
16
25
|
if (maxQueueSize !== void 0) tuning.maxQueueSize = maxQueueSize;
|
|
17
|
-
const
|
|
26
|
+
const oversizedTimers = [];
|
|
27
|
+
const scheduledDelayMillis = readTimerMillis(
|
|
28
|
+
"OTEL_BSP_SCHEDULE_DELAY",
|
|
29
|
+
source["OTEL_BSP_SCHEDULE_DELAY"],
|
|
30
|
+
oversizedTimers
|
|
31
|
+
);
|
|
18
32
|
if (scheduledDelayMillis !== void 0) tuning.scheduledDelayMillis = scheduledDelayMillis;
|
|
19
|
-
const exportTimeoutMillis =
|
|
33
|
+
const exportTimeoutMillis = readTimerMillis(
|
|
34
|
+
"OTEL_BSP_EXPORT_TIMEOUT",
|
|
35
|
+
source["OTEL_BSP_EXPORT_TIMEOUT"],
|
|
36
|
+
oversizedTimers
|
|
37
|
+
);
|
|
20
38
|
if (exportTimeoutMillis !== void 0) tuning.exportTimeoutMillis = exportTimeoutMillis;
|
|
21
39
|
const maxExportBatchSize = readPositiveNumber(source["OTEL_BSP_MAX_EXPORT_BATCH_SIZE"]);
|
|
22
40
|
if (maxExportBatchSize !== void 0) tuning.maxExportBatchSize = maxExportBatchSize;
|
|
@@ -28,6 +46,7 @@ function readTelemetryEnvironment(source = process.env) {
|
|
|
28
46
|
metricsExporters: readExporterList(source["OTEL_METRICS_EXPORTER"]),
|
|
29
47
|
logsExporters: readExporterList(source["OTEL_LOGS_EXPORTER"]),
|
|
30
48
|
batchSpanProcessor: tuning,
|
|
49
|
+
oversizedTimers,
|
|
31
50
|
resourceDetectors: detectors === void 0 || detectors.trim() === "" ? void 0 : readExporterList(detectors)
|
|
32
51
|
};
|
|
33
52
|
}
|
|
@@ -93,6 +112,8 @@ var HTTP_INSTRUMENTATION = "@opentelemetry/instrumentation-http";
|
|
|
93
112
|
var IOREDIS_INSTRUMENTATION = "@opentelemetry/instrumentation-ioredis";
|
|
94
113
|
var REDIS_INSTRUMENTATION = "@opentelemetry/instrumentation-redis";
|
|
95
114
|
var PINO_INSTRUMENTATION = "@opentelemetry/instrumentation-pino";
|
|
115
|
+
var WINSTON_INSTRUMENTATION = "@opentelemetry/instrumentation-winston";
|
|
116
|
+
var BUNYAN_INSTRUMENTATION = "@opentelemetry/instrumentation-bunyan";
|
|
96
117
|
var LOG_EXPORTERS = /* @__PURE__ */ new Set(["otlp", "console"]);
|
|
97
118
|
var UNKNOWN_SERVICE_NAME = "unknown_service:node";
|
|
98
119
|
var WARNING_OPTIONS = {
|
|
@@ -128,10 +149,13 @@ function buildInstrumentationConfig(options, signals) {
|
|
|
128
149
|
if (config !== void 0) overrides[name] = { ...config };
|
|
129
150
|
}
|
|
130
151
|
const redactRedis = options.unsafe?.disableRedisArgumentRedaction !== true;
|
|
152
|
+
const disableLogSending = !(instrumentations.sendLogs ?? signals.sendLogs);
|
|
131
153
|
const library = {
|
|
132
154
|
[FS_INSTRUMENTATION]: { enabled: instrumentations.fs === true },
|
|
133
155
|
[HTTP_INSTRUMENTATION]: {},
|
|
134
|
-
[PINO_INSTRUMENTATION]: { disableLogSending
|
|
156
|
+
[PINO_INSTRUMENTATION]: { disableLogSending },
|
|
157
|
+
[WINSTON_INSTRUMENTATION]: { disableLogSending },
|
|
158
|
+
[BUNYAN_INSTRUMENTATION]: { disableLogSending }
|
|
135
159
|
};
|
|
136
160
|
const merged = {};
|
|
137
161
|
for (const name of /* @__PURE__ */ new Set([...Object.keys(library), ...Object.keys(overrides)])) {
|
|
@@ -172,7 +196,13 @@ function warnAboutUnsafeOptions(options) {
|
|
|
172
196
|
}
|
|
173
197
|
if (options.unsafe?.exportProcessCommandArgs === true) {
|
|
174
198
|
process.emitWarning(
|
|
175
|
-
"Process command-line redaction is disabled: process.command_args and process.
|
|
199
|
+
"Process command-line redaction is disabled: process.command_args, process.command_line and process.command are exported in the resource, and command-line arguments can carry secrets.",
|
|
200
|
+
WARNING_OPTIONS
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
if (options.unsafe?.exportHostId === true) {
|
|
204
|
+
process.emitWarning(
|
|
205
|
+
"Host id redaction is disabled: host.id, the machine identifier, is exported in the resource, and it identifies the machine to every collector and backend.",
|
|
176
206
|
WARNING_OPTIONS
|
|
177
207
|
);
|
|
178
208
|
}
|
|
@@ -183,6 +213,14 @@ function warnAboutUnsafeOptions(options) {
|
|
|
183
213
|
);
|
|
184
214
|
}
|
|
185
215
|
}
|
|
216
|
+
function warnAboutOversizedTimers(env) {
|
|
217
|
+
for (const name of env.oversizedTimers) {
|
|
218
|
+
process.emitWarning(
|
|
219
|
+
`${name} is above 2147483647 ms, which a timer cannot hold, so the default applies. Set a value up to 2147483647.`,
|
|
220
|
+
{ type: "Warning", code: "BYMAX_TELEMETRY_BSP_VALUE_IGNORED" }
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
186
224
|
function warnAboutIgnoredOptions(options) {
|
|
187
225
|
const stop = options.enabled === false;
|
|
188
226
|
if (stop || Object.values(options).some((v) => v !== void 0)) {
|
|
@@ -310,7 +348,12 @@ function createHandle(stopSdk, shutdownTimeoutMs) {
|
|
|
310
348
|
}
|
|
311
349
|
|
|
312
350
|
// src/sdk/resource-detectors.ts
|
|
313
|
-
var COMMAND_LINE_ATTRIBUTES = [
|
|
351
|
+
var COMMAND_LINE_ATTRIBUTES = [
|
|
352
|
+
"process.command_args",
|
|
353
|
+
"process.command_line",
|
|
354
|
+
"process.command"
|
|
355
|
+
];
|
|
356
|
+
var HOST_ID_ATTRIBUTES = ["host.id"];
|
|
314
357
|
var NAMED = /* @__PURE__ */ new Map([
|
|
315
358
|
["process", ["process"]],
|
|
316
359
|
["host", ["host", "os"]],
|
|
@@ -342,8 +385,12 @@ function withoutAttributes(detector, names) {
|
|
|
342
385
|
}
|
|
343
386
|
};
|
|
344
387
|
}
|
|
345
|
-
function selectResourceDetectors(selection, detectors,
|
|
346
|
-
const available =
|
|
388
|
+
function selectResourceDetectors(selection, detectors, keeps) {
|
|
389
|
+
const available = {
|
|
390
|
+
...detectors,
|
|
391
|
+
process: keeps.keepCommandLine ? detectors.process : withoutAttributes(detectors.process, COMMAND_LINE_ATTRIBUTES),
|
|
392
|
+
host: keeps.keepHostId ? detectors.host : withoutAttributes(detectors.host, HOST_ID_ATTRIBUTES)
|
|
393
|
+
};
|
|
347
394
|
if (selection?.includes("none") === true && !selection.includes("all")) {
|
|
348
395
|
return [];
|
|
349
396
|
}
|
|
@@ -418,7 +465,10 @@ function buildSdk(packages, options, env) {
|
|
|
418
465
|
process: resources.processDetector,
|
|
419
466
|
serviceinstance: resources.serviceInstanceIdDetector
|
|
420
467
|
},
|
|
421
|
-
|
|
468
|
+
{
|
|
469
|
+
keepCommandLine: options.unsafe?.exportProcessCommandArgs === true,
|
|
470
|
+
keepHostId: options.unsafe?.exportHostId === true
|
|
471
|
+
}
|
|
422
472
|
),
|
|
423
473
|
spanProcessors: [
|
|
424
474
|
// Ordered before the batch processor, so each span is redacted in place before it is exported.
|
|
@@ -436,6 +486,7 @@ function buildSdk(packages, options, env) {
|
|
|
436
486
|
async function boot(options, env) {
|
|
437
487
|
warnAboutUnsafeOptions(options);
|
|
438
488
|
warnAboutMissingServiceName(options, env);
|
|
489
|
+
warnAboutOversizedTimers(env);
|
|
439
490
|
const sdk = buildSdk(await loadPackages(), options, env);
|
|
440
491
|
sdk.start();
|
|
441
492
|
const handle = createHandle(() => sdk.shutdown(), options.shutdownTimeoutMs);
|
package/dist/sdk/index.cjs
CHANGED
|
@@ -166,6 +166,8 @@ var HTTP_INSTRUMENTATION = "@opentelemetry/instrumentation-http";
|
|
|
166
166
|
var IOREDIS_INSTRUMENTATION = "@opentelemetry/instrumentation-ioredis";
|
|
167
167
|
var REDIS_INSTRUMENTATION = "@opentelemetry/instrumentation-redis";
|
|
168
168
|
var PINO_INSTRUMENTATION = "@opentelemetry/instrumentation-pino";
|
|
169
|
+
var WINSTON_INSTRUMENTATION = "@opentelemetry/instrumentation-winston";
|
|
170
|
+
var BUNYAN_INSTRUMENTATION = "@opentelemetry/instrumentation-bunyan";
|
|
169
171
|
var LOG_EXPORTERS = /* @__PURE__ */ new Set(["otlp", "console"]);
|
|
170
172
|
var UNKNOWN_SERVICE_NAME = "unknown_service:node";
|
|
171
173
|
var WARNING_OPTIONS = {
|
|
@@ -201,10 +203,13 @@ function buildInstrumentationConfig(options, signals) {
|
|
|
201
203
|
if (config !== void 0) overrides[name] = { ...config };
|
|
202
204
|
}
|
|
203
205
|
const redactRedis = options.unsafe?.disableRedisArgumentRedaction !== true;
|
|
206
|
+
const disableLogSending = !(instrumentations.sendLogs ?? signals.sendLogs);
|
|
204
207
|
const library = {
|
|
205
208
|
[FS_INSTRUMENTATION]: { enabled: instrumentations.fs === true },
|
|
206
209
|
[HTTP_INSTRUMENTATION]: {},
|
|
207
|
-
[PINO_INSTRUMENTATION]: { disableLogSending
|
|
210
|
+
[PINO_INSTRUMENTATION]: { disableLogSending },
|
|
211
|
+
[WINSTON_INSTRUMENTATION]: { disableLogSending },
|
|
212
|
+
[BUNYAN_INSTRUMENTATION]: { disableLogSending }
|
|
208
213
|
};
|
|
209
214
|
const merged = {};
|
|
210
215
|
for (const name of /* @__PURE__ */ new Set([...Object.keys(library), ...Object.keys(overrides)])) {
|
|
@@ -245,7 +250,13 @@ function warnAboutUnsafeOptions(options) {
|
|
|
245
250
|
}
|
|
246
251
|
if (options.unsafe?.exportProcessCommandArgs === true) {
|
|
247
252
|
process.emitWarning(
|
|
248
|
-
"Process command-line redaction is disabled: process.command_args and process.
|
|
253
|
+
"Process command-line redaction is disabled: process.command_args, process.command_line and process.command are exported in the resource, and command-line arguments can carry secrets.",
|
|
254
|
+
WARNING_OPTIONS
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
if (options.unsafe?.exportHostId === true) {
|
|
258
|
+
process.emitWarning(
|
|
259
|
+
"Host id redaction is disabled: host.id, the machine identifier, is exported in the resource, and it identifies the machine to every collector and backend.",
|
|
249
260
|
WARNING_OPTIONS
|
|
250
261
|
);
|
|
251
262
|
}
|
|
@@ -256,6 +267,14 @@ function warnAboutUnsafeOptions(options) {
|
|
|
256
267
|
);
|
|
257
268
|
}
|
|
258
269
|
}
|
|
270
|
+
function warnAboutOversizedTimers(env) {
|
|
271
|
+
for (const name of env.oversizedTimers) {
|
|
272
|
+
process.emitWarning(
|
|
273
|
+
`${name} is above 2147483647 ms, which a timer cannot hold, so the default applies. Set a value up to 2147483647.`,
|
|
274
|
+
{ type: "Warning", code: "BYMAX_TELEMETRY_BSP_VALUE_IGNORED" }
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
259
278
|
function warnAboutIgnoredOptions(options) {
|
|
260
279
|
const stop = options.enabled === false;
|
|
261
280
|
if (stop || Object.values(options).some((v) => v !== void 0)) {
|
|
@@ -267,6 +286,7 @@ function warnAboutIgnoredOptions(options) {
|
|
|
267
286
|
}
|
|
268
287
|
|
|
269
288
|
// src/sdk/environment.ts
|
|
289
|
+
var MAX_TIMER_MS = 2147483647;
|
|
270
290
|
function readExporterList(raw) {
|
|
271
291
|
return (raw ?? "").split(",").map((name) => name.trim()).filter((name) => name !== "");
|
|
272
292
|
}
|
|
@@ -274,13 +294,30 @@ function readPositiveNumber(raw) {
|
|
|
274
294
|
const value = Number(raw);
|
|
275
295
|
return Number.isFinite(value) && value > 0 ? value : void 0;
|
|
276
296
|
}
|
|
297
|
+
function readTimerMillis(name, raw, oversized) {
|
|
298
|
+
const value = readPositiveNumber(raw);
|
|
299
|
+
if (value !== void 0 && value > MAX_TIMER_MS) {
|
|
300
|
+
oversized.push(name);
|
|
301
|
+
return void 0;
|
|
302
|
+
}
|
|
303
|
+
return value;
|
|
304
|
+
}
|
|
277
305
|
function readTelemetryEnvironment(source = process.env) {
|
|
278
306
|
const tuning = {};
|
|
279
307
|
const maxQueueSize = readPositiveNumber(source["OTEL_BSP_MAX_QUEUE_SIZE"]);
|
|
280
308
|
if (maxQueueSize !== void 0) tuning.maxQueueSize = maxQueueSize;
|
|
281
|
-
const
|
|
309
|
+
const oversizedTimers = [];
|
|
310
|
+
const scheduledDelayMillis = readTimerMillis(
|
|
311
|
+
"OTEL_BSP_SCHEDULE_DELAY",
|
|
312
|
+
source["OTEL_BSP_SCHEDULE_DELAY"],
|
|
313
|
+
oversizedTimers
|
|
314
|
+
);
|
|
282
315
|
if (scheduledDelayMillis !== void 0) tuning.scheduledDelayMillis = scheduledDelayMillis;
|
|
283
|
-
const exportTimeoutMillis =
|
|
316
|
+
const exportTimeoutMillis = readTimerMillis(
|
|
317
|
+
"OTEL_BSP_EXPORT_TIMEOUT",
|
|
318
|
+
source["OTEL_BSP_EXPORT_TIMEOUT"],
|
|
319
|
+
oversizedTimers
|
|
320
|
+
);
|
|
284
321
|
if (exportTimeoutMillis !== void 0) tuning.exportTimeoutMillis = exportTimeoutMillis;
|
|
285
322
|
const maxExportBatchSize = readPositiveNumber(source["OTEL_BSP_MAX_EXPORT_BATCH_SIZE"]);
|
|
286
323
|
if (maxExportBatchSize !== void 0) tuning.maxExportBatchSize = maxExportBatchSize;
|
|
@@ -292,6 +329,7 @@ function readTelemetryEnvironment(source = process.env) {
|
|
|
292
329
|
metricsExporters: readExporterList(source["OTEL_METRICS_EXPORTER"]),
|
|
293
330
|
logsExporters: readExporterList(source["OTEL_LOGS_EXPORTER"]),
|
|
294
331
|
batchSpanProcessor: tuning,
|
|
332
|
+
oversizedTimers,
|
|
295
333
|
resourceDetectors: detectors === void 0 || detectors.trim() === "" ? void 0 : readExporterList(detectors)
|
|
296
334
|
};
|
|
297
335
|
}
|
|
@@ -328,7 +366,12 @@ function warnOnExportFailure(exporter, kind, clock = () => performance.now()) {
|
|
|
328
366
|
}
|
|
329
367
|
|
|
330
368
|
// src/sdk/resource-detectors.ts
|
|
331
|
-
var COMMAND_LINE_ATTRIBUTES = [
|
|
369
|
+
var COMMAND_LINE_ATTRIBUTES = [
|
|
370
|
+
"process.command_args",
|
|
371
|
+
"process.command_line",
|
|
372
|
+
"process.command"
|
|
373
|
+
];
|
|
374
|
+
var HOST_ID_ATTRIBUTES = ["host.id"];
|
|
332
375
|
var NAMED = /* @__PURE__ */ new Map([
|
|
333
376
|
["process", ["process"]],
|
|
334
377
|
["host", ["host", "os"]],
|
|
@@ -360,8 +403,12 @@ function withoutAttributes(detector, names) {
|
|
|
360
403
|
}
|
|
361
404
|
};
|
|
362
405
|
}
|
|
363
|
-
function selectResourceDetectors(selection, detectors,
|
|
364
|
-
const available =
|
|
406
|
+
function selectResourceDetectors(selection, detectors, keeps) {
|
|
407
|
+
const available = {
|
|
408
|
+
...detectors,
|
|
409
|
+
process: keeps.keepCommandLine ? detectors.process : withoutAttributes(detectors.process, COMMAND_LINE_ATTRIBUTES),
|
|
410
|
+
host: keeps.keepHostId ? detectors.host : withoutAttributes(detectors.host, HOST_ID_ATTRIBUTES)
|
|
411
|
+
};
|
|
365
412
|
if (selection?.includes("none") === true && !selection.includes("all")) {
|
|
366
413
|
return [];
|
|
367
414
|
}
|
|
@@ -436,7 +483,10 @@ function buildSdk(packages, options, env) {
|
|
|
436
483
|
process: resources.processDetector,
|
|
437
484
|
serviceinstance: resources.serviceInstanceIdDetector
|
|
438
485
|
},
|
|
439
|
-
|
|
486
|
+
{
|
|
487
|
+
keepCommandLine: options.unsafe?.exportProcessCommandArgs === true,
|
|
488
|
+
keepHostId: options.unsafe?.exportHostId === true
|
|
489
|
+
}
|
|
440
490
|
),
|
|
441
491
|
spanProcessors: [
|
|
442
492
|
// Ordered before the batch processor, so each span is redacted in place before it is exported.
|
|
@@ -454,6 +504,7 @@ function buildSdk(packages, options, env) {
|
|
|
454
504
|
async function boot(options, env) {
|
|
455
505
|
warnAboutUnsafeOptions(options);
|
|
456
506
|
warnAboutMissingServiceName(options, env);
|
|
507
|
+
warnAboutOversizedTimers(env);
|
|
457
508
|
const sdk = buildSdk(await loadPackages(), options, env);
|
|
458
509
|
sdk.start();
|
|
459
510
|
const handle = createHandle(() => sdk.shutdown(), options.shutdownTimeoutMs);
|
package/dist/sdk/index.d.cts
CHANGED
|
@@ -41,18 +41,25 @@ interface UnsafeOptions {
|
|
|
41
41
|
/** Keeps Redis command arguments in `db.query.text`, including `EVAL` and `EVALSHA` payloads. */
|
|
42
42
|
readonly disableRedisArgumentRedaction?: true;
|
|
43
43
|
/**
|
|
44
|
-
* Keeps `process.command_args` and `process.
|
|
45
|
-
* removed by default, because command-line arguments are a common carrier of
|
|
44
|
+
* Keeps `process.command_args`, `process.command_line` and `process.command` in the exported
|
|
45
|
+
* resource. They are removed by default, because command-line arguments are a common carrier of
|
|
46
|
+
* secrets, and `process.command` is the first argument for `node -e code ARG`.
|
|
46
47
|
*/
|
|
47
48
|
readonly exportProcessCommandArgs?: true;
|
|
49
|
+
/**
|
|
50
|
+
* Keeps `host.id` in the exported resource. It is removed by default: it is the machine
|
|
51
|
+
* identifier (the platform UUID, or `/etc/machine-id`), a stable hardware id that every collector
|
|
52
|
+
* and backend would see. `host.name` stays.
|
|
53
|
+
*/
|
|
54
|
+
readonly exportHostId?: true;
|
|
48
55
|
}
|
|
49
56
|
/** Instrumentation choices that are the host's policy, with their safe defaults. */
|
|
50
57
|
interface InstrumentationOptions {
|
|
51
58
|
/** File-system instrumentation. Off by default: it floods traces with context-free disk activity. */
|
|
52
59
|
readonly fs?: boolean;
|
|
53
60
|
/**
|
|
54
|
-
* Whether
|
|
55
|
-
* `OTEL_LOGS_EXPORTER` names an exporter that exports logs.
|
|
61
|
+
* Whether the records of pino, winston and bunyan are forwarded to the OpenTelemetry logs
|
|
62
|
+
* pipeline. Defaults to whether `OTEL_LOGS_EXPORTER` names an exporter that exports logs.
|
|
56
63
|
*/
|
|
57
64
|
readonly sendLogs?: boolean;
|
|
58
65
|
/**
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -41,18 +41,25 @@ interface UnsafeOptions {
|
|
|
41
41
|
/** Keeps Redis command arguments in `db.query.text`, including `EVAL` and `EVALSHA` payloads. */
|
|
42
42
|
readonly disableRedisArgumentRedaction?: true;
|
|
43
43
|
/**
|
|
44
|
-
* Keeps `process.command_args` and `process.
|
|
45
|
-
* removed by default, because command-line arguments are a common carrier of
|
|
44
|
+
* Keeps `process.command_args`, `process.command_line` and `process.command` in the exported
|
|
45
|
+
* resource. They are removed by default, because command-line arguments are a common carrier of
|
|
46
|
+
* secrets, and `process.command` is the first argument for `node -e code ARG`.
|
|
46
47
|
*/
|
|
47
48
|
readonly exportProcessCommandArgs?: true;
|
|
49
|
+
/**
|
|
50
|
+
* Keeps `host.id` in the exported resource. It is removed by default: it is the machine
|
|
51
|
+
* identifier (the platform UUID, or `/etc/machine-id`), a stable hardware id that every collector
|
|
52
|
+
* and backend would see. `host.name` stays.
|
|
53
|
+
*/
|
|
54
|
+
readonly exportHostId?: true;
|
|
48
55
|
}
|
|
49
56
|
/** Instrumentation choices that are the host's policy, with their safe defaults. */
|
|
50
57
|
interface InstrumentationOptions {
|
|
51
58
|
/** File-system instrumentation. Off by default: it floods traces with context-free disk activity. */
|
|
52
59
|
readonly fs?: boolean;
|
|
53
60
|
/**
|
|
54
|
-
* Whether
|
|
55
|
-
* `OTEL_LOGS_EXPORTER` names an exporter that exports logs.
|
|
61
|
+
* Whether the records of pino, winston and bunyan are forwarded to the OpenTelemetry logs
|
|
62
|
+
* pipeline. Defaults to whether `OTEL_LOGS_EXPORTER` names an exporter that exports logs.
|
|
56
63
|
*/
|
|
57
64
|
readonly sendLogs?: boolean;
|
|
58
65
|
/**
|
package/dist/sdk/index.mjs
CHANGED
|
@@ -164,6 +164,8 @@ var HTTP_INSTRUMENTATION = "@opentelemetry/instrumentation-http";
|
|
|
164
164
|
var IOREDIS_INSTRUMENTATION = "@opentelemetry/instrumentation-ioredis";
|
|
165
165
|
var REDIS_INSTRUMENTATION = "@opentelemetry/instrumentation-redis";
|
|
166
166
|
var PINO_INSTRUMENTATION = "@opentelemetry/instrumentation-pino";
|
|
167
|
+
var WINSTON_INSTRUMENTATION = "@opentelemetry/instrumentation-winston";
|
|
168
|
+
var BUNYAN_INSTRUMENTATION = "@opentelemetry/instrumentation-bunyan";
|
|
167
169
|
var LOG_EXPORTERS = /* @__PURE__ */ new Set(["otlp", "console"]);
|
|
168
170
|
var UNKNOWN_SERVICE_NAME = "unknown_service:node";
|
|
169
171
|
var WARNING_OPTIONS = {
|
|
@@ -199,10 +201,13 @@ function buildInstrumentationConfig(options, signals) {
|
|
|
199
201
|
if (config !== void 0) overrides[name] = { ...config };
|
|
200
202
|
}
|
|
201
203
|
const redactRedis = options.unsafe?.disableRedisArgumentRedaction !== true;
|
|
204
|
+
const disableLogSending = !(instrumentations.sendLogs ?? signals.sendLogs);
|
|
202
205
|
const library = {
|
|
203
206
|
[FS_INSTRUMENTATION]: { enabled: instrumentations.fs === true },
|
|
204
207
|
[HTTP_INSTRUMENTATION]: {},
|
|
205
|
-
[PINO_INSTRUMENTATION]: { disableLogSending
|
|
208
|
+
[PINO_INSTRUMENTATION]: { disableLogSending },
|
|
209
|
+
[WINSTON_INSTRUMENTATION]: { disableLogSending },
|
|
210
|
+
[BUNYAN_INSTRUMENTATION]: { disableLogSending }
|
|
206
211
|
};
|
|
207
212
|
const merged = {};
|
|
208
213
|
for (const name of /* @__PURE__ */ new Set([...Object.keys(library), ...Object.keys(overrides)])) {
|
|
@@ -243,7 +248,13 @@ function warnAboutUnsafeOptions(options) {
|
|
|
243
248
|
}
|
|
244
249
|
if (options.unsafe?.exportProcessCommandArgs === true) {
|
|
245
250
|
process.emitWarning(
|
|
246
|
-
"Process command-line redaction is disabled: process.command_args and process.
|
|
251
|
+
"Process command-line redaction is disabled: process.command_args, process.command_line and process.command are exported in the resource, and command-line arguments can carry secrets.",
|
|
252
|
+
WARNING_OPTIONS
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
if (options.unsafe?.exportHostId === true) {
|
|
256
|
+
process.emitWarning(
|
|
257
|
+
"Host id redaction is disabled: host.id, the machine identifier, is exported in the resource, and it identifies the machine to every collector and backend.",
|
|
247
258
|
WARNING_OPTIONS
|
|
248
259
|
);
|
|
249
260
|
}
|
|
@@ -254,6 +265,14 @@ function warnAboutUnsafeOptions(options) {
|
|
|
254
265
|
);
|
|
255
266
|
}
|
|
256
267
|
}
|
|
268
|
+
function warnAboutOversizedTimers(env) {
|
|
269
|
+
for (const name of env.oversizedTimers) {
|
|
270
|
+
process.emitWarning(
|
|
271
|
+
`${name} is above 2147483647 ms, which a timer cannot hold, so the default applies. Set a value up to 2147483647.`,
|
|
272
|
+
{ type: "Warning", code: "BYMAX_TELEMETRY_BSP_VALUE_IGNORED" }
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
257
276
|
function warnAboutIgnoredOptions(options) {
|
|
258
277
|
const stop = options.enabled === false;
|
|
259
278
|
if (stop || Object.values(options).some((v) => v !== void 0)) {
|
|
@@ -265,6 +284,7 @@ function warnAboutIgnoredOptions(options) {
|
|
|
265
284
|
}
|
|
266
285
|
|
|
267
286
|
// src/sdk/environment.ts
|
|
287
|
+
var MAX_TIMER_MS = 2147483647;
|
|
268
288
|
function readExporterList(raw) {
|
|
269
289
|
return (raw ?? "").split(",").map((name) => name.trim()).filter((name) => name !== "");
|
|
270
290
|
}
|
|
@@ -272,13 +292,30 @@ function readPositiveNumber(raw) {
|
|
|
272
292
|
const value = Number(raw);
|
|
273
293
|
return Number.isFinite(value) && value > 0 ? value : void 0;
|
|
274
294
|
}
|
|
295
|
+
function readTimerMillis(name, raw, oversized) {
|
|
296
|
+
const value = readPositiveNumber(raw);
|
|
297
|
+
if (value !== void 0 && value > MAX_TIMER_MS) {
|
|
298
|
+
oversized.push(name);
|
|
299
|
+
return void 0;
|
|
300
|
+
}
|
|
301
|
+
return value;
|
|
302
|
+
}
|
|
275
303
|
function readTelemetryEnvironment(source = process.env) {
|
|
276
304
|
const tuning = {};
|
|
277
305
|
const maxQueueSize = readPositiveNumber(source["OTEL_BSP_MAX_QUEUE_SIZE"]);
|
|
278
306
|
if (maxQueueSize !== void 0) tuning.maxQueueSize = maxQueueSize;
|
|
279
|
-
const
|
|
307
|
+
const oversizedTimers = [];
|
|
308
|
+
const scheduledDelayMillis = readTimerMillis(
|
|
309
|
+
"OTEL_BSP_SCHEDULE_DELAY",
|
|
310
|
+
source["OTEL_BSP_SCHEDULE_DELAY"],
|
|
311
|
+
oversizedTimers
|
|
312
|
+
);
|
|
280
313
|
if (scheduledDelayMillis !== void 0) tuning.scheduledDelayMillis = scheduledDelayMillis;
|
|
281
|
-
const exportTimeoutMillis =
|
|
314
|
+
const exportTimeoutMillis = readTimerMillis(
|
|
315
|
+
"OTEL_BSP_EXPORT_TIMEOUT",
|
|
316
|
+
source["OTEL_BSP_EXPORT_TIMEOUT"],
|
|
317
|
+
oversizedTimers
|
|
318
|
+
);
|
|
282
319
|
if (exportTimeoutMillis !== void 0) tuning.exportTimeoutMillis = exportTimeoutMillis;
|
|
283
320
|
const maxExportBatchSize = readPositiveNumber(source["OTEL_BSP_MAX_EXPORT_BATCH_SIZE"]);
|
|
284
321
|
if (maxExportBatchSize !== void 0) tuning.maxExportBatchSize = maxExportBatchSize;
|
|
@@ -290,6 +327,7 @@ function readTelemetryEnvironment(source = process.env) {
|
|
|
290
327
|
metricsExporters: readExporterList(source["OTEL_METRICS_EXPORTER"]),
|
|
291
328
|
logsExporters: readExporterList(source["OTEL_LOGS_EXPORTER"]),
|
|
292
329
|
batchSpanProcessor: tuning,
|
|
330
|
+
oversizedTimers,
|
|
293
331
|
resourceDetectors: detectors === void 0 || detectors.trim() === "" ? void 0 : readExporterList(detectors)
|
|
294
332
|
};
|
|
295
333
|
}
|
|
@@ -326,7 +364,12 @@ function warnOnExportFailure(exporter, kind, clock = () => performance.now()) {
|
|
|
326
364
|
}
|
|
327
365
|
|
|
328
366
|
// src/sdk/resource-detectors.ts
|
|
329
|
-
var COMMAND_LINE_ATTRIBUTES = [
|
|
367
|
+
var COMMAND_LINE_ATTRIBUTES = [
|
|
368
|
+
"process.command_args",
|
|
369
|
+
"process.command_line",
|
|
370
|
+
"process.command"
|
|
371
|
+
];
|
|
372
|
+
var HOST_ID_ATTRIBUTES = ["host.id"];
|
|
330
373
|
var NAMED = /* @__PURE__ */ new Map([
|
|
331
374
|
["process", ["process"]],
|
|
332
375
|
["host", ["host", "os"]],
|
|
@@ -358,8 +401,12 @@ function withoutAttributes(detector, names) {
|
|
|
358
401
|
}
|
|
359
402
|
};
|
|
360
403
|
}
|
|
361
|
-
function selectResourceDetectors(selection, detectors,
|
|
362
|
-
const available =
|
|
404
|
+
function selectResourceDetectors(selection, detectors, keeps) {
|
|
405
|
+
const available = {
|
|
406
|
+
...detectors,
|
|
407
|
+
process: keeps.keepCommandLine ? detectors.process : withoutAttributes(detectors.process, COMMAND_LINE_ATTRIBUTES),
|
|
408
|
+
host: keeps.keepHostId ? detectors.host : withoutAttributes(detectors.host, HOST_ID_ATTRIBUTES)
|
|
409
|
+
};
|
|
363
410
|
if (selection?.includes("none") === true && !selection.includes("all")) {
|
|
364
411
|
return [];
|
|
365
412
|
}
|
|
@@ -434,7 +481,10 @@ function buildSdk(packages, options, env) {
|
|
|
434
481
|
process: resources.processDetector,
|
|
435
482
|
serviceinstance: resources.serviceInstanceIdDetector
|
|
436
483
|
},
|
|
437
|
-
|
|
484
|
+
{
|
|
485
|
+
keepCommandLine: options.unsafe?.exportProcessCommandArgs === true,
|
|
486
|
+
keepHostId: options.unsafe?.exportHostId === true
|
|
487
|
+
}
|
|
438
488
|
),
|
|
439
489
|
spanProcessors: [
|
|
440
490
|
// Ordered before the batch processor, so each span is redacted in place before it is exported.
|
|
@@ -452,6 +502,7 @@ function buildSdk(packages, options, env) {
|
|
|
452
502
|
async function boot(options, env) {
|
|
453
503
|
warnAboutUnsafeOptions(options);
|
|
454
504
|
warnAboutMissingServiceName(options, env);
|
|
505
|
+
warnAboutOversizedTimers(env);
|
|
455
506
|
const sdk = buildSdk(await loadPackages(), options, env);
|
|
456
507
|
sdk.start();
|
|
457
508
|
const handle = createHandle(() => sdk.shutdown(), options.shutdownTimeoutMs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-telemetry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "OpenTelemetry tracing for NestJS 11 and plain Node: starts the SDK before your app loads, redacts secrets from spans by default, and flushes on shutdown. Optional peers, zero cost when disabled.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|