@mark1russell7/otel-ts 0.1.3 → 0.2.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 +16 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +4 -1
- package/dist/init.js.map +1 -1
- package/dist/node.d.ts +11 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +21 -11
- package/dist/node.js.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/init.ts +4 -1
- package/src/node.ts +32 -11
- package/src/types.ts +5 -1
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ meter.createHistogram("checkout.duration", { unit: "ms" }).record(120);
|
|
|
54
54
|
| `browserAttributes` | `boolean` | `true` | Puts `browser.brands`, `browser.platform`, `browser.mobile`, `browser.language` and `user_agent.original` (semantic conventions) on the resource, from `navigator`. The attributes of `resourceAttributes` replace them when the key is the same. |
|
|
55
55
|
| `resourceAttributes` | `Record<string, string>` | `{}` | More resource attributes. They replace the attributes above when the key is the same. |
|
|
56
56
|
| `tracing` | `boolean` | `true` | Starts the trace provider. |
|
|
57
|
-
| `propagateTraceHeaderCorsUrls` | `Array<string \| RegExp>` |
|
|
57
|
+
| `propagateTraceHeaderCorsUrls` | `Array<string \| RegExp>` | `[]` (the origin of the page only) | The other origins that get trace context headers. Requests to the origin of the page always get them. Refer to [Trace headers to other origins](#trace-headers-to-other-origins). |
|
|
58
58
|
| `metrics` | `boolean` | `true` | Starts the meter provider. |
|
|
59
59
|
| `metricsExportIntervalMs` | `number` | `15000` | The time between two metric exports, in milliseconds. Refer to [Metric export](#metric-export). |
|
|
60
60
|
| `metricsTemporality` | `"cumulative" \| "delta"` | `"cumulative"` | The aggregation temporality that the OTLP metric exporter requests. |
|
|
@@ -71,6 +71,18 @@ meter.createHistogram("checkout.duration", { unit: "ms" }).record(120);
|
|
|
71
71
|
| `sessionTracking` | `boolean` | `true` | Keeps the session ID in `sessionStorage`. Refer to [Sessions](#sessions). |
|
|
72
72
|
| `debug` | `boolean` | `false` | Writes the configuration to the console when `init()` runs. |
|
|
73
73
|
|
|
74
|
+
### Trace headers to other origins
|
|
75
|
+
|
|
76
|
+
The fetch and XHR instrumentations add the trace context headers (`traceparent`) to the requests to the origin of the page. A request to another origin gets them only when `propagateTraceHeaderCorsUrls` has a match for its URL. A custom header makes the browser send a CORS preflight, so each origin in the list must allow `traceparent` in `Access-Control-Allow-Headers`. Otherwise the browser refuses the request.
|
|
77
|
+
|
|
78
|
+
To join the spans of your API on another origin to the trace of the page, give that origin:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
init({ propagateTraceHeaderCorsUrls: [/^https:\/\/api\.example\.com\//] });
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Before 0.2.0, the default was `[/.*/]`: each cross-origin request got the headers, and third-party servers without `traceparent` in their CORS headers refused the requests.
|
|
85
|
+
|
|
74
86
|
## The returned object
|
|
75
87
|
|
|
76
88
|
| Member | Description |
|
|
@@ -343,7 +355,9 @@ node --import ./dist/instrumentation.js dist/server.js
|
|
|
343
355
|
|
|
344
356
|
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.
|
|
345
357
|
|
|
346
|
-
`startNodeTelemetry()` starts nothing when `OTEL_EXPORTER_OTLP_ENDPOINT` has no value. Set `enabled` to change this. By default, it stops the SDK and sends the last spans at `SIGTERM` and `SIGINT`.
|
|
358
|
+
`startNodeTelemetry()` starts nothing when `OTEL_EXPORTER_OTLP_ENDPOINT` has no value. Set `enabled` to change this. 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.
|
|
359
|
+
|
|
360
|
+
The option `env` sets only `enabled` and the service name. The SDK reads its exporter settings (`OTEL_EXPORTER_OTLP_*`) from `process.env`. To send the spans to another endpoint, give `traceExporter`.
|
|
347
361
|
|
|
348
362
|
### The trace of a write, in its echo
|
|
349
363
|
|