@zigordev/otel 1.8.2 → 1.8.3
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 +2 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +11 -6
- package/dist/telemetry.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ The start reads the standard variables of OpenTelemetry:
|
|
|
79
79
|
|
|
80
80
|
Nothing differs between the laptop and production. A service sends to the agent in both, and only the agent knows where the data goes next.
|
|
81
81
|
|
|
82
|
-
Every span and every metric says who sent it. The start names the service, its version and one id for each running copy, the process
|
|
82
|
+
Every span and every metric says who sent it, and nothing more. The start names the service, its version and one id for each running copy, the process by its id and the Node.js version that runs it, and the operating system with its version. It sends nothing that names the machine or the person who runs it: no host name, no machine id, no user, no command and no path. On a laptop each of those can hold a person's name, as a computer's name or a home folder often does. `OTEL_NODE_RESOURCE_DETECTORS` is not read, so these facts are the same everywhere.
|
|
83
83
|
|
|
84
84
|
### The rules it keeps
|
|
85
85
|
|
|
@@ -87,6 +87,7 @@ Every span and every metric says who sent it. The start names the service, its v
|
|
|
87
87
|
- **Background work starts no trace.** A query or an outgoing request gets a span only inside another span, so a timer that polls does not fill the store. A background task that is worth a trace starts its own span.
|
|
88
88
|
- **Every trace is kept.** Nothing is sampled, so `OTEL_TRACES_SAMPLER` is not read.
|
|
89
89
|
- **Nothing identifies a visitor.** Before a span leaves the service, it loses the visitor's address, the user agent and the query string. A web address keeps only what comes before its `?`.
|
|
90
|
+
- **Nothing names the machine or its user.** The facts that go with every span and metric name no host, user, command or path.
|
|
90
91
|
- **Starting twice does nothing.** The second call returns the first one's handle.
|
|
91
92
|
- **A stop never fails over telemetry.** `shutdownTelemetry()` sends what the service still holds. When the agent cannot be reached, it waits until the send gives up, says so in a line at the level `warn`, and returns as usual.
|
|
92
93
|
- **Every line is a JSON line.** What a library prints with `console`, what OpenTelemetry says about itself and what Node.js warns of all become lines of the same shape as the service's own.
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface Telemetry {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function isProbeRequest(url: string | undefined): boolean;
|
|
13
13
|
export declare const probeAwareSampler: Sampler;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const runtimeDetector: ResourceDetector;
|
|
15
15
|
export declare function startTelemetry(options?: TelemetryOptions): Telemetry;
|
|
16
16
|
export declare function shutdownTelemetry(): Promise<void>;
|
|
17
17
|
export {};
|
package/dist/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,KAAK,gBAAgB,EAGtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAGL,KAAK,OAAO,EAGb,MAAM,0BAA0B,CAAC;AAMlC,KAAK,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,KAAK,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CAC9C;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAMD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAG/D;AAiBD,eAAO,MAAM,iBAAiB,EAAE,OAAsD,CAAC;AAEvF,eAAO,MAAM,eAAe,EAAE,gBAS7B,CAAC;AAoBF,wBAAgB,cAAc,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CA0CxE;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvD"}
|
package/dist/telemetry.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hostname } from 'node:os';
|
|
2
1
|
import { diag, SpanKind } from '@opentelemetry/api';
|
|
3
2
|
import { diagLogLevelFromString, setGlobalErrorHandler } from '@opentelemetry/core';
|
|
4
3
|
import { OTLPTraceExporter as JsonTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
@@ -7,7 +6,7 @@ import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
|
|
|
7
6
|
import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';
|
|
8
7
|
import { RuntimeNodeInstrumentation } from '@opentelemetry/instrumentation-runtime-node';
|
|
9
8
|
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
|
|
10
|
-
import { osDetector,
|
|
9
|
+
import { osDetector, serviceInstanceIdDetector, serviceNameEnvDetector, } from '@opentelemetry/resources';
|
|
11
10
|
import { startNodeSdk } from '@opentelemetry/sdk-node';
|
|
12
11
|
import { BatchSpanProcessor, ParentBasedSampler, SamplingDecision, } from '@opentelemetry/sdk-trace';
|
|
13
12
|
import { createDiagnostics } from './diagnostics.js';
|
|
@@ -33,15 +32,21 @@ const skipProbes = {
|
|
|
33
32
|
toString: () => 'SkipProbes',
|
|
34
33
|
};
|
|
35
34
|
export const probeAwareSampler = new ParentBasedSampler({ root: skipProbes });
|
|
36
|
-
export const
|
|
37
|
-
detect: () => ({
|
|
35
|
+
export const runtimeDetector = {
|
|
36
|
+
detect: () => ({
|
|
37
|
+
attributes: {
|
|
38
|
+
'process.pid': process.pid,
|
|
39
|
+
'process.runtime.name': 'nodejs',
|
|
40
|
+
'process.runtime.version': process.versions.node,
|
|
41
|
+
'process.runtime.description': 'Node.js',
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
38
44
|
};
|
|
39
45
|
const resourceDetectors = [
|
|
40
46
|
serviceInstanceIdDetector,
|
|
41
47
|
serviceNameEnvDetector,
|
|
42
|
-
|
|
48
|
+
runtimeDetector,
|
|
43
49
|
osDetector,
|
|
44
|
-
hostNameDetector,
|
|
45
50
|
];
|
|
46
51
|
function serviceVersion() {
|
|
47
52
|
const version = process.env.OTEL_SERVICE_VERSION;
|
package/dist/telemetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACjG,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EACL,UAAU,EAEV,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAElB,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,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C/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zigordev/otel",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "Telemetry for zigordev services: traces and metrics over OpenTelemetry, structured logs with the trace in them, and the answer of the health route",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@opentelemetry/context-async-hooks": "3.1.1",
|
|
43
43
|
"@opentelemetry/sdk-metrics": "3.1.1",
|
|
44
44
|
"@types/node": "26.6.6",
|
|
45
|
-
"@zigordev/dev": "1.8.
|
|
45
|
+
"@zigordev/dev": "1.8.3",
|
|
46
46
|
"pg": "8.23.1",
|
|
47
47
|
"typescript": "7.0.2",
|
|
48
48
|
"vitest": "5.1.1"
|