@mark1russell7/otel-ts 0.3.1 → 0.5.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 +22 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/context-processors.d.ts +48 -0
- package/dist/context-processors.d.ts.map +1 -0
- package/dist/context-processors.js +92 -0
- package/dist/context-processors.js.map +1 -0
- package/dist/context-propagator.d.ts +39 -0
- package/dist/context-propagator.d.ts.map +1 -0
- package/dist/context-propagator.js +88 -0
- package/dist/context-propagator.js.map +1 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +13 -0
- package/dist/init.js.map +1 -1
- package/dist/logs.d.ts.map +1 -1
- package/dist/logs.js +2 -0
- package/dist/logs.js.map +1 -1
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +5 -2
- package/dist/metrics.js.map +1 -1
- package/dist/node-exporters.d.ts +40 -0
- package/dist/node-exporters.d.ts.map +1 -0
- package/dist/node-exporters.js +86 -0
- package/dist/node-exporters.js.map +1 -0
- package/dist/node.d.ts +28 -10
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +53 -12
- package/dist/node.js.map +1 -1
- package/dist/session-processors.d.ts.map +1 -1
- package/dist/session-processors.js +6 -19
- package/dist/session-processors.js.map +1 -1
- package/dist/tracing.d.ts.map +1 -1
- package/dist/tracing.js +7 -1
- package/dist/tracing.js.map +1 -1
- package/package.json +4 -1
- package/src/context-processors.ts +106 -0
- package/src/context-propagator.ts +96 -0
- package/src/init.ts +13 -0
- package/src/logs.ts +2 -0
- package/src/metrics.ts +5 -2
- package/src/node-exporters.ts +104 -0
- package/src/node.ts +77 -22
- package/src/session-processors.ts +6 -19
- package/src/tracing.ts +7 -1
package/README.md
CHANGED
|
@@ -231,6 +231,15 @@ The rules:
|
|
|
231
231
|
- `contextValues()` gives the value of each defined key. A baggage entry from outside with a key that is not defined is not in it.
|
|
232
232
|
- `withInternalCall(fn)` marks the calls that `fn` starts as internal calls. `isInternalCall()` reads the mark.
|
|
233
233
|
|
|
234
|
+
In the browser, `init()` registers the context when `tracing` is on (the default):
|
|
235
|
+
|
|
236
|
+
- The context manager of the entry, so a value of `withContext()` stays after `await` (refer to [Context manager](#context-manager)).
|
|
237
|
+
- The propagator of otel-ts. The fetch and XHR instrumentations add `traceparent` to each request that [`propagateTraceHeaderCorsUrls`](#trace-headers-to-other-origins) permits. They add `baggage` only to an internal call: start the calls to your own API in `withInternalCall()`.
|
|
238
|
+
- Processors that add the value of each context key to each span and each log record. An attribute that the caller sets stays.
|
|
239
|
+
- Metric views that remove each key with `cardinality: "high"` from each metric.
|
|
240
|
+
|
|
241
|
+
Only one part of a program registers the context. A second `init()` before the `shutdown()` of the first is an error. `shutdown()` removes the registration. With `tracing: false`, `init()` registers no context manager and no propagator.
|
|
242
|
+
|
|
234
243
|
## Writer identity
|
|
235
244
|
|
|
236
245
|
Prometheus and Mimir make the `instance` label from the `service.instance.id` resource attribute. Each SDK instance writes its own metric series. Two SDK instances with the same identity write to the same series. Then Mimir rejects samples, and `rate()` gives incorrect values.
|
|
@@ -394,9 +403,20 @@ node --import ./dist/instrumentation.js dist/server.js
|
|
|
394
403
|
|
|
395
404
|
The instrumentations patch a module when it loads, so this module must load before the modules of the service. In an ES module service, the CommonJS hook does not see a package that an ES module imports. When you give `importMetaUrl`, `startNodeTelemetry()` registers the loader hook of OpenTelemetry (`@opentelemetry/instrumentation/hook.mjs`) before the SDK starts. The hook then patches those imports too.
|
|
396
405
|
|
|
397
|
-
`startNodeTelemetry()`
|
|
406
|
+
`startNodeTelemetry()` exports nothing when `OTEL_EXPORTER_OTLP_ENDPOINT` has no value. Set `enabled` to change this. With export on or off, it registers the [context ids](#context-ids):
|
|
407
|
+
|
|
408
|
+
- AsyncLocalStorage as the context manager, so a value of `withContext()` stays after `await`.
|
|
409
|
+
- The propagator of otel-ts: `traceparent` and `tracestate` go on each call, and the context keys go in `baggage` only on an internal call (`withInternalCall()`).
|
|
410
|
+
- A metric view that removes each key with `cardinality: "high"` from each metric.
|
|
411
|
+
- With export on: a processor that adds the value of each context key to each span and each log record. An attribute that the caller sets stays.
|
|
412
|
+
|
|
413
|
+
Only one part of a program registers the context. A second `startNodeTelemetry()` before the `shutdown()` of the first is an error. `shutdown()` removes the registration.
|
|
414
|
+
|
|
415
|
+
With export on, the exporters come from `OTEL_TRACES_EXPORTER` and `OTEL_LOGS_EXPORTER`: `otlp` (the default), `console` or `none`. The OTLP protocol comes from `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` and `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL`, else `OTEL_EXPORTER_OTLP_PROTOCOL`: `http/protobuf` (the default) or `http/json`. Another name is an error. For grpc, give `traceExporter` and `logExporter`. The sampler and the metric readers are those of the SDK. The metric views take the histogram aggregation from `OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION`: `explicit_bucket_histogram` (the default) or `base2_exponential_bucket_histogram`. A view decides the aggregation, so this variable also sets the aggregation of a reader in `metricReaders`.
|
|
416
|
+
|
|
417
|
+
By default, it stops the SDK and sends the last spans at `SIGTERM` and `SIGINT`. Then, when the service has no listener of its own for the signal, the process ends with the signal, as it does without `startNodeTelemetry()`. When the service has a listener, that listener ends the process. Set `stopOnSignals: false` to add no listener.
|
|
398
418
|
|
|
399
|
-
The option `env` sets
|
|
419
|
+
The option `env` sets `enabled`, the service name, the exporter names and the protocols. An OTLP exporter and the sampler read their other settings (the endpoint, the headers, `OTEL_TRACES_SAMPLER`) from `process.env`. To send to another endpoint, give `traceExporter` and `logExporter`.
|
|
400
420
|
|
|
401
421
|
### The trace of a write, in its echo
|
|
402
422
|
|