@mark1russell7/otel-ts 0.1.4 → 0.3.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  OpenTelemetry and Grafana Faro for TypeScript web apps, with one `init()` call.
4
4
 
5
+ Try the [live lab](https://mark1russell7.github.io/otel-ts/). It starts the real `init()` in your browser, and it shows each span, metric and log record as it leaves the package. The data stays in your browser.
6
+
5
7
  ## Install
6
8
 
7
9
  Install the package from npm:
@@ -54,7 +56,7 @@ meter.createHistogram("checkout.duration", { unit: "ms" }).record(120);
54
56
  | `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
57
  | `resourceAttributes` | `Record<string, string>` | `{}` | More resource attributes. They replace the attributes above when the key is the same. |
56
58
  | `tracing` | `boolean` | `true` | Starts the trace provider. |
57
- | `propagateTraceHeaderCorsUrls` | `Array<string \| RegExp>` | All origins | The origins that get trace context headers. |
59
+ | `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
60
  | `metrics` | `boolean` | `true` | Starts the meter provider. |
59
61
  | `metricsExportIntervalMs` | `number` | `15000` | The time between two metric exports, in milliseconds. Refer to [Metric export](#metric-export). |
60
62
  | `metricsTemporality` | `"cumulative" \| "delta"` | `"cumulative"` | The aggregation temporality that the OTLP metric exporter requests. |
@@ -71,6 +73,18 @@ meter.createHistogram("checkout.duration", { unit: "ms" }).record(120);
71
73
  | `sessionTracking` | `boolean` | `true` | Keeps the session ID in `sessionStorage`. Refer to [Sessions](#sessions). |
72
74
  | `debug` | `boolean` | `false` | Writes the configuration to the console when `init()` runs. |
73
75
 
76
+ ### Trace headers to other origins
77
+
78
+ 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.
79
+
80
+ To join the spans of your API on another origin to the trace of the page, give that origin:
81
+
82
+ ```ts
83
+ init({ propagateTraceHeaderCorsUrls: [/^https:\/\/api\.example\.com\//] });
84
+ ```
85
+
86
+ 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.
87
+
74
88
  ## The returned object
75
89
 
76
90
  | Member | Description |