@utk09/ui-observability 0.9.3 → 0.9.5
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 +90 -0
- package/README.md +199 -96
- package/dist/batch-BQFtb3i5.cjs +2 -0
- package/dist/batch-BQFtb3i5.cjs.map +1 -0
- package/dist/{batch-DDgxg16_.js → batch-BUJh-1jZ.js} +6 -4
- package/dist/batch-BUJh-1jZ.js.map +1 -0
- package/dist/bus/bus.d.ts +76 -2
- package/dist/bus/links.d.ts +9 -2
- package/dist/bus/validation.d.ts +7 -0
- package/dist/bus-BW6N-pY8.cjs +2 -0
- package/dist/bus-BW6N-pY8.cjs.map +1 -0
- package/dist/bus-DeOPHWaD.js +647 -0
- package/dist/bus-DeOPHWaD.js.map +1 -0
- package/dist/capture/network.d.ts +1 -0
- package/dist/capture/storm.d.ts +2 -1
- package/dist/capture/types.d.ts +5 -0
- package/dist/capture/web-socket.d.ts +40 -0
- package/dist/{console-BSusX_M-.cjs → console-Ce6heqZZ.cjs} +2 -2
- package/dist/console-Ce6heqZZ.cjs.map +1 -0
- package/dist/{console-Dv5GfaNn.js → console-DbAZYJuy.js} +4 -4
- package/dist/console-DbAZYJuy.js.map +1 -0
- package/dist/constants-CN7GE1Lt.js +246 -0
- package/dist/constants-CN7GE1Lt.js.map +1 -0
- package/dist/constants-CW-MlHdY.cjs +2 -0
- package/dist/constants-CW-MlHdY.cjs.map +1 -0
- package/dist/constants.d.ts +63 -11
- package/dist/context-storage-BjzeBSxH.cjs +2 -0
- package/dist/context-storage-BjzeBSxH.cjs.map +1 -0
- package/dist/context-storage-DxZf4Gfh.js +52 -0
- package/dist/context-storage-DxZf4Gfh.js.map +1 -0
- package/dist/core/breadcrumbs.d.ts +10 -3
- package/dist/core/context.d.ts +2 -0
- package/dist/core/diagnostics.d.ts +11 -3
- package/dist/core/journey.d.ts +7 -0
- package/dist/core/meter.d.ts +25 -2
- package/dist/core/pipeline.d.ts +41 -6
- package/dist/core/record.d.ts +42 -9
- package/dist/core/remote-sampling.d.ts +7 -3
- package/dist/core/runtime.d.ts +153 -6
- package/dist/core/sampling.d.ts +35 -2
- package/dist/core/sender.d.ts +43 -1
- package/dist/core/spans.d.ts +34 -0
- package/dist/deadline-5_PecIl5.js +26 -0
- package/dist/deadline-5_PecIl5.js.map +1 -0
- package/dist/deadline-XSnm95pg.cjs +2 -0
- package/dist/deadline-XSnm95pg.cjs.map +1 -0
- package/dist/emergency-queue-BYUyDHGD.js +69 -0
- package/dist/emergency-queue-BYUyDHGD.js.map +1 -0
- package/dist/emergency-queue-Cs1hrjsC.cjs +2 -0
- package/dist/emergency-queue-Cs1hrjsC.cjs.map +1 -0
- package/dist/{errors-DCZWcHkd.js → errors-BhC7HTSt.js} +8 -9
- package/dist/errors-BhC7HTSt.js.map +1 -0
- package/dist/errors-CgY633cG.cjs +3 -0
- package/dist/errors-CgY633cG.cjs.map +1 -0
- package/dist/factory-C5TujXlU.js +280 -0
- package/dist/factory-C5TujXlU.js.map +1 -0
- package/dist/factory-CNj4DH3n.cjs +2 -0
- package/dist/factory-CNj4DH3n.cjs.map +1 -0
- package/dist/fixed-window-CtaFHanJ.js +12 -0
- package/dist/fixed-window-CtaFHanJ.js.map +1 -0
- package/dist/fixed-window-CvESpFYV.cjs +2 -0
- package/dist/fixed-window-CvESpFYV.cjs.map +1 -0
- package/dist/identity-8vKkyAWm.js +103 -0
- package/dist/identity-8vKkyAWm.js.map +1 -0
- package/dist/identity-Da9TkuKd.cjs +2 -0
- package/dist/identity-Da9TkuKd.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +66 -6
- package/dist/index.js +1253 -595
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-BTfIFRHF.cjs +2 -0
- package/dist/indexeddb-storage-BTfIFRHF.cjs.map +1 -0
- package/dist/{indexeddb-storage-T9YIYVYC.js → indexeddb-storage-CCA1LvtO.js} +45 -30
- package/dist/indexeddb-storage-CCA1LvtO.js.map +1 -0
- package/dist/{interactions-BLH_tX87.js → interactions-BUDLxbv1.js} +16 -12
- package/dist/interactions-BUDLxbv1.js.map +1 -0
- package/dist/interactions-NHbLKrqe.cjs +2 -0
- package/dist/interactions-NHbLKrqe.cjs.map +1 -0
- package/dist/{journey-yALMEWF7.js → journey-BUJ4WJxP.js} +37 -34
- package/dist/journey-BUJ4WJxP.js.map +1 -0
- package/dist/journey-B_tTnvac.cjs +2 -0
- package/dist/journey-B_tTnvac.cjs.map +1 -0
- package/dist/keys-BHhw_0Wh.cjs +2 -0
- package/dist/keys-BHhw_0Wh.cjs.map +1 -0
- package/dist/keys-D5r_GH9q.js +17 -0
- package/dist/keys-D5r_GH9q.js.map +1 -0
- package/dist/{library-request-CQD4HUiP.js → library-request-BKOcaKtQ.js} +3 -3
- package/dist/{library-request-CQD4HUiP.js.map → library-request-BKOcaKtQ.js.map} +1 -1
- package/dist/{library-request-BcAxuwsf.cjs → library-request-BaZOi4eg.cjs} +2 -2
- package/dist/{library-request-BcAxuwsf.cjs.map → library-request-BaZOi4eg.cjs.map} +1 -1
- package/dist/{long-frames-D4Bm3Zkz.cjs → long-frames-CF3qiSAX.cjs} +2 -2
- package/dist/long-frames-CF3qiSAX.cjs.map +1 -0
- package/dist/{long-frames-DD_Um9_4.js → long-frames-DI5ypfAF.js} +5 -5
- package/dist/long-frames-DI5ypfAF.js.map +1 -0
- package/dist/models/batch.d.ts +4 -0
- package/dist/models/bus.d.ts +32 -9
- package/dist/models/config.d.ts +401 -12
- package/dist/models/drop.d.ts +1 -1
- package/dist/models/health.d.ts +27 -0
- package/dist/models/log-record.d.ts +1 -1
- package/dist/models/plugin.d.ts +47 -0
- package/dist/models/stats.d.ts +11 -0
- package/dist/models/storage.d.ts +13 -0
- package/dist/network-CF8UO5PK.cjs +2 -0
- package/dist/network-CF8UO5PK.cjs.map +1 -0
- package/dist/{network--GoE7_Or.js → network-DdzXDI3J.js} +47 -31
- package/dist/network-DdzXDI3J.js.map +1 -0
- package/dist/openfin-BwEN0uj4.js.map +1 -1
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/{platform-GaM6h7XM.js → platform-Bw1btWCT.js} +21 -10
- package/dist/platform-Bw1btWCT.js.map +1 -0
- package/dist/platform-DBSKTvFn.cjs +2 -0
- package/dist/platform-DBSKTvFn.cjs.map +1 -0
- package/dist/remote-rules-DIcC5vVC.js +91 -0
- package/dist/remote-rules-DIcC5vVC.js.map +1 -0
- package/dist/remote-rules-DpFmOef2.cjs +2 -0
- package/dist/remote-rules-DpFmOef2.cjs.map +1 -0
- package/dist/sampling-BVjspJWu.cjs +2 -0
- package/dist/sampling-BVjspJWu.cjs.map +1 -0
- package/dist/sampling-Cm3WhI0a.js +76 -0
- package/dist/sampling-Cm3WhI0a.js.map +1 -0
- package/dist/{sanitize-DP0xDPrt.js → sanitize-C-ahCFsG.js} +2 -2
- package/dist/{sanitize-DP0xDPrt.js.map → sanitize-C-ahCFsG.js.map} +1 -1
- package/dist/{sanitize--_e4oOPX.cjs → sanitize-DHucKGdi.cjs} +2 -2
- package/dist/{sanitize--_e4oOPX.cjs.map → sanitize-DHucKGdi.cjs.map} +1 -1
- package/dist/sender-D3fRCR8d.cjs +3 -0
- package/dist/sender-D3fRCR8d.cjs.map +1 -0
- package/dist/sender-DUUmSglb.js +1163 -0
- package/dist/sender-DUUmSglb.js.map +1 -0
- package/dist/storage/context-storage.d.ts +89 -0
- package/dist/storage/emergency-queue.d.ts +9 -1
- package/dist/storage/factory.d.ts +7 -1
- package/dist/storage/idb-driver.d.ts +13 -0
- package/dist/storage/indexeddb-storage.d.ts +13 -0
- package/dist/storage/local-storage.d.ts +21 -1
- package/dist/storage/memory-storage.d.ts +13 -0
- package/dist/storage-BA9RqRO-.cjs +2 -0
- package/dist/storage-BA9RqRO-.cjs.map +1 -0
- package/dist/storage-w7Tslvlq.js +17 -0
- package/dist/storage-w7Tslvlq.js.map +1 -0
- package/dist/storm-CNZjsw4T.cjs +2 -0
- package/dist/storm-CNZjsw4T.cjs.map +1 -0
- package/dist/storm-Daq2jGHU.js +10 -0
- package/dist/storm-Daq2jGHU.js.map +1 -0
- package/dist/transport/exit-flush.d.ts +6 -0
- package/dist/transport/http-transport.d.ts +2 -1
- package/dist/transport/retry-engine.d.ts +7 -2
- package/dist/transport/serializers/otlp-traces.d.ts +3 -0
- package/dist/transport/serializers/select.d.ts +8 -5
- package/dist/transport/status-transport.d.ts +24 -0
- package/dist/types-BR9t_w28.js +8 -0
- package/dist/types-BR9t_w28.js.map +1 -0
- package/dist/types-C7WNpnG1.cjs +2 -0
- package/dist/types-C7WNpnG1.cjs.map +1 -0
- package/dist/utils/fixed-window.d.ts +9 -0
- package/dist/utils/identity.d.ts +20 -2
- package/dist/utils/lock.d.ts +8 -0
- package/dist/utils/openfin.d.ts +1 -1
- package/dist/utils/platform.d.ts +10 -0
- package/dist/utils/tracing.d.ts +82 -4
- package/dist/web-socket-BacvKOvD.cjs +2 -0
- package/dist/web-socket-BacvKOvD.cjs.map +1 -0
- package/dist/web-socket-CpsD8WAa.js +105 -0
- package/dist/web-socket-CpsD8WAa.js.map +1 -0
- package/package.json +1 -1
- package/dist/batch-D5qvsMQ_.cjs +0 -2
- package/dist/batch-D5qvsMQ_.cjs.map +0 -1
- package/dist/batch-DDgxg16_.js.map +0 -1
- package/dist/bus-C6RwKzPW.js +0 -478
- package/dist/bus-C6RwKzPW.js.map +0 -1
- package/dist/bus-WPVDFw2y.cjs +0 -2
- package/dist/bus-WPVDFw2y.cjs.map +0 -1
- package/dist/console-BSusX_M-.cjs.map +0 -1
- package/dist/console-Dv5GfaNn.js.map +0 -1
- package/dist/constants-Cb92egPS.cjs +0 -2
- package/dist/constants-Cb92egPS.cjs.map +0 -1
- package/dist/constants-DhH6VI5a.js +0 -144
- package/dist/constants-DhH6VI5a.js.map +0 -1
- package/dist/deadline-CUrH0Hd8.cjs +0 -2
- package/dist/deadline-CUrH0Hd8.cjs.map +0 -1
- package/dist/deadline-DeqXEliN.js +0 -31
- package/dist/deadline-DeqXEliN.js.map +0 -1
- package/dist/errors-DCZWcHkd.js.map +0 -1
- package/dist/errors-ERu-su8m.cjs +0 -3
- package/dist/errors-ERu-su8m.cjs.map +0 -1
- package/dist/fixed-window-BR0bu32Y.cjs +0 -2
- package/dist/fixed-window-BR0bu32Y.cjs.map +0 -1
- package/dist/fixed-window-Re7jIRJH.js +0 -9
- package/dist/fixed-window-Re7jIRJH.js.map +0 -1
- package/dist/identity-C1WLItSl.cjs +0 -2
- package/dist/identity-C1WLItSl.cjs.map +0 -1
- package/dist/identity-Di-QXGCC.js +0 -88
- package/dist/identity-Di-QXGCC.js.map +0 -1
- package/dist/indexeddb-storage-DX18p39D.cjs +0 -2
- package/dist/indexeddb-storage-DX18p39D.cjs.map +0 -1
- package/dist/indexeddb-storage-T9YIYVYC.js.map +0 -1
- package/dist/interactions-BLH_tX87.js.map +0 -1
- package/dist/interactions-_hfOerfC.cjs +0 -2
- package/dist/interactions-_hfOerfC.cjs.map +0 -1
- package/dist/journey-BRUj0hqD.cjs +0 -2
- package/dist/journey-BRUj0hqD.cjs.map +0 -1
- package/dist/journey-yALMEWF7.js.map +0 -1
- package/dist/long-frames-D4Bm3Zkz.cjs.map +0 -1
- package/dist/long-frames-DD_Um9_4.js.map +0 -1
- package/dist/network--GoE7_Or.js.map +0 -1
- package/dist/network-DcuS2H1P.cjs +0 -2
- package/dist/network-DcuS2H1P.cjs.map +0 -1
- package/dist/platform-GaM6h7XM.js.map +0 -1
- package/dist/platform-kIL5AZB7.cjs +0 -2
- package/dist/platform-kIL5AZB7.cjs.map +0 -1
- package/dist/remote-rules-6ePq8CrI.js +0 -84
- package/dist/remote-rules-6ePq8CrI.js.map +0 -1
- package/dist/remote-rules-CI3gbRCL.cjs +0 -2
- package/dist/remote-rules-CI3gbRCL.cjs.map +0 -1
- package/dist/sampling-C-M8p3FK.cjs +0 -2
- package/dist/sampling-C-M8p3FK.cjs.map +0 -1
- package/dist/sampling-Ud_WiuU9.js +0 -65
- package/dist/sampling-Ud_WiuU9.js.map +0 -1
- package/dist/sender-BESHz6my.cjs +0 -3
- package/dist/sender-BESHz6my.cjs.map +0 -1
- package/dist/sender-BUBWLn5i.js +0 -1244
- package/dist/sender-BUBWLn5i.js.map +0 -1
- package/dist/storm-DhHGHhOc.cjs +0 -2
- package/dist/storm-DhHGHhOc.cjs.map +0 -1
- package/dist/storm-OD5J6Ylm.js +0 -10
- package/dist/storm-OD5J6Ylm.js.map +0 -1
package/README.md
CHANGED
|
@@ -64,11 +64,11 @@ log.logAction("ORDER_SUBMIT", { orderId: "ORD-1001", qty: 100 });
|
|
|
64
64
|
log.error("pricing call failed", caughtError);
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
- `configure()` is idempotent. A later call updates
|
|
67
|
+
- `configure()` is idempotent. A later call updates an unlocked runtime singleton in place. Delivery/identity changes require `rotateSecurityContext()` by default. You cannot change `storage`, `identity`, `batching`, `retention`, `limits` or `journey.maxAgeMs` after startup. The library reports that change and ignores it.
|
|
68
68
|
- Call `configure()` from one context in each document. A second call changes `service.name` on the records of every other context. In a composed page, the shell calls `configure()`. Each microfrontend uses its own namespace.
|
|
69
69
|
- You can call `getLogger()` at module top level, before `configure()`. The logger finds the runtime on its first write.
|
|
70
|
-
- A write before the first `configure()` starts a runtime with default settings. It does not throw. The first `configure()` then sets `limits` and `
|
|
71
|
-
- After `shutdown()`,
|
|
70
|
+
- A write before the first `configure()` starts a runtime with default settings. It does not throw. The first `configure()` then sets `limits`, `journey.maxAgeMs`, `persistence.namespace` and an explicit `securityContext.id` of that runtime.
|
|
71
|
+
- After `shutdown()`, logging does nothing until the next `configure()`; health/stats remain inspectable.
|
|
72
72
|
|
|
73
73
|
### Console Only (No Network)
|
|
74
74
|
|
|
@@ -89,7 +89,7 @@ configure({
|
|
|
89
89
|
- `identity: "memory"` writes no key to `localStorage` or `sessionStorage`.
|
|
90
90
|
- `console` and `minLevel` are independent. `console` sets what the library prints. `minLevel` sets what the library sends.
|
|
91
91
|
- The console output does not depend on the bus or the endpoint.
|
|
92
|
-
- With a `redact` hook, the console shows only what `redact` returns. A record that `redact` drops prints no line.
|
|
92
|
+
- With a `redact` hook, the console shows only what `redact` returns. A record that a processor or `redact` drops prints no line. With `redact` or `processors`, a record below `minLevel` or outside the sample also goes through them before the console prints it. Without hooks, such a record shows its message, payload and error as given.
|
|
93
93
|
|
|
94
94
|
### Console Output
|
|
95
95
|
|
|
@@ -159,7 +159,8 @@ configure({
|
|
|
159
159
|
- A rejected promise counts as a network error. The library sends the batch again later. A call that does not settle in 15 seconds counts as a timeout.
|
|
160
160
|
- The library does not compress `request.body`. Compress it in your transport if necessary.
|
|
161
161
|
- `request.records` holds the built records after `redact`. Do not change them, because the retry engine can send them again.
|
|
162
|
-
- `request.kind` is `"metrics"` for a batch of metric records when `metricsEndpoint` is set. `request.body` is then an OTLP `ExportMetricsServiceRequest`. Send it to your metrics endpoint.
|
|
162
|
+
- `request.kind` is `"metrics"` for a batch of metric records when `metricsEndpoint` is set. `request.body` is then an OTLP `ExportMetricsServiceRequest`. Send it to your metrics endpoint.
|
|
163
|
+
- `request.kind` is `"traces"` for a batch of span records. `request.body` is then an OTLP `ExportTraceServiceRequest`. Send it to your traces endpoint. Each other batch has the kind `"logs"`.
|
|
163
164
|
- Without `transportOnExit`, the last batch goes to the emergency queue when the page closes. The next page load sends it.
|
|
164
165
|
- With `storage: "none"`, the next page load cannot keep that batch. Set `transportOnExit`, or the library loses the last batch.
|
|
165
166
|
- The library ignores a `retryAfterMs` or a `maxBytes` that is not a finite number. It uses 0 for a negative value.
|
|
@@ -225,21 +226,25 @@ X-UiObs-Sampling: {"v":1,"ttlMs":600000,"defaultRate":0.1,"rates":{"blotter.grid
|
|
|
225
226
|
- `v` must be `1`. `ttlMs` is mandatory, from more than 0 to 3,600,000 (1 hour). After the TTL, the rules from `configure()` apply again.
|
|
226
227
|
- `rates` apply over the `configure()` rates. The other `configure()` rates stay. `defaultRate` applies only if the header has it.
|
|
227
228
|
- `minLevel` can only lower the level that the library sends. It does not change the console level.
|
|
229
|
+
- `minLevels` sets a level for each namespace prefix, for example `{"trading.ticks":"DEBUG"}`. A remote prefix wins over the remote `minLevel`. A remote level applies only when it is lower than the `configure()` level of the namespace. At most 100 prefixes.
|
|
228
230
|
- `sampling.remoteMaxRate` caps each remote rate. It also caps the records that a remote `minLevel` adds. Set it below 1 to limit the traffic that a compromised server can cause.
|
|
229
231
|
- The library rejects all the rules if one field is not valid, for example a rate outside 0 to 1, more than 100 `rates` or a header longer than 4096 characters. It reports `config.invalid`.
|
|
230
232
|
- The library keeps the rules in memory only. A reload uses the `configure()` rules until the next accepted batch.
|
|
231
233
|
- A child frame, a worker or an OpenFin view asks its owner for the rules at start and each 30 seconds. Set `sampling.remote: true` in each context.
|
|
232
234
|
- A frame accepts rules from a parent only if the parent origin is the page origin or is in `bus.trustedOrigins`. A page that embeds your app cannot lower `minLevel`.
|
|
235
|
+
- Under the default `bus.sourcePolicy: "registered"`, a parent sends rules only to a frame or a worker that it registered with the `sampling:read` permission.
|
|
233
236
|
- Each OpenFin view of one app can read the bus messages of the others. Load only trusted content into a view that has the `fin` API.
|
|
234
237
|
|
|
235
238
|
## API Reference
|
|
236
239
|
|
|
237
240
|
### Lifecycle & Setup
|
|
238
241
|
|
|
239
|
-
| Function
|
|
240
|
-
|
|
|
241
|
-
| `configure(config)`
|
|
242
|
-
| `shutdown()`
|
|
242
|
+
| Function | Description |
|
|
243
|
+
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
244
|
+
| `configure(config)` | Starts the runtime singleton, or updates it. |
|
|
245
|
+
| `shutdown()` | Sends pending records and stops every subsystem. Later calls do nothing until the next `configure()`. |
|
|
246
|
+
| `rotateSecurityContext(update, options?)` | Changes the delivery identity and the delivery settings together. Use it at logout or a tenant change. See [runtime policies](docs/runtime-policies.md#security-context-rotation). |
|
|
247
|
+
| `setConfigurationLocked(locked)` | Locks or unlocks changes through `configure()`. |
|
|
243
248
|
|
|
244
249
|
### Logging Methods
|
|
245
250
|
|
|
@@ -266,83 +271,110 @@ The level methods give records with `log.type: "log"`. Records of the library it
|
|
|
266
271
|
|
|
267
272
|
### Context & Correlation
|
|
268
273
|
|
|
269
|
-
| Function
|
|
270
|
-
|
|
|
271
|
-
| `setContext(key, value)`
|
|
272
|
-
| `setContextMap(values)`
|
|
273
|
-
| `removeContext(key)`
|
|
274
|
-
| `
|
|
275
|
-
| `
|
|
276
|
-
| `
|
|
277
|
-
| `
|
|
278
|
-
| `
|
|
279
|
-
| `
|
|
280
|
-
| `
|
|
281
|
-
| `
|
|
274
|
+
| Function | Description |
|
|
275
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
276
|
+
| `setContext(key, value)` | Sets one ambient attribute on every later record. |
|
|
277
|
+
| `setContextMap(values)` | Merges an attribute map into the ambient context. |
|
|
278
|
+
| `removeContext(key)` | Removes one attribute from the ambient context. |
|
|
279
|
+
| `addBreadcrumb(message, data?)` | Adds a breadcrumb with the category `custom`. The next error record carries the trail. The library copies `data` at the call. |
|
|
280
|
+
| `startJourney(name, options?)` | Starts a journey across windows. `options.parent: true` links the active journey as the parent. `options.id` sets the id, 1 to 64 letters, digits, `_`, `.`, `:` or `-`. Another value gives a new id and a `config.invalid` report. |
|
|
281
|
+
| `endJourney()` | Ends the active journey. |
|
|
282
|
+
| `currentJourney()` | Returns the active `Journey`, or null. |
|
|
283
|
+
| `getJourneyToken()` | Serializes the active journey into a URL token. |
|
|
284
|
+
| `adoptJourney(token)` | Adopts a journey token into this context. |
|
|
285
|
+
| `startTrace()` | Rotates the ambient trace context. |
|
|
286
|
+
| `getTraceHeaders()` | Returns the W3C `traceparent` header for an outgoing request. |
|
|
287
|
+
| `registerWorker(worker, options?)` | Attaches a Web Worker or MessagePort to the bus, with its permissions. Returns a function that removes the registration. |
|
|
288
|
+
| `registerFrame(frame, options)` | Registers a child iframe element or window at its exact origin, with its permissions. Returns a function that removes the registration. A child frame forwards only after its registration, unless `bus.sourcePolicy` is `trusted-origin`. |
|
|
289
|
+
| `newSession()` | Rotates correlation in this tab. Use `rotateSecurityContext()` for logout or tenant changes. It sends the open metric points, ends the active trace and journey, and clears the breadcrumbs. Other tabs read the new id at their next startup. |
|
|
290
|
+
|
|
291
|
+
See [runtime policies, operational budgets and migration](docs/runtime-policies.md) for `rotateSecurityContext()`, `registerFrame()`, source permissions, `setConfigurationLocked()`, `getHealth()` and configurable cache/bus budgets. Defaults favor privacy and isolation; applications can explicitly choose broader capture and delivery policies.
|
|
282
292
|
|
|
283
293
|
### Delivery & Diagnostics
|
|
284
294
|
|
|
285
|
-
| Function
|
|
286
|
-
|
|
|
287
|
-
| `flush()`
|
|
288
|
-
| `getQueueDepth()`
|
|
289
|
-
| `
|
|
295
|
+
| Function | Description |
|
|
296
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
297
|
+
| `flush()` | Sends the records held in the pipeline or the forward buffer, and waits for the batches in flight. |
|
|
298
|
+
| `getQueueDepth()` | Returns the number of batches in storage. |
|
|
299
|
+
| `getStats()` | Returns `{ pending, inFlight, stored, lastSendAt }`. `pending` counts the records in the buffers. `inFlight` counts the records in requests. `stored` counts the batches in storage. `lastSendAt` is the epoch time in ms of the last batch that the server accepted, or null. A forwarder reports only its own buffers. |
|
|
300
|
+
| `getDiagnosticCounters()` | Returns the count of each diagnostic code. |
|
|
301
|
+
| `getHealth()` | Returns the state of this SDK copy. It has the SDK version, the status, the delivery role and counts, the lock and cache state, the issue codes and the policies. |
|
|
302
|
+
| `clearPersistedLogs(scope?)` | Removes the stored records of the active context. With `"namespace"`, it removes the stored records of each context in the persistence namespace. |
|
|
290
303
|
|
|
291
304
|
---
|
|
292
305
|
|
|
293
306
|
## Configuration Options
|
|
294
307
|
|
|
295
|
-
No key is required. Set `endpoint` to send records. A value of the wrong type or outside its range reports `config.invalid`. The value in force stays. Level names can have any case. You cannot change `batching` and `retention` after the delivery stack loads. You cannot change `limits` and `journey.maxAgeMs` after the first `configure()`.
|
|
296
|
-
|
|
297
|
-
| Key
|
|
298
|
-
|
|
|
299
|
-
| `endpoint`
|
|
300
|
-
| `metricsEndpoint`
|
|
301
|
-
| `
|
|
302
|
-
| `
|
|
303
|
-
| `
|
|
304
|
-
| `
|
|
305
|
-
| `
|
|
306
|
-
| `
|
|
307
|
-
| `
|
|
308
|
-
| `
|
|
309
|
-
| `
|
|
310
|
-
| `
|
|
311
|
-
| `
|
|
312
|
-
| `
|
|
313
|
-
| `
|
|
314
|
-
| `sampling.
|
|
315
|
-
| `sampling.
|
|
316
|
-
| `sampling.
|
|
317
|
-
| `
|
|
318
|
-
| `
|
|
319
|
-
| `bus.
|
|
320
|
-
| `
|
|
321
|
-
| `
|
|
322
|
-
| `
|
|
323
|
-
| `
|
|
324
|
-
| `
|
|
325
|
-
| `
|
|
326
|
-
| `
|
|
327
|
-
| `
|
|
328
|
-
| `
|
|
329
|
-
| `
|
|
330
|
-
| `
|
|
331
|
-
| `
|
|
332
|
-
| `
|
|
333
|
-
| `
|
|
334
|
-
| `
|
|
335
|
-
| `limits.
|
|
336
|
-
| `limits.
|
|
337
|
-
| `limits.
|
|
338
|
-
| `
|
|
339
|
-
| `
|
|
340
|
-
| `
|
|
341
|
-
| `
|
|
342
|
-
| `
|
|
343
|
-
| `
|
|
344
|
-
| `
|
|
345
|
-
| `
|
|
308
|
+
No key is required. Set `endpoint` to send records. A value of the wrong type or outside its range reports `config.invalid`. The value in force stays. Level names can have any case. You cannot change `batching` and `retention` after the delivery stack loads. You cannot change `limits` and `journey.maxAgeMs` after the first `configure()`. [Runtime policies](docs/runtime-policies.md) gives each default and range of the policy sections.
|
|
309
|
+
|
|
310
|
+
| Key | Default | Description |
|
|
311
|
+
| ------------------------------------------------------------------------------------------------------ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
312
|
+
| `endpoint` | `""` | HTTP endpoint that receives the batches. `null` selects console-only mode. `""` reports `config.invalid`. |
|
|
313
|
+
| `metricsEndpoint` | `""` | OTLP metrics endpoint, for example `https://ingest.example/v1/metrics`. With it, each batch of metric records goes there as an OTLP `ExportMetricsServiceRequest`. Without it, metric records are log records on `endpoint`. It needs `serializer: "otlp"`, and `endpoint` or `transport`. |
|
|
314
|
+
| `tracesEndpoint` | `""` | OTLP traces endpoint, for example `https://ingest.example/v1/traces`. With it, the library records spans and sends them there as an OTLP `ExportTraceServiceRequest`. Without it, the library sends no span. It needs `serializer: "otlp"`, and `endpoint` or `transport`. See [Spans](#spans). |
|
|
315
|
+
| `serviceName` | `""` | `service.name` on every record. |
|
|
316
|
+
| `serviceVersion` | `""` | `service.version` on every record. |
|
|
317
|
+
| `environment` | `""` | `deployment.environment` on every record. |
|
|
318
|
+
| `enabled` | `true` | Set `false` to stop all logging. Every log call then does nothing. |
|
|
319
|
+
| `minLevel` | `"INFO"` | Lowest level that the library sends (`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`). It does not drop actions and metrics. |
|
|
320
|
+
| `minLevels` | `{}` | Lowest level for each namespace prefix, for example `{ "trading.ticks": "DEBUG" }`. The longest matching prefix wins. A prefix matches its own namespace and the namespaces below it after a dot. A namespace with no match uses `minLevel`. A new map replaces the map in force. |
|
|
321
|
+
| `compression` | `"gzip"` | `gzip` or `none`. The library compresses a payload above 1 KB only. |
|
|
322
|
+
| `serializer` | `"otlp"` | `otlp`, `ecs`, or a custom `LogSerializer`. `ecs` writes ECS 8.10 NDJSON. It maps `app.namespace` to `log.logger`, `error.type`, `error.message` and `error.stack_trace` to `error.*`, and `log.type` to `event.kind`. The other attributes go to `labels`. |
|
|
323
|
+
| `credentials` | `"omit"` | Fetch credentials mode. Set `"include"` for cookie auth. |
|
|
324
|
+
| `headers` | `{}` | Static headers, or a function that returns them. After a 401 or 403, a function gets one more call and the batch one more send. The exit flush sends the last headers. Before a function gives its first result, the exit flush puts the batch in the emergency queue. `headers: undefined` removes the headers. |
|
|
325
|
+
| `storage` | `"auto"` | Store for undelivered batches: `auto`, `indexeddb`, `localstorage`, `memory` or `none`. Fixed at startup. |
|
|
326
|
+
| `identity` | `"storage"` | Store for session, tab and journey ids. `memory` writes no key. Fixed at startup. |
|
|
327
|
+
| `sampling.defaultRate` | `1` | Keep rate for a namespace with no rule. |
|
|
328
|
+
| `sampling.rates` | `{}` | Keep rate per namespace. The longest matching prefix wins. |
|
|
329
|
+
| `sampling.alwaysSampleTypes` | `["action"]` | Record types that ignore the rate. |
|
|
330
|
+
| `sampling.remote` | `false` | Reads sampling rules from the `X-UiObs-Sampling` header of each accepted batch (see Remote Sampling). |
|
|
331
|
+
| `sampling.remoteMaxRate` | `1` | Highest rate that a remote rule can set. It applies to the remote `defaultRate` and to each remote namespace rate. |
|
|
332
|
+
| `bus.mode` | `"auto"` | `auto`, `sender`, `forwarder` or `off`. With `off`, this context sends its own records and opens no link. A same-origin child frame that the page registers can still forward to it. |
|
|
333
|
+
| `bus.trustedOrigins` | `[]` | Origins of other documents that this document trusts. A cross-origin child frame forwards its records only to a parent on these origins. With `bus.sourcePolicy: "trusted-origin"`, a parent also accepts records from a child frame on these origins. With the default policy, use `registerFrame()`. The library keeps the origin of each URL. For a sandboxed frame, set `bus.mode: "sender"` in the frame. A trusted origin is also trusted for metric points. Its points bypass the sampling and the limit of 100 attribute sets of this document. |
|
|
334
|
+
| `bus.sourcePolicy` | `"registered"` | `registered` accepts only the frames and workers that the page registers. `trusted-origin` also accepts each frame on the page origin or in `bus.trustedOrigins`. |
|
|
335
|
+
| `bus.validation` | `"strict"` | `strict` checks the fields of each bus message. `envelope` checks the envelope only. |
|
|
336
|
+
| `bus.maxMessageBytes`, `bus.maxRecordsPerMessage`, `bus.maxMessagesPerSecond`, `bus.maxTrackedSources` | `262144`, `100`, `100`, `256` | Bus budgets for each message and each source. `0` turns a limit off. |
|
|
337
|
+
| `bus.openFinRole` | `"auto"` | `auto`, `provider` or `client`. |
|
|
338
|
+
| `journey.scope` | `"auto"` | Which contexts adopt a journey. `context`: each context keeps its own. `tab`: a frame or a worker adopts the journey of its owner. `origin`: each context of the origin, also in other tabs. `auto` is `origin` in OpenFin and `tab` in a browser. |
|
|
339
|
+
| `journey.maxAgeMs` | `1800000` | Maximum open time of a journey, in milliseconds. Then the library ends it. The range is 60000 to 86400000. |
|
|
340
|
+
| `batching.logFlushIntervalMs` | `2000` | Maximum wait of a partial log batch, in milliseconds. The range is 100 to 60000. |
|
|
341
|
+
| `batching.logBatchSize` | `100` | Maximum records in one log batch. The range is 1 to 1000. |
|
|
342
|
+
| `batching.metricFlushIntervalMs` | `10000` | Maximum wait of a partial metric batch, in milliseconds. The range is 100 to 60000. |
|
|
343
|
+
| `batching.metricBatchSize` | `500` | Maximum records in one metric batch. The range is 1 to 1000. |
|
|
344
|
+
| `retention.mode` | `"limited"` | `limited` or `until-delivered`. With `until-delivered`, a stored batch has no age limit and no attempt limit. `retention.maxBatches` still applies. A permanent error still drops the batch. A batch that always gets a temporary error stays first. The batches of the same endpoint behind it wait. |
|
|
345
|
+
| `retention.maxBatches` | `500` | Maximum stored batches. A new batch evicts the oldest batch without an action first. The range is 1 to 5000. |
|
|
346
|
+
| `retention.maxAgeMs` | `86400000` | Maximum age of a stored batch, in milliseconds. The range is 60000 to 604800000. |
|
|
347
|
+
| `retention.maxAttempts` | `5` | Maximum send attempts of a stored batch. The range is 1 to 20. |
|
|
348
|
+
| `limits.maxBodyChars` | `4096` | Maximum body length, in characters. The range is 256 to 65536. |
|
|
349
|
+
| `limits.maxAttributeChars` | `8192` | Maximum length of a string attribute, in characters. The range is 256 to 65536. |
|
|
350
|
+
| `limits.maxAttributeCount` | `128` | Maximum keys in one object. The range is 1 to 1024. |
|
|
351
|
+
| `limits.maxStackChars` | `8192` | Maximum length of an error stack, in characters. The range is 256 to 65536. |
|
|
352
|
+
| `limits.maxDepth` | `6` | Maximum depth of a nested value. The range is 1 to 16. |
|
|
353
|
+
| `limits.maxArrayLength` | `100` | Maximum items in one array, set or map. The range is 1 to 10000. |
|
|
354
|
+
| `limits.maxNodes` | `10000` | Maximum values in one sanitize pass. The range is 100 to 100000. |
|
|
355
|
+
| `limits.maxRecordBytes` | `32768` | Maximum attribute bytes of one record. Above it, the library drops the caller attributes. The range is 1024 to 60000. |
|
|
356
|
+
| `securityContext.id` | Generated | Delivery identity of this runtime. Supply a stable opaque id to send stored batches after a reload. Do not put secrets or personal data in it. |
|
|
357
|
+
| `securityContext.isolation` | `true` | Keeps the stored batches of each identity apart. Delivery changes then need `rotateSecurityContext()`. |
|
|
358
|
+
| `lockConfiguration` | `false` | Refuses changes through `configure()`. Identical repeated settings are accepted. `setConfigurationLocked(false)` unlocks. |
|
|
359
|
+
| `loggerCache.maxEntries` | `256` | LRU limit of cached loggers. `0` turns the cache off. `null` sets no limit. |
|
|
360
|
+
| `delivery` | See policies | Request timeout, request concurrency, retry delays and batches in one retry pass. |
|
|
361
|
+
| `buffering` | 10,000 records, 16 MiB, `"drop-oldest"` | Limits of the live buffers, and the overflow rule. |
|
|
362
|
+
| `metrics` | See policies | Limits of instrument names, attribute sets and histogram boundaries. |
|
|
363
|
+
| `correlation` | See policies | Session idle time, session write interval and trace age. Fixed at startup. |
|
|
364
|
+
| `capturePolicy` | See policies | Breadcrumb capacity, error duplicate check, capture rate limits and the error ceiling. |
|
|
365
|
+
| `diagnostics` | `{ throttleMs: 1000, consoleFallback: false }` | Report interval of each diagnostic code, and the console fallback when `onDiagnostic` throws. |
|
|
366
|
+
| `persistence.namespace` | `""` | Separates the batch stores, the emergency queue and the retry locks of one application. Fixed at startup. |
|
|
367
|
+
| `metadata` | All `true` | `pageUrl`, `userAgent` and `openfin` include `page.url`, `browser.user_agent` and the OpenFin fields. |
|
|
368
|
+
| `capture` | See below | Auto-capture settings. |
|
|
369
|
+
| `console` | `false` | Prints records to devtools. `true` prints from `DEBUG` up. A level name prints from that level up. An object sets `level` and `styles` (see Console Output). It does not depend on `minLevel`. |
|
|
370
|
+
| `transport(request)` | `undefined` | Sends batches through a channel of your app in place of HTTP (see Custom Transport). |
|
|
371
|
+
| `transportOnExit(request)` | `undefined` | Sends the last batch while the page closes. It must return a boolean and must not wait. |
|
|
372
|
+
| `otelLoader()` | `undefined` | Loads `@opentelemetry/api`. Without it, OTel is off. |
|
|
373
|
+
| `contextProvider()` | `undefined` | Returns attributes for each built record, including console/breadcrumb-only candidates, for example the current route. Its values override `setContext()` values. The logger scope and the call payload override its values. Keep it fast and synchronous. A provider that throws reports `handler.threw`. A value that is not an object reports `config.invalid`. The record is still built. |
|
|
374
|
+
| `processors` | `[]` | Functions that change or drop a record. They run in list order, before `redact`. A processor has the contract of `redact`. Return the record or a new record to keep it, or `null` to drop it. If a processor throws or returns a value that is not a record, the library drops the record. It counts `record.dropped_by_processor`. A new list replaces the list in force. |
|
|
375
|
+
| `redact(record)` | `undefined` | Changes a record before the library sends or prints it, including console-only candidates. Return `null` to drop the record. If the hook throws or returns a value that is not a record, the library drops the record. It counts `record.dropped_by_redact`. The sender also runs its `redact` on each record from a frame or a worker. A record that the child already redacted then runs through `redact` again. Write `redact` so that a second run gives the same result. |
|
|
376
|
+
| `onDiagnostic(event)` | `undefined` | Receives the faults of the library itself. |
|
|
377
|
+
| `onDrop(summary)` | `undefined` | Receives a summary when the library loses records that it built. The summary has `reason`, `records`, `batchIds`, `journeyIds` and `actions`. Sampling, `minLevel`, `processors` and `redact` do not cause a loss. Do not log through the library in the hook. A record from the hook can evict a stored batch. A batch that storage evicts during its send can still reach the server. |
|
|
346
378
|
|
|
347
379
|
### Auto-Capture Options
|
|
348
380
|
|
|
@@ -355,15 +387,18 @@ capture: {
|
|
|
355
387
|
xhr: false, // XMLHttpRequest duration and status codes
|
|
356
388
|
httpMetrics: true, // http.client.request.duration histogram of fetch and xhr requests, in seconds.
|
|
357
389
|
// Attributes: http.request.method, http.response.status_code, server.address, error.type
|
|
358
|
-
interactions: false, //
|
|
390
|
+
interactions: false, // Click action names. The object form sets actionAttribute, text and selector
|
|
359
391
|
navigation: false, // Single-page navigation URL changes
|
|
360
392
|
webVitals: false, // Core Web Vitals (LCP, CLS, INP, FCP, TTFB)
|
|
361
393
|
longFrames: false, // Frames that freeze the page, as ui.long_frame.duration
|
|
362
394
|
longFrameThresholdMs: 100, // Minimum frame duration that longFrames records
|
|
363
395
|
console: false, // App console calls: true, or a list such as ["error", "warn", "info"]
|
|
364
396
|
fullUrls: false, // Keep query strings and fragments on recorded URLs
|
|
397
|
+
urlTransform: undefined, // Function that replaces the default URL rule
|
|
365
398
|
ignoreUrls: [], // URL patterns excluded from network capture
|
|
366
399
|
propagateTraceHeaderTo: [], // Origins, or RegExp patterns, that receive traceparent
|
|
400
|
+
webSocket: false, // WebSocket open, close and error, and ui.websocket.messages
|
|
401
|
+
plugins: [], // Capture plugins of your app
|
|
367
402
|
}
|
|
368
403
|
```
|
|
369
404
|
|
|
@@ -386,22 +421,85 @@ capture: {
|
|
|
386
421
|
- To record an argument, the library reads each property, also a getter. A getter with a side effect then runs during the console call.
|
|
387
422
|
- On `shutdown()`, the library restores each method. If another script wrapped the method later, the library leaves it and reports `capture.install_failed`.
|
|
388
423
|
|
|
389
|
-
`
|
|
424
|
+
`webSocket` records the lifecycle of each WebSocket that the app opens after the capture loads.
|
|
425
|
+
|
|
426
|
+
- `websocket.open` and `websocket.close` are events. `websocket.error` is a WARN record. Each has `url.full` and `server.address`.
|
|
427
|
+
- `websocket.close` adds `websocket.close.code` and `websocket.close.clean`.
|
|
428
|
+
- `url.full` has no user info, no query and no fragment, also with `fullUrls`. A socket URL often holds a token. Only `urlTransform` can record more of the URL.
|
|
429
|
+
- The counter `ui.websocket.messages` counts the messages, with `network.io.direction` (`transmit` or `receive`) and `server.address`.
|
|
430
|
+
- The library never reads the content of a message.
|
|
431
|
+
- The library records at most 20 lifecycle records in each 10-second window. The counter counts each message.
|
|
432
|
+
|
|
433
|
+
`plugins` adds your own capture modules. A plugin is an object with `name`, `install(ctx)` and `uninstall()`.
|
|
434
|
+
|
|
435
|
+
- `ctx` gives `logger`, `counter()`, `histogram()`, `addBreadcrumb()` and `ownRequest(fn)`. The logger namespace is `uiobs.capture.<name>`.
|
|
436
|
+
- `ownRequest(fn)` runs `fn`. The network capture does not record a request that `fn` starts before its first `await`, and does not add `traceparent` to it.
|
|
437
|
+
- A `configure()` that changes the capture section calls `uninstall()`, then `install(ctx)` again. `shutdown()` calls `uninstall()`.
|
|
438
|
+
- If `install()` or `uninstall()` throws, the library reports `capture.install_failed`. The other capture modules keep working.
|
|
439
|
+
- The console-only runtime next to another version of the library installs no plugin.
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
import { type CapturePlugin, configure } from "@utk09/ui-observability";
|
|
443
|
+
|
|
444
|
+
let onChange: (() => void) | undefined;
|
|
445
|
+
|
|
446
|
+
const visibility: CapturePlugin = {
|
|
447
|
+
name: "visibility",
|
|
448
|
+
install(ctx) {
|
|
449
|
+
onChange = () => {
|
|
450
|
+
ctx.logger.logEvent("page.visibility", { state: document.visibilityState });
|
|
451
|
+
};
|
|
452
|
+
document.addEventListener("visibilitychange", onChange);
|
|
453
|
+
},
|
|
454
|
+
uninstall() {
|
|
455
|
+
if (onChange) {
|
|
456
|
+
document.removeEventListener("visibilitychange", onChange);
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
configure({ endpoint: "https://ingest.example/v1/logs", capture: { plugins: [visibility] } });
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
`fullUrls` is off by default. The library then cuts each recorded URL at the first `?` or `#`. This applies to the page URL, the request target and the URL of a failed resource. `ignoreUrls` and a RegExp in `propagateTraceHeaderTo` match the full URL. `urlTransform` replaces this rule. It receives the original URL. If it throws, the library records an empty URL and reports `capture.record_failed`.
|
|
390
465
|
|
|
391
466
|
A string in `propagateTraceHeaderTo` is an origin, for example `"https://api.example"`. It matches a request to that origin only. A URL with a path gives its origin. A relative request URL resolves against the page. To match a path, use a RegExp. A RegExp tests the request URL in the form that the caller gives. Start each RegExp with `^`. Without it, `/\/api\//` also matches `https://vendor.example/api/`. For example, `/^https:\/\/api\.example\/v2\//` matches one path on one origin. `/^\/api\//` matches a relative request URL only.
|
|
392
467
|
|
|
468
|
+
### Spans
|
|
469
|
+
|
|
470
|
+
With `tracesEndpoint`, the library sends spans. The backend then has a root span for each trace of the library.
|
|
471
|
+
|
|
472
|
+
- **Root span:** Each ambient trace has one root span of kind INTERNAL. It starts with the trace and ends when the trace rotates. Its name tells why the trace started: `ui.start`, `ui.interaction`, `ui.navigation` or `ui.trace`.
|
|
473
|
+
- **Client span:** Each `fetch` or XHR request that gets `traceparent` from `capture.propagateTraceHeaderTo` has one span of kind CLIENT. The `traceparent` names the client span, and the root span is its parent. Its name is the HTTP method. Its attributes are `http.request.method`, `url.full`, `server.address`, `http.response.status_code` and `error.type`. A status of 0 or 400 and more sets the status ERROR.
|
|
474
|
+
- **Sampling:** `sampling.defaultRate` samples each trace by its trace id. The whole trace stays or goes. `minLevel` does not apply to a span. For a trace that sampling drops, the `traceparent` has the sampled flag off. A downstream service then drops its spans too.
|
|
475
|
+
- **Exit:** The exit flush and `shutdown()` end the root span of the active trace. The root span of a trace ends one time. A tab that becomes hidden ends it too, because a mobile OS can stop a hidden page.
|
|
476
|
+
- **OpenTelemetry:** With `otelLoader`, a trace from the OpenTelemetry API keeps its own spans. The library sends no span for it.
|
|
477
|
+
- `getTraceHeaders()` names the root span. Your server span is then a child of the root span.
|
|
478
|
+
- Span records go through `processors` and `redact`. They also carry the context attributes of a record, for example `page.url` and `journey.id`.
|
|
479
|
+
|
|
393
480
|
### Browser Storage Keys
|
|
394
481
|
|
|
395
|
-
| Key | Store | Written when | Option that stops it
|
|
396
|
-
| ------------------------------ | ---------------- | ---------------------------------------------------------------- |
|
|
397
|
-
| `ui-observability.session` | `localStorage` | At startup, then at most one time each minute while logging | `identity: "memory"`
|
|
398
|
-
| `ui-observability.tab` | `sessionStorage` | At startup, and when the bus finds a duplicated tab | `identity: "memory"`
|
|
399
|
-
| `ui-observability.journey` | `sessionStorage` | When a journey starts or ends | `identity: "memory"`
|
|
400
|
-
| `ui-observability.batch.*` | `localStorage` | When a send fails and the `localstorage` adapter holds the batch | `storage` other than `auto` or `localstorage`
|
|
401
|
-
| `ui-observability.emergency.*` | `localStorage` | When the exit flush cannot send a batch | `endpoint: null`
|
|
402
|
-
| `ui-observability.probe` | `localStorage` | One write and one remove, when the library tests `localStorage` | `storage` other than `auto` or `localstorage`
|
|
482
|
+
| Key | Store | Written when | Option that stops it |
|
|
483
|
+
| ------------------------------ | ---------------- | ---------------------------------------------------------------- | ------------------------------------------------- |
|
|
484
|
+
| `ui-observability.session` | `localStorage` | At startup, then at most one time each minute while logging | `identity: "memory"` |
|
|
485
|
+
| `ui-observability.tab` | `sessionStorage` | At startup, and when the bus finds a duplicated tab | `identity: "memory"` |
|
|
486
|
+
| `ui-observability.journey` | `sessionStorage` | When a journey starts or ends | `identity: "memory"` |
|
|
487
|
+
| `ui-observability.batch.*` | `localStorage` | When a send fails and the `localstorage` adapter holds the batch | `storage` other than `auto` or `localstorage` |
|
|
488
|
+
| `ui-observability.emergency.*` | `localStorage` | When the exit flush cannot send a batch | `endpoint: null`, `storage: "memory"` or `"none"` |
|
|
489
|
+
| `ui-observability.probe` | `localStorage` | One write and one remove, when the library tests `localStorage` | `storage` other than `auto` or `localstorage` |
|
|
490
|
+
|
|
491
|
+
IndexedDB holds undelivered batches with `storage: "auto"` or `"indexeddb"`, in the database `UiObservability`.
|
|
403
492
|
|
|
404
|
-
|
|
493
|
+
With `persistence.namespace`, the batch keys start with `ui-observability:namespaced:<namespace>:batch:`, the emergency keys start with `ui-observability:namespaced:<namespace>:emergency:`, and the database is `UiObservability:<namespace>`.
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## Reference Documents
|
|
498
|
+
|
|
499
|
+
- [Attribute reference](docs/attributes.md): each attribute that the library writes, and its type.
|
|
500
|
+
- [Browser support](docs/browser-support.md): the browser APIs that the library uses, and the fallback for each.
|
|
501
|
+
- [Threat model](docs/threat-model.md): the trust boundaries, the threats and the controls.
|
|
502
|
+
- [Runtime policies and migration](docs/runtime-policies.md): the defaults, the overrides, security-context rotation, registered bus sources, health and the upgrade steps for 0.9.5.
|
|
405
503
|
|
|
406
504
|
---
|
|
407
505
|
|
|
@@ -409,17 +507,19 @@ IndexedDB holds undelivered batches with `storage: "auto"` or `"indexeddb"`.
|
|
|
409
507
|
|
|
410
508
|
- **Code splitting:** The main chunk holds the logger, the record builder and the console sink. The delivery stack loads only when you set an endpoint. The bus loads only when the context needs it. Each capture module loads only when you enable it.
|
|
411
509
|
- **Document singleton:** The library keeps the runtime at `globalThis[Symbol.for("ui-observability.runtime")]`. Federated microfrontends and separate bundles share one buffer, one sequence and one transport.
|
|
412
|
-
- **One sender:** Iframes, workers and OpenFin views find the nearest long-lived context. They forward their records to it over the bus. That context batches, stores and sends for all of them.
|
|
510
|
+
- **One sender:** Iframes, workers and OpenFin views find the nearest long-lived context. They forward their records to it over the bus. That context batches, stores and sends for all of them. By default, a parent accepts only the frames and workers that it registers with `registerFrame()` and `registerWorker()`. A frame that knows its owner relays the records of its own children.
|
|
511
|
+
- **One sender for each tab:** Each top-level tab or window has its own sender. Two tabs of one origin send their records separately. They have the same `session.id` and a different `tab.id`. A retry of stored batches runs in one tab at a time, under a Web Lock for each persistence namespace.
|
|
413
512
|
- **Five correlation ids:** Each record carries `session.id`, `tab.id`, `context.id`, `journey.id` and `trace_id`.
|
|
414
513
|
- **Durability and exit flush:** The library stores a batch that fails to send, in IndexedDB or localStorage. It sends the batch again with exponential backoff and jitter. When the document becomes hidden, the library runs a normal flush with the headers, gzip and retry. While the document is hidden, a send of 60 KB or less uses `keepalive`. A mobile OS can stop a hidden page with no `pagehide`. On `pagehide`, `freeze` or OpenFin close, it sends pending records with `navigator.sendBeacon` if they are below 60 KB. With `headers`, it uses a keepalive fetch with the last headers, because a beacon cannot set a header. A larger payload goes to the emergency queue. `shutdown()` runs a normal flush before the exit flush. An action is an audit fact. When storage is over `retention.maxBatches` or over the quota of the browser, it removes the batches without an action first. Before startup, the hold buffers keep up to 2000 actions. The 500-record limit applies only to other records. `onDrop` tells the app about each loss.
|
|
514
|
+
- **Server (Node):** On Node, for example during server-side rendering, the library runs console-only. It installs no capture, keeps the ids in memory, uses no storage and has no exit flush. If you set `endpoint`, `metricsEndpoint`, `tracesEndpoint` or `transport`, it reports `config.invalid` one time.
|
|
415
515
|
- **One library version on a page:** If a copy of another version owns the page runtime, this copy runs console-only. It installs no capture and reports `runtime.version_mismatch`. Load one version of the library on the page.
|
|
416
|
-
- **Emergency queue:** The emergency queue is best effort. It writes to `localStorage` synchronously, because no other storage works while the page unloads. If the browser refuses the write, the library reports `storage.quota_exceeded`. The library then loses the batch.
|
|
417
|
-
- **Configuration after startup:** A second `configure()` call merges
|
|
516
|
+
- **Emergency queue:** The emergency queue is best effort. With `storage: "memory"` or `"none"`, the exit flush does not use it. A batch that it cannot send is then lost, and `onDrop` reports `not_stored`. It writes to `localStorage` synchronously, because no other storage works while the page unloads. If the browser refuses the write, the library reports `storage.quota_exceeded`. The library then loses the batch.
|
|
517
|
+
- **Configuration after startup:** A second `configure()` call merges accepted options into an unlocked live runtime. Isolation is on by default. Then `configure()` refuses changes to delivery settings and to the context ID. It keeps the values in force, reports `config.invalid` and applies the other settings. Use `rotateSecurityContext()` for these changes. `securityContext.isolation: false` restores ordinary mutable routing. The runtime also refuses these 5 changes and reports `config.invalid` for each:
|
|
418
518
|
- A change to `storage`. The stored batches stay in the adapter that the runtime built at startup.
|
|
419
519
|
- A change to `identity`. The ids exist from startup.
|
|
420
520
|
- A change to `batching` or `retention` after the delivery stack loads. The stack reads them one time.
|
|
421
521
|
- A change to `limits` or `journey.maxAgeMs` after the first `configure()`. The record builder and the journey engine read them one time.
|
|
422
|
-
- An `endpoint` change to `null` or `""` after the delivery stack loads. Without an endpoint, the stored batches would be lost.
|
|
522
|
+
- An `endpoint` change to `null` or `""` after the delivery stack loads. Without an endpoint, the stored batches would be lost. With isolation off, a change to another endpoint URL is accepted.
|
|
423
523
|
- **Deterministic sampling:** FNV-1a hashing applies one keep rate to a whole journey. An error and an explicit action are always kept.
|
|
424
524
|
|
|
425
525
|
---
|
|
@@ -444,9 +544,11 @@ The ingest server must meet these requirements:
|
|
|
444
544
|
3. **Deduplication:** Deduplicate on the `X-UiObs-Batch-Id` header and the `uiobs_batch_id` query parameter. Keep the ids for at least 24 hours.
|
|
445
545
|
4. **Throttling:** Return `429` or `503` with `Retry-After`. Expose the header with `Access-Control-Expose-Headers: retry-after`. The library waits 60 s at most.
|
|
446
546
|
5. **Status codes:** `200`, `202` and `204` accept the batch. `413` makes the library split the batch. With a `headers` function, a `401` or `403` gets one more send with new headers. The library drops a batch that gets any other `4xx`.
|
|
447
|
-
6. **Metrics
|
|
547
|
+
6. **Metrics and traces endpoints (optional):** With `metricsEndpoint`, the library sends each batch of metric records there as an OTLP/JSON `ExportMetricsServiceRequest`. With `tracesEndpoint`, it sends each batch of span records there as an OTLP/JSON `ExportTraceServiceRequest`. The rules 1 to 5 also apply to these endpoints. A throttle or a failed batch of one endpoint does not hold back the batches of another endpoint. `headers` applies to each endpoint. Each point is a delta from the previous point of its attribute set. A histogram point with a negative value has no `sum`.
|
|
448
548
|
7. **Remote sampling (optional):** To send sampling rules, add `X-UiObs-Sampling` to a `2xx` answer. Expose the header with `Access-Control-Expose-Headers: x-uiobs-sampling`.
|
|
449
549
|
|
|
550
|
+
`tools/reference-collector.mjs` implements each rule with no dependencies. It is not part of the package. Run `node tools/reference-collector.mjs`. Set `ALLOWED_ORIGINS` to the origins of your app. Set `UPSTREAM_URL` to an OTLP/HTTP collector, for example `http://localhost:4318`, to forward each OTLP batch there. The file lists the other settings: `PORT`, `AUTH_TOKEN`, `SAMPLING_RULES`, `MAX_BODY_BYTES` and `MAX_REQUESTS_PER_SECOND`.
|
|
551
|
+
|
|
450
552
|
---
|
|
451
553
|
|
|
452
554
|
## Development
|
|
@@ -454,11 +556,12 @@ The ingest server must meet these requirements:
|
|
|
454
556
|
```bash
|
|
455
557
|
npm install
|
|
456
558
|
npm run dev # Playground, mock ingest server and iframe host
|
|
457
|
-
npm run verify # Format check,
|
|
559
|
+
npm run verify # Format check, typecheck, build, lint, peer, size and dev-server checks, tests
|
|
458
560
|
```
|
|
459
561
|
|
|
460
562
|
- Vanilla playground: `http://localhost:5173/playground/vanilla/index.html`
|
|
461
|
-
- Mock ingest server: `http://localhost:8787`. It accepts `/v1/logs` and `/v1/
|
|
563
|
+
- Mock ingest server: `http://localhost:8787`. It accepts `/v1/logs`, `/v1/metrics` and `/v1/traces`. It prints one line for each record and for each metric point.
|
|
564
|
+
- Cross-origin child frame: `http://localhost:5174`. The vanilla playground registers it and its same-origin child frame before they load.
|
|
462
565
|
- The React example sends its counter, histogram and HTTP duration points to `/v1/metrics`.
|
|
463
566
|
|
|
464
567
|
### Example Applications
|