@utk09/ui-observability 0.9.4 → 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 +45 -0
- package/README.md +122 -94
- package/dist/batch-BQFtb3i5.cjs +2 -0
- package/dist/batch-BQFtb3i5.cjs.map +1 -0
- package/dist/{batch-D-4xl7op.js → batch-BUJh-1jZ.js} +7 -5
- 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/storm.d.ts +2 -1
- package/dist/capture/types.d.ts +2 -0
- package/dist/{console-Boqa7new.cjs → console-Ce6heqZZ.cjs} +2 -2
- package/dist/console-Ce6heqZZ.cjs.map +1 -0
- package/dist/{console-BT7mcgU6.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 +29 -9
- 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 +7 -2
- package/dist/core/context.d.ts +2 -0
- package/dist/core/diagnostics.d.ts +11 -3
- package/dist/core/meter.d.ts +6 -1
- package/dist/core/pipeline.d.ts +29 -2
- package/dist/core/record.d.ts +2 -1
- package/dist/core/runtime.d.ts +91 -3
- package/dist/core/sampling.d.ts +3 -1
- package/dist/core/sender.d.ts +35 -1
- 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-BDI96zKc.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 +45 -7
- package/dist/index.js +908 -529
- 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-HgkQUTyS.js → indexeddb-storage-CCA1LvtO.js} +33 -18
- package/dist/indexeddb-storage-CCA1LvtO.js.map +1 -0
- package/dist/{interactions-Ck01cEij.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-DRK0A8u_.js → journey-BUJ4WJxP.js} +12 -12
- package/dist/{journey-DRK0A8u_.js.map → journey-BUJ4WJxP.js.map} +1 -1
- package/dist/{journey-Co9OlzrW.cjs → journey-B_tTnvac.cjs} +2 -2
- package/dist/{journey-Co9OlzrW.cjs.map → journey-B_tTnvac.cjs.map} +1 -1
- 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-ChCar5F8.js → library-request-BKOcaKtQ.js} +2 -2
- package/dist/{library-request-ChCar5F8.js.map → library-request-BKOcaKtQ.js.map} +1 -1
- package/dist/{library-request-gMFOCNcn.cjs → library-request-BaZOi4eg.cjs} +2 -2
- package/dist/{library-request-gMFOCNcn.cjs.map → library-request-BaZOi4eg.cjs.map} +1 -1
- package/dist/{long-frames-Bky6nZDF.cjs → long-frames-CF3qiSAX.cjs} +2 -2
- package/dist/long-frames-CF3qiSAX.cjs.map +1 -0
- package/dist/{long-frames-DDumopji.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 +347 -9
- package/dist/models/drop.d.ts +1 -1
- package/dist/models/health.d.ts +27 -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-BsBZ6_-Q.js → network-DdzXDI3J.js} +18 -16
- 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-4yYjMD-B.js → platform-Bw1btWCT.js} +16 -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-1KqfVBIu.js → remote-rules-DIcC5vVC.js} +3 -3
- package/dist/{remote-rules-1KqfVBIu.js.map → remote-rules-DIcC5vVC.js.map} +1 -1
- package/dist/{remote-rules-BHgEGlYi.cjs → remote-rules-DpFmOef2.cjs} +2 -2
- package/dist/{remote-rules-BHgEGlYi.cjs.map → remote-rules-DpFmOef2.cjs.map} +1 -1
- package/dist/sampling-BVjspJWu.cjs +2 -0
- package/dist/sampling-BVjspJWu.cjs.map +1 -0
- package/dist/{sampling-nYIWP_vP.js → sampling-Cm3WhI0a.js} +26 -36
- package/dist/sampling-Cm3WhI0a.js.map +1 -0
- package/dist/{sanitize-BiUKCUG6.js → sanitize-C-ahCFsG.js} +2 -2
- package/dist/{sanitize-BiUKCUG6.js.map → sanitize-C-ahCFsG.js.map} +1 -1
- package/dist/{sanitize-BxuPSXOk.cjs → sanitize-DHucKGdi.cjs} +2 -2
- package/dist/{sanitize-BxuPSXOk.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/retry-engine.d.ts +7 -2
- package/dist/transport/status-transport.d.ts +17 -0
- package/dist/types-BR9t_w28.js.map +1 -1
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/utils/fixed-window.d.ts +9 -0
- package/dist/utils/identity.d.ts +9 -2
- package/dist/utils/lock.d.ts +8 -0
- package/dist/utils/openfin.d.ts +1 -1
- package/dist/utils/platform.d.ts +3 -1
- 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-C4oF6XZT.cjs +0 -2
- package/dist/batch-C4oF6XZT.cjs.map +0 -1
- package/dist/batch-D-4xl7op.js.map +0 -1
- package/dist/bus-Cyvq-Ngx.js +0 -478
- package/dist/bus-Cyvq-Ngx.js.map +0 -1
- package/dist/bus-rOhVuRee.cjs +0 -2
- package/dist/bus-rOhVuRee.cjs.map +0 -1
- package/dist/console-BT7mcgU6.js.map +0 -1
- package/dist/console-Boqa7new.cjs.map +0 -1
- package/dist/constants-BgRS6MB0.cjs +0 -2
- package/dist/constants-BgRS6MB0.cjs.map +0 -1
- package/dist/constants-L_d5YvvQ.js +0 -160
- package/dist/constants-L_d5YvvQ.js.map +0 -1
- package/dist/errors-BDI96zKc.js.map +0 -1
- package/dist/errors-_xEsCVXn.cjs +0 -3
- package/dist/errors-_xEsCVXn.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-Bwku7zzN.cjs +0 -2
- package/dist/identity-Bwku7zzN.cjs.map +0 -1
- package/dist/identity-Dtv917nz.js +0 -98
- package/dist/identity-Dtv917nz.js.map +0 -1
- package/dist/indexeddb-storage-Cvavrf-y.cjs +0 -2
- package/dist/indexeddb-storage-Cvavrf-y.cjs.map +0 -1
- package/dist/indexeddb-storage-HgkQUTyS.js.map +0 -1
- package/dist/interactions-Bhe1ft8P.cjs +0 -2
- package/dist/interactions-Bhe1ft8P.cjs.map +0 -1
- package/dist/interactions-Ck01cEij.js.map +0 -1
- package/dist/log-record-cwFiLyPY.js +0 -17
- package/dist/log-record-cwFiLyPY.js.map +0 -1
- package/dist/log-record-jX9eWUP8.cjs +0 -2
- package/dist/log-record-jX9eWUP8.cjs.map +0 -1
- package/dist/long-frames-Bky6nZDF.cjs.map +0 -1
- package/dist/long-frames-DDumopji.js.map +0 -1
- package/dist/network-BsBZ6_-Q.js.map +0 -1
- package/dist/network-_4csBGBM.cjs +0 -2
- package/dist/network-_4csBGBM.cjs.map +0 -1
- package/dist/platform-4yYjMD-B.js.map +0 -1
- package/dist/platform-o7r1ocOu.cjs +0 -2
- package/dist/platform-o7r1ocOu.cjs.map +0 -1
- package/dist/sampling-C4my-ma0.cjs +0 -2
- package/dist/sampling-C4my-ma0.cjs.map +0 -1
- package/dist/sampling-nYIWP_vP.js.map +0 -1
- package/dist/sender-6vrT9fFL.cjs +0 -3
- package/dist/sender-6vrT9fFL.cjs.map +0 -1
- package/dist/sender-DFQMF39P.js +0 -1351
- package/dist/sender-DFQMF39P.js.map +0 -1
- package/dist/storm-6YYbXzT_.cjs +0 -2
- package/dist/storm-6YYbXzT_.cjs.map +0 -1
- package/dist/storm-CfO0Sam2.js +0 -10
- package/dist/storm-CfO0Sam2.js.map +0 -1
- package/dist/web-socket-Ar4cZxmd.js +0 -102
- package/dist/web-socket-Ar4cZxmd.js.map +0 -1
- package/dist/web-socket-BwJdwSHl.cjs +0 -2
- package/dist/web-socket-BwJdwSHl.cjs.map +0 -1
package/dist/models/config.d.ts
CHANGED
|
@@ -142,14 +142,46 @@ export interface SamplingOptions {
|
|
|
142
142
|
}
|
|
143
143
|
/** Bus settings. They control how this context finds, trusts, and sends messages to others. */
|
|
144
144
|
export interface BusOptions {
|
|
145
|
+
/**
|
|
146
|
+
* Rule for accepting child windows. "registered" requires a window registration.
|
|
147
|
+
* "trusted-origin" accepts child windows from a trusted origin.
|
|
148
|
+
* @default "registered"
|
|
149
|
+
*/
|
|
150
|
+
sourcePolicy: "registered" | "trusted-origin";
|
|
151
|
+
/**
|
|
152
|
+
* Message checks. "strict" checks each record and control message.
|
|
153
|
+
* "envelope" checks the protocol tag only.
|
|
154
|
+
* @default "strict"
|
|
155
|
+
*/
|
|
156
|
+
validation: "strict" | "envelope";
|
|
157
|
+
/**
|
|
158
|
+
* Maximum encoded bytes in one message. Set 0 for no size limit.
|
|
159
|
+
* @default 262144
|
|
160
|
+
*/
|
|
161
|
+
maxMessageBytes: number;
|
|
162
|
+
/**
|
|
163
|
+
* Maximum records in one message. Set 0 for no record limit.
|
|
164
|
+
* @default 100
|
|
165
|
+
*/
|
|
166
|
+
maxRecordsPerMessage: number;
|
|
167
|
+
/**
|
|
168
|
+
* Maximum messages from one source in one second. Set 0 for no rate limit.
|
|
169
|
+
* @default 100
|
|
170
|
+
*/
|
|
171
|
+
maxMessagesPerSecond: number;
|
|
172
|
+
/**
|
|
173
|
+
* Maximum named sources to track, for example OpenFin identities. Set 0 for no limit.
|
|
174
|
+
* @default 256
|
|
175
|
+
*/
|
|
176
|
+
maxTrackedSources: number;
|
|
145
177
|
/**
|
|
146
178
|
* This context's role.
|
|
147
179
|
* @default "auto"
|
|
148
180
|
*/
|
|
149
181
|
mode: BusMode;
|
|
150
182
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
183
|
+
* Additional trusted parent origins. With sourcePolicy "trusted-origin", the list also
|
|
184
|
+
* permits child origins. A registered child uses the exact origin in its registration.
|
|
153
185
|
* The library does not accept "null". A sandboxed frame must set `mode: "sender"`.
|
|
154
186
|
* @default []
|
|
155
187
|
*/
|
|
@@ -286,11 +318,91 @@ export interface LimitOptions {
|
|
|
286
318
|
}
|
|
287
319
|
/** Console method that the console capture can wrap. */
|
|
288
320
|
export type CapturedConsoleMethod = "error" | "warn" | "info" | "log";
|
|
321
|
+
/** Click settings. An object turns on capture. With true, capture uses the defaults below. */
|
|
322
|
+
export interface InteractionOptions {
|
|
323
|
+
/**
|
|
324
|
+
* Record the textContent of the clicked element.
|
|
325
|
+
* @default false
|
|
326
|
+
*/
|
|
327
|
+
text?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Record a DOM selector. Its attributes can identify a user or an account.
|
|
330
|
+
* @default false
|
|
331
|
+
*/
|
|
332
|
+
selector?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* CSS selector for regions to exclude. Set null to include all regions.
|
|
335
|
+
* @default "[data-observability-ignore]"
|
|
336
|
+
*/
|
|
337
|
+
ignoreSelector?: string | null;
|
|
338
|
+
/**
|
|
339
|
+
* Maximum click text length, in characters.
|
|
340
|
+
* @default 50
|
|
341
|
+
*/
|
|
342
|
+
maxTextChars?: number;
|
|
343
|
+
/**
|
|
344
|
+
* Attribute that names the click action, for example "data-testid". The closest element with
|
|
345
|
+
* the attribute gives the breadcrumb message. Use letters, digits, hyphens and underscores.
|
|
346
|
+
* @default "data-observability-action"
|
|
347
|
+
*/
|
|
348
|
+
actionAttribute?: string;
|
|
349
|
+
}
|
|
350
|
+
/** Cache settings. A logger that the app holds stays valid after removal from the cache. */
|
|
351
|
+
export interface LoggerCacheOptions {
|
|
352
|
+
/**
|
|
353
|
+
* Maximum cached loggers. The cache removes the least recently used logger first.
|
|
354
|
+
* Set 0 for no cache. Set null for no cache limit.
|
|
355
|
+
* @default 256
|
|
356
|
+
*/
|
|
357
|
+
maxEntries: number | null;
|
|
358
|
+
}
|
|
359
|
+
/** Identity of one delivery context. Do not put secrets or personal data in the id. */
|
|
360
|
+
export interface SecurityContextOptions {
|
|
361
|
+
/** Stable id for delivery after a page reload. An empty id gives this runtime a new id. */
|
|
362
|
+
id: string;
|
|
363
|
+
/**
|
|
364
|
+
* Keep stored batches in separate contexts. With true, change delivery settings through
|
|
365
|
+
* rotateSecurityContext() instead of configure().
|
|
366
|
+
* @default true
|
|
367
|
+
*/
|
|
368
|
+
isolation: boolean;
|
|
369
|
+
}
|
|
370
|
+
/** Delivery settings that the runtime replaces together when the security context changes. */
|
|
371
|
+
export type DeliveryOptions = Pick<ObservabilityConfig, "endpoint" | "metricsEndpoint" | "tracesEndpoint" | "headers" | "credentials" | "transport" | "transportOnExit">;
|
|
372
|
+
/** New security context. A delivery field that is not supplied resets to its default. */
|
|
373
|
+
export interface SecurityContextUpdate {
|
|
374
|
+
/** New delivery context id. If not supplied, the runtime makes a new id. */
|
|
375
|
+
id?: string;
|
|
376
|
+
/** New delivery settings. A field that is not supplied resets to its default. */
|
|
377
|
+
delivery: DeliveryOptions;
|
|
378
|
+
/** New ambient attributes. If not supplied, the runtime removes the old attributes. */
|
|
379
|
+
context?: Record<string, unknown>;
|
|
380
|
+
}
|
|
381
|
+
/** Policy for old records. */
|
|
382
|
+
export interface SecurityContextRotationOptions {
|
|
383
|
+
/**
|
|
384
|
+
* Rule for old records. "discard" removes them. "flush" tries delivery, then removes them.
|
|
385
|
+
* "retain" keeps them in the old context. "carry" gives them to the new context.
|
|
386
|
+
* @default "discard"
|
|
387
|
+
*/
|
|
388
|
+
pending?: "discard" | "flush" | "retain" | "carry";
|
|
389
|
+
/**
|
|
390
|
+
* Maximum wait for a flush of old records, in milliseconds.
|
|
391
|
+
* @default 5000
|
|
392
|
+
*/
|
|
393
|
+
timeoutMs?: number;
|
|
394
|
+
}
|
|
289
395
|
/**
|
|
290
396
|
* What the library instruments automatically. By default, only `errors` and `rejections`
|
|
291
397
|
* are on.
|
|
292
398
|
*/
|
|
293
399
|
export interface CaptureOptions {
|
|
400
|
+
/**
|
|
401
|
+
* Changes a URL before capture records it. Applies to page, HTTP, resource and WebSocket URLs.
|
|
402
|
+
* @param url Original URL, before the default URL changes.
|
|
403
|
+
* @returns URL to record. Null, an invalid result or an exception gives an empty URL.
|
|
404
|
+
*/
|
|
405
|
+
urlTransform?: (url: string) => string | null;
|
|
294
406
|
/**
|
|
295
407
|
* Log uncaught errors from `window.onerror`.
|
|
296
408
|
* @default true
|
|
@@ -326,7 +438,7 @@ export interface CaptureOptions {
|
|
|
326
438
|
* Log clicks and other interactions as breadcrumbs.
|
|
327
439
|
* @default false
|
|
328
440
|
*/
|
|
329
|
-
interactions: boolean;
|
|
441
|
+
interactions: boolean | InteractionOptions;
|
|
330
442
|
/**
|
|
331
443
|
* Log route changes, including single-page-application navigation.
|
|
332
444
|
* @default false
|
|
@@ -429,6 +541,10 @@ export interface ResolvedConsole {
|
|
|
429
541
|
export type BatchKind = "logs" | "metrics" | "traces";
|
|
430
542
|
/** One batch that the library gives to a custom transport. */
|
|
431
543
|
export interface TransportRequest {
|
|
544
|
+
/** Abort signal for this delivery context. A custom transport must check it to cancel its work. */
|
|
545
|
+
signal?: AbortSignal;
|
|
546
|
+
/** Delivery context of this batch. */
|
|
547
|
+
routingContextId?: string;
|
|
432
548
|
/** Kind of the batch. Send a "metrics" body to your metrics endpoint, and a "traces" body to your traces endpoint. */
|
|
433
549
|
kind: BatchKind;
|
|
434
550
|
/** Serialized batch from the configured serializer. The library does not compress it. */
|
|
@@ -472,8 +588,207 @@ export type Transport = (request: TransportRequest) => Promise<TransportResponse
|
|
|
472
588
|
* @returns True if the channel accepted the batch. False puts the batch in the emergency queue.
|
|
473
589
|
*/
|
|
474
590
|
export type ExitTransport = (request: TransportRequest) => boolean;
|
|
591
|
+
/** Request timing, retry timing and delivery capacity. Durations are in milliseconds. */
|
|
592
|
+
export interface DeliveryPolicy {
|
|
593
|
+
/**
|
|
594
|
+
* Maximum wait for one request. The value must be at least 1.
|
|
595
|
+
* @default 15000
|
|
596
|
+
*/
|
|
597
|
+
requestTimeoutMs: number;
|
|
598
|
+
/**
|
|
599
|
+
* Maximum requests that have not completed. The value must be at least 1.
|
|
600
|
+
* @default 2
|
|
601
|
+
*/
|
|
602
|
+
maxConcurrentRequests: number;
|
|
603
|
+
/**
|
|
604
|
+
* First retry delay. Set 0 for an immediate retry.
|
|
605
|
+
* @default 2000
|
|
606
|
+
*/
|
|
607
|
+
retryBaseDelayMs: number;
|
|
608
|
+
/**
|
|
609
|
+
* Maximum retry delay. It must be at least retryBaseDelayMs.
|
|
610
|
+
* @default 60000
|
|
611
|
+
*/
|
|
612
|
+
retryMaxDelayMs: number;
|
|
613
|
+
/**
|
|
614
|
+
* Wait before the next check for stored work.
|
|
615
|
+
* @default 30000
|
|
616
|
+
*/
|
|
617
|
+
retryIdleDelayMs: number;
|
|
618
|
+
/**
|
|
619
|
+
* Maximum batches in one delivery pass. The value must be at least 1.
|
|
620
|
+
* @default 20
|
|
621
|
+
*/
|
|
622
|
+
batchesPerDrain: number;
|
|
623
|
+
}
|
|
624
|
+
/** Record and byte limits for the live delivery buffers. */
|
|
625
|
+
export interface BufferingPolicy {
|
|
626
|
+
/**
|
|
627
|
+
* Maximum records in the buffers and requests. Set 0 for no record limit.
|
|
628
|
+
* @default 10000
|
|
629
|
+
*/
|
|
630
|
+
maxPendingRecords: number;
|
|
631
|
+
/**
|
|
632
|
+
* Maximum encoded JSON bytes in the buffers and requests. Set 0 for no byte limit.
|
|
633
|
+
* @default 16777216
|
|
634
|
+
*/
|
|
635
|
+
maxPendingBytes: number;
|
|
636
|
+
/**
|
|
637
|
+
* Rule when a new record does not fit. Remove old records, drop the new record, or try storage.
|
|
638
|
+
* @default "drop-oldest"
|
|
639
|
+
*/
|
|
640
|
+
overflow: "drop-oldest" | "drop-newest" | "persist";
|
|
641
|
+
}
|
|
642
|
+
/** Metric capacity in one collection interval. */
|
|
643
|
+
export interface MetricsPolicy {
|
|
644
|
+
/**
|
|
645
|
+
* Maximum histogram boundaries. Set 0 for no limit.
|
|
646
|
+
* @default 50
|
|
647
|
+
*/
|
|
648
|
+
maxHistogramBoundaries: number;
|
|
649
|
+
/**
|
|
650
|
+
* Maximum attribute sets per instrument. Extra sets use the overflow set. Set 0 for no limit.
|
|
651
|
+
* @default 100
|
|
652
|
+
*/
|
|
653
|
+
maxSeries: number;
|
|
654
|
+
/**
|
|
655
|
+
* Maximum instrument names. Drop extra names. Set 0 for no limit.
|
|
656
|
+
* @default 1000
|
|
657
|
+
*/
|
|
658
|
+
maxInstruments: number;
|
|
659
|
+
}
|
|
660
|
+
/** Session and trace timing. The runtime sets these values at startup. */
|
|
661
|
+
export interface CorrelationPolicy {
|
|
662
|
+
/**
|
|
663
|
+
* Maximum idle time of a stored session, in milliseconds. Set 0 for no idle expiration.
|
|
664
|
+
* @default 1800000
|
|
665
|
+
*/
|
|
666
|
+
sessionIdleMs: number;
|
|
667
|
+
/**
|
|
668
|
+
* Minimum wait between session activity writes, in milliseconds. Set 0 to write each time.
|
|
669
|
+
* @default 60000
|
|
670
|
+
*/
|
|
671
|
+
sessionTouchMs: number;
|
|
672
|
+
/**
|
|
673
|
+
* Maximum idle time of an ambient trace, in milliseconds. Set 0 for no idle expiration.
|
|
674
|
+
* @default 300000
|
|
675
|
+
*/
|
|
676
|
+
traceMaxAgeMs: number;
|
|
677
|
+
}
|
|
678
|
+
/** Rules for diagnostic reports and the console fallback. */
|
|
679
|
+
export interface DiagnosticsPolicy {
|
|
680
|
+
/**
|
|
681
|
+
* Minimum wait between reports of one code, in milliseconds. Set 0 to report each event.
|
|
682
|
+
* @default 1000
|
|
683
|
+
*/
|
|
684
|
+
throttleMs: number;
|
|
685
|
+
/**
|
|
686
|
+
* Print a fixed warning if onDiagnostic throws. Do not print the exception.
|
|
687
|
+
* @default false
|
|
688
|
+
*/
|
|
689
|
+
consoleFallback: boolean;
|
|
690
|
+
}
|
|
691
|
+
/** Application storage settings. The runtime sets these values at startup. */
|
|
692
|
+
export interface PersistencePolicy {
|
|
693
|
+
/**
|
|
694
|
+
* Namespace for batch storage and emergency queues. An empty value uses the previous storage keys.
|
|
695
|
+
* @default ""
|
|
696
|
+
*/
|
|
697
|
+
namespace: string;
|
|
698
|
+
}
|
|
699
|
+
/** Resource and page fields that the SDK records. */
|
|
700
|
+
export interface MetadataPolicy {
|
|
701
|
+
/**
|
|
702
|
+
* Record the page URL. With false, page.url is empty.
|
|
703
|
+
* @default true
|
|
704
|
+
*/
|
|
705
|
+
pageUrl: boolean;
|
|
706
|
+
/**
|
|
707
|
+
* Include browser.user_agent in resource attributes.
|
|
708
|
+
* @default true
|
|
709
|
+
*/
|
|
710
|
+
userAgent: boolean;
|
|
711
|
+
/**
|
|
712
|
+
* Include the OpenFin application uuid and window name in resource attributes.
|
|
713
|
+
* @default true
|
|
714
|
+
*/
|
|
715
|
+
openfin: boolean;
|
|
716
|
+
}
|
|
717
|
+
/** Capture capacity, duplicate checks and rate limits. */
|
|
718
|
+
export interface CapturePolicy {
|
|
719
|
+
/**
|
|
720
|
+
* Maximum breadcrumbs to keep. Set 0 to keep none.
|
|
721
|
+
* @default 50
|
|
722
|
+
*/
|
|
723
|
+
breadcrumbs: number;
|
|
724
|
+
/**
|
|
725
|
+
* Time to suppress repeated errors, in milliseconds. Set 0 to report each error.
|
|
726
|
+
* @default 5000
|
|
727
|
+
*/
|
|
728
|
+
errorDedupeMs: number;
|
|
729
|
+
/**
|
|
730
|
+
* Maximum error signatures to keep for duplicate checks. Set 0 for no limit.
|
|
731
|
+
* @default 200
|
|
732
|
+
*/
|
|
733
|
+
maxErrorSignatures: number;
|
|
734
|
+
/**
|
|
735
|
+
* Maximum captured errors in one window. Set 0 for no limit.
|
|
736
|
+
* @default 20
|
|
737
|
+
*/
|
|
738
|
+
errorsPerWindow: number;
|
|
739
|
+
/**
|
|
740
|
+
* Maximum captured console records in one window. Set 0 for no limit.
|
|
741
|
+
* @default 20
|
|
742
|
+
*/
|
|
743
|
+
consolePerWindow: number;
|
|
744
|
+
/**
|
|
745
|
+
* Maximum long frames in one window. Set 0 for no limit.
|
|
746
|
+
* @default 20
|
|
747
|
+
*/
|
|
748
|
+
longFramesPerWindow: number;
|
|
749
|
+
/**
|
|
750
|
+
* Maximum WebSocket events in one window. Set 0 for no limit.
|
|
751
|
+
* @default 20
|
|
752
|
+
*/
|
|
753
|
+
webSocketPerWindow: number;
|
|
754
|
+
/**
|
|
755
|
+
* Rate limit window, in milliseconds. Set 0 to reset the window for each event.
|
|
756
|
+
* @default 10000
|
|
757
|
+
*/
|
|
758
|
+
windowMs: number;
|
|
759
|
+
/**
|
|
760
|
+
* Maximum pipeline ERROR and FATAL records in one window. Set 0 for no limit.
|
|
761
|
+
* @default 500
|
|
762
|
+
*/
|
|
763
|
+
errorCeiling: number;
|
|
764
|
+
}
|
|
475
765
|
/** Options passed to `configure()`. */
|
|
476
766
|
export interface ObservabilityConfig {
|
|
767
|
+
/** Capture capacity and rate limits. */
|
|
768
|
+
capturePolicy?: Partial<CapturePolicy>;
|
|
769
|
+
/** Resource and page fields to record. */
|
|
770
|
+
metadata?: Partial<MetadataPolicy>;
|
|
771
|
+
/** Application storage namespace. */
|
|
772
|
+
persistence?: Partial<PersistencePolicy>;
|
|
773
|
+
/** Diagnostic report and console fallback settings. */
|
|
774
|
+
diagnostics?: Partial<DiagnosticsPolicy>;
|
|
775
|
+
/** Session and trace timing. */
|
|
776
|
+
correlation?: Partial<CorrelationPolicy>;
|
|
777
|
+
/** Metric capacity in one interval. */
|
|
778
|
+
metrics?: Partial<MetricsPolicy>;
|
|
779
|
+
/** Live buffer capacity and the overflow rule. */
|
|
780
|
+
buffering?: Partial<BufferingPolicy>;
|
|
781
|
+
/** Request timing and delivery capacity. */
|
|
782
|
+
delivery?: Partial<DeliveryPolicy>;
|
|
783
|
+
/**
|
|
784
|
+
* Refuse changes through configure(). Call setConfigurationLocked(false) to permit changes again.
|
|
785
|
+
* @default false
|
|
786
|
+
*/
|
|
787
|
+
lockConfiguration?: boolean;
|
|
788
|
+
/** Logger cache capacity. The app can change it until configuration is locked. */
|
|
789
|
+
loggerCache?: Partial<LoggerCacheOptions>;
|
|
790
|
+
/** Delivery identity and isolation rule. Use rotateSecurityContext() to change the identity. */
|
|
791
|
+
securityContext?: Partial<SecurityContextOptions>;
|
|
477
792
|
/**
|
|
478
793
|
* Ingest endpoint URL. Set `null` for console-only mode.
|
|
479
794
|
* In console-only mode, the library sends nothing. It writes records to the console
|
|
@@ -623,8 +938,9 @@ export interface ObservabilityConfig {
|
|
|
623
938
|
/**
|
|
624
939
|
* Gives attributes for each record that the library builds. Its values override `setContext()`
|
|
625
940
|
* values. The logger scope and the call payload override its values. The library calls it for
|
|
626
|
-
* each record
|
|
627
|
-
*
|
|
941
|
+
* each built record. This includes records used only for the console or breadcrumbs.
|
|
942
|
+
* Keep it fast and synchronous. If it throws or returns a value that is not an object,
|
|
943
|
+
* it adds nothing to the record.
|
|
628
944
|
* @returns The attributes, or undefined for none.
|
|
629
945
|
*/
|
|
630
946
|
contextProvider?: () => Record<string, unknown> | undefined;
|
|
@@ -635,9 +951,9 @@ export interface ObservabilityConfig {
|
|
|
635
951
|
*/
|
|
636
952
|
processors?: ((record: LogRecord) => LogRecord | null)[];
|
|
637
953
|
/**
|
|
638
|
-
*
|
|
954
|
+
* Changes or drops a record before the SDK prints or sends it. If the hook throws or returns a
|
|
639
955
|
* value that is not a record, the library drops the record.
|
|
640
|
-
* @param record
|
|
956
|
+
* @param record Record to process. It can be used only for the console or breadcrumbs.
|
|
641
957
|
* @returns The record to send, or `null` to drop it.
|
|
642
958
|
*/
|
|
643
959
|
redact?: (record: LogRecord) => LogRecord | null;
|
|
@@ -658,6 +974,28 @@ export interface ObservabilityConfig {
|
|
|
658
974
|
}
|
|
659
975
|
/** Fully resolved configuration that the runtime holds. */
|
|
660
976
|
export interface ResolvedConfig {
|
|
977
|
+
/** Capture capacity and rate limits. */
|
|
978
|
+
capturePolicy: CapturePolicy;
|
|
979
|
+
/** Resource and page fields to record. */
|
|
980
|
+
metadata: MetadataPolicy;
|
|
981
|
+
/** Application storage namespace. */
|
|
982
|
+
persistence: PersistencePolicy;
|
|
983
|
+
/** Diagnostic report and console fallback settings. */
|
|
984
|
+
diagnostics: DiagnosticsPolicy;
|
|
985
|
+
/** Session and trace timing. */
|
|
986
|
+
correlation: CorrelationPolicy;
|
|
987
|
+
/** Metric capacity in one interval. */
|
|
988
|
+
metrics: MetricsPolicy;
|
|
989
|
+
/** Live buffer capacity and the overflow rule. */
|
|
990
|
+
buffering: BufferingPolicy;
|
|
991
|
+
/** Request timing and delivery capacity. */
|
|
992
|
+
delivery: DeliveryPolicy;
|
|
993
|
+
/** True if configure() must refuse changes to the active settings. */
|
|
994
|
+
lockConfiguration: boolean;
|
|
995
|
+
/** Capacity of the logger cache. */
|
|
996
|
+
loggerCache: LoggerCacheOptions;
|
|
997
|
+
/** Active delivery context id and isolation rule. */
|
|
998
|
+
securityContext: SecurityContextOptions;
|
|
661
999
|
/** Ingest endpoint URL, or null in console-only mode. */
|
|
662
1000
|
endpoint: string | null;
|
|
663
1001
|
/** OTLP metrics endpoint URL. An empty string sends metric records as log records. */
|
|
@@ -736,8 +1074,8 @@ export interface ResolvedConfig {
|
|
|
736
1074
|
/** Gives attributes for each record that the library builds. */
|
|
737
1075
|
contextProvider?: ObservabilityConfig["contextProvider"];
|
|
738
1076
|
/**
|
|
739
|
-
*
|
|
740
|
-
* @param record
|
|
1077
|
+
* Changes or drops a record before the SDK prints or sends it.
|
|
1078
|
+
* @param record Record to process. It can be used only for the console or breadcrumbs.
|
|
741
1079
|
* @returns The record to send, or `null` to drop it.
|
|
742
1080
|
*/
|
|
743
1081
|
redact?: ObservabilityConfig["redact"];
|
package/dist/models/drop.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { LogRecord } from "./log-record";
|
|
|
13
13
|
* - "not_stored": storage did not keep a batch after a failed send. The cause is a write error or
|
|
14
14
|
* `storage: "none"`.
|
|
15
15
|
*/
|
|
16
|
-
export type LossReason = "buffer_full" | "expired" | "over_capacity" | "quota" | "max_attempts" | "rejected" | "unserializable" | "exit_queue_full" | "load_failed" | "not_stored";
|
|
16
|
+
export type LossReason = "security_context" | "buffer_full" | "expired" | "over_capacity" | "quota" | "max_attempts" | "rejected" | "unserializable" | "exit_queue_full" | "load_failed" | "not_stored";
|
|
17
17
|
/**
|
|
18
18
|
* One report of lost records. The library joins the losses of one reason in one task.
|
|
19
19
|
* Each list holds at most 20 different values.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DeliveryStats } from "./stats";
|
|
2
|
+
import type { BusOptions, LoggerCacheOptions, SecurityContextOptions } from "./config";
|
|
3
|
+
/** State of this SDK copy. A configured console-only runtime can have the status "ready". */
|
|
4
|
+
export interface ObservabilityHealth extends DeliveryStats {
|
|
5
|
+
/** Version of this SDK copy. */
|
|
6
|
+
sdkVersion: string;
|
|
7
|
+
/** Version of a different SDK copy that owns the page runtime, or null. */
|
|
8
|
+
owningSdkVersion: string | null;
|
|
9
|
+
/** Current runtime state. A configured console-only runtime can be ready. */
|
|
10
|
+
status: "starting" | "ready" | "rotating" | "degraded" | "stopped";
|
|
11
|
+
/** Delivery role of this context. */
|
|
12
|
+
mode: "sender" | "forwarder" | "console-only";
|
|
13
|
+
/** True if the local sender is ready and the runtime has not stopped. */
|
|
14
|
+
senderReady: boolean;
|
|
15
|
+
/** True if configure() cannot change the current settings. */
|
|
16
|
+
configurationLocked: boolean;
|
|
17
|
+
/** Codes of the current runtime or context failures. */
|
|
18
|
+
issues: ("runtime.version_mismatch" | "sender.unavailable" | "security.context_mismatch")[];
|
|
19
|
+
/** Logger cache capacity and the number of cached loggers. */
|
|
20
|
+
loggerCache: LoggerCacheOptions & {
|
|
21
|
+
size: number;
|
|
22
|
+
};
|
|
23
|
+
/** Active delivery context id and isolation rule. */
|
|
24
|
+
securityContext: SecurityContextOptions;
|
|
25
|
+
/** Source, validation and capacity rules of the bus. */
|
|
26
|
+
bus: Pick<BusOptions, "sourcePolicy" | "validation" | "maxMessageBytes" | "maxRecordsPerMessage" | "maxMessagesPerSecond" | "maxTrackedSources">;
|
|
27
|
+
}
|
package/dist/models/storage.d.ts
CHANGED
|
@@ -15,6 +15,19 @@ export interface StorageAdapter {
|
|
|
15
15
|
* @returns Oldest persisted batches.
|
|
16
16
|
*/
|
|
17
17
|
take(limit: number): Promise<LogBatch[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Reads batches of one context without loading batches of other contexts.
|
|
20
|
+
* @param id Delivery context id.
|
|
21
|
+
* @param limit Maximum batches to return.
|
|
22
|
+
* @returns Batches of this context, oldest first.
|
|
23
|
+
*/
|
|
24
|
+
takeContext?(id: string, limit: number): Promise<LogBatch[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Counts batches of one context without loading them.
|
|
27
|
+
* @param id Delivery context id.
|
|
28
|
+
* @returns Number of batches in this context.
|
|
29
|
+
*/
|
|
30
|
+
countContext?(id: string): Promise<number>;
|
|
18
31
|
/**
|
|
19
32
|
* Removes a batch by ID. A call with an unknown ID resolves without error.
|
|
20
33
|
* @param id Batch identifier.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./error-like-gGRx2s36.cjs"),t=require("./library-request-BaZOi4eg.cjs"),n=require("./platform-DBSKTvFn.cjs"),r=require("./patch-BX8KrPCT.cjs"),i=require("./types-C7WNpnG1.cjs");var a=1e3,o={name:`http.client.request.duration`,kind:`histogram`,unit:`s`,boundaries:[.005,.01,.025,.05,.075,.1,.25,.5,.75,1,2.5,5,7.5,10]};function s(t,n,r,i){let a=typeof location<`u`?location.href:void 0,o={"http.request.method":t,"server.address":new URL(n,a).hostname};if(r===0){let t=e.r(i)?i.name:``;return o[`error.type`]=t===``?`_OTHER`:t,o}return o[`http.response.status_code`]=r,r>=400&&(o[`error.type`]=String(r)),o}function c(){return XMLHttpRequest.prototype}function l(e){if(typeof e==`string`)return e;if(e instanceof URL)return e.href;if(typeof e==`object`&&e){let{url:t}=e;if(typeof t==`string`)return t}return String(e)}function u(e,t){let n=t?.method;return n===void 0&&typeof e==`object`&&e&&(n=e.method),f(n??`GET`)}function d(e){return typeof e==`object`&&!(e instanceof URL)&&!(e instanceof Request)}function f(e){return typeof e==`string`?e.toUpperCase():String(e)}var p=class{ctx;name=`network`;installed=!1;restores=[];warnedTransport=!1;constructor(e){this.ctx=e}install(){this.installed||(this.installed=!0,this.ctx.config.capture.fetch&&this.installFetch(),this.ctx.config.capture.xhr&&this.installXhr())}uninstall(){if(this.installed){this.installed=!1;for(let e of this.restores.splice(0))e()}}ignored(e){return t.t()||i.t(e,this.ctx.config.capture.ignoreUrls)}propagates(e){let t=this.ctx.config.capture.propagateTraceHeaderTo;if(t.length===0)return!1;let n=this.ctx.diagnostics.guard(`capture.header_failed`,`The library could not read the origin of a request URL. Only a RegExp target can match it.`,()=>new URL(e,location.href).origin);return t.some(t=>typeof t==`string`?t===n:t.test(e))}installFetch(){if(typeof globalThis.fetch!=`function`)return;let e=!0,t=(e,t)=>this.prepareFetch(e,t),n=(e,t,n,r)=>{this.record(e.method,e.url,t,n,r,e.span,e.routingContextId)},i=r.t(globalThis,`fetch`,r=>{let i=r.bind(globalThis);return async function(r,a){let o=e?t(r,a):void 0;if(!o)return i(r,a);let s=performance.now();try{let e=await i(o.input,o.init);return n(o,e.status,performance.now()-s,void 0),e}catch(e){throw n(o,0,performance.now()-s,e),e}}});this.restores.push(()=>{e=!1,i()})}prepareFetch(e,t){let n=this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not read a fetch request. It sends the request unchanged.`,()=>{let n=l(e);if(!this.ignored(n))return{method:u(e,t),url:n,propagate:this.propagates(n)}});if(!n)return;let{method:r,url:i}=n,a={method:r,url:i,input:e,init:t,routingContextId:this.ctx.config.securityContext.id};if(!n.propagate||d(e))return a;try{let n=this.ctx.tracing.request(),r=Object.entries(n.headers);if(e instanceof Request){let t=new Headers(e.headers);for(let[e,n]of r)t.set(e,n);a.input=new Request(e,{headers:t})}else{let e=new Headers(t?.headers);for(let[t,n]of r)e.set(t,n);a.init={...t,headers:e}}a.span=n.span}catch(n){a.input=e,a.init=t,this.ctx.diagnostics.report(`capture.header_failed`,`The library could not add the traceparent header. It sends the request unchanged.`,{url:i},n)}return a}installXhr(){if(typeof XMLHttpRequest>`u`)return;let e=!0,t=this.ctx,n=e=>this.ignored(e),i=e=>this.propagates(e),a=(e,t,n)=>{this.record(e.method,e.url,t,n,void 0,e.span,e.routingContextId)},o=c(),s=r.t(o,`open`,n=>function(r,i,...a){e&&t.diagnostics.guard(`capture.record_failed`,`The library could not read an XMLHttpRequest. It does not record the request.`,()=>{this.__uiobs={method:f(r),url:l(i),startedAt:0}}),n.apply(this,[r,i,...a])}),u=r.t(o,`send`,r=>function(...o){let s=e?this.__uiobs:void 0;s&&t.diagnostics.guard(`capture.record_failed`,`The library could not record ${s.method} ${s.url}.`,()=>{n(s.url)||(s.startedAt=performance.now(),s.routingContextId=t.config.securityContext.id,this.addEventListener(`loadend`,()=>{a(s,this.status,performance.now()-s.startedAt)},{once:!0}),i(s.url)&&(s.span=m(this,s.url,t)))}),r.apply(this,o)});this.restores.push(()=>{e=!1,s(),u()})}record(e,r,i,c,l,u,d){if(this.ctx.isActive?.()===!1||this.ctx.config.securityContext.isolation&&d!==void 0&&d!==this.ctx.config.securityContext.id)return;let f=n.i(r,this.ctx.config.capture.fullUrls,this.ctx.config.capture.urlTransform,this.ctx.diagnostics);!this.warnedTransport&&t.n()&&(this.warnedTransport=!0,this.ctx.diagnostics.report(`capture.transport_request`,`Network capture saw ${e} ${f} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`)),this.ctx.config.capture.httpMetrics&&this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record the duration of ${e} ${f}.`,()=>{let t=s(e,r,i,l);this.ctx.recordMetric(o,c/a,t)}),u&&this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record the span of ${e} ${f}.`,()=>{let t=Date.now();this.ctx.recordSpan({...u,name:e,kind:`client`,startMs:t-c,endMs:t,error:i===0||i>=400,attributes:{...s(e,r,i,l),"url.full":f}})}),this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record ${e} ${f}.`,()=>{let t=Math.round(c);this.ctx.breadcrumbs.push({t:Date.now(),category:`http`,message:`${e} ${f} ${i===0?`failed`:String(i)}`,data:{durationMs:t}});let n={"http.request.method":e,"url.full":f,"http.response.status_code":i,"http.duration_ms":t};i===0?this.ctx.logger.error(`${e} ${f} failed`,l,n):i>=400?this.ctx.logger.warn(`${e} ${f} returned ${String(i)}`,n):this.ctx.logger.debug(`${e} ${f}`,n)})}};function m(e,t,n){try{let t=n.tracing.request();for(let[n,r]of Object.entries(t.headers))e.setRequestHeader(n,r);return t.span}catch(e){n.diagnostics.report(`capture.header_failed`,`The library could not add the traceparent header. It sends the request unchanged.`,{url:t},e);return}}exports.NetworkCapture=p;
|
|
2
|
+
//# sourceMappingURL=network-CF8UO5PK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-CF8UO5PK.cjs","names":["isErrorLike","isLibraryRequest","matchesAny","patch","recordedUrl","isTransportPending","require_error_like","require_library_request","require_platform","require_patch","require_types","MS_PER_SECOND","HTTP_DURATION","durationAttributes","base","attributes","method","url","status","name","error","xhrMethods","readUrl","input","readFetchMethod","requested","init","toMethod","isForeignInput","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","call","original","startedAt","response","read","trace","injected","headers","key","value","ignored","propagates","meta","proto","restoreOpen","rest","originalOpen","restoreSend","args","addTraceHeaders","originalSend","routingContextId","span","endMs","rounded","xhr"],"sources":["../src/capture/network.ts"],"sourcesContent":["// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record network request outcomes and timing.\n\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { isLibraryRequest, isTransportPending } from \"../utils/library-request\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { ClientSpan } from \"../utils/tracing\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** Milliseconds in one second. The histogram is in seconds, as the OpenTelemetry name gives. */\nconst MS_PER_SECOND = 1000;\n\n/**\n * The HTTP client duration histogram of the OpenTelemetry semantic conventions. Its boundaries\n * are the ones that the conventions advise.\n */\nconst HTTP_DURATION: InstrumentDef = {\n name: \"http.client.request.duration\",\n kind: \"histogram\",\n unit: \"s\",\n boundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],\n};\n\n/**\n * Gives the low-cardinality attributes of one request. The path and the query stay out. Each\n * value of an attribute makes a new series in the backend.\n * @param method Uppercase HTTP method.\n * @param url Request URL.\n * @param status HTTP status code, or 0 when no response came.\n * @param error Failure of a request without a response.\n * @returns The attribute set.\n */\nfunction durationAttributes(\n method: string,\n url: string,\n status: number,\n error: unknown,\n): MetricAttributes {\n // A relative URL needs the page URL as its base. A worker has a location too.\n const base = typeof location !== \"undefined\" ? location.href : undefined;\n const attributes: MetricAttributes = {\n \"http.request.method\": method,\n \"server.address\": new URL(url, base).hostname,\n };\n\n if (status === 0) {\n // A request without a response has the type of its error, for example TypeError.\n const name = isErrorLike(error) ? error.name : \"\";\n attributes[\"error.type\"] = name === \"\" ? \"_OTHER\" : name;\n return attributes;\n }\n\n attributes[\"http.response.status_code\"] = status;\n if (status >= 400) {\n attributes[\"error.type\"] = String(status);\n }\n\n return attributes;\n}\n\n/** Request data that the XHR wrapper keeps from open to send. */\ninterface XhrMeta {\n /** Delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Performance timestamp at send. */\n startedAt: number;\n /** Client span that the traceparent names. */\n span?: ClientSpan;\n}\n\n/** XMLHttpRequest extended with internal telemetry tracking metadata. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: XhrMeta;\n};\n\n/** Unbound prototype methods intercepted on XMLHttpRequest. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** The fetch call to make, and the method and URL to record. */\ninterface FetchPlan {\n /** Delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Input to pass to the original fetch. */\n input: RequestInfo | URL;\n /** Init to pass to the original fetch. */\n init: RequestInit | undefined;\n /** Client span that the traceparent names. */\n span?: ClientSpan;\n}\n\n/**\n * Reads the URL of a fetch input or an XHR URL argument.\n * A Request from another realm fails `instanceof Request`. Its `url` property still works.\n * @param input String, URL, Request, or an object with a text form.\n * @returns The URL.\n * @throws TypeError when the input has no text form. Call it inside a diagnostics guard.\n */\nfunction readUrl(input: unknown): string {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (input instanceof URL) {\n return input.href;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const { url } = input as { url?: unknown };\n if (typeof url === \"string\") {\n return url;\n }\n }\n\n // fetch accepts each value with a text form.\n return String(input);\n}\n\n/**\n * Reads the method of a fetch call. The init method wins over the Request method.\n * @param input Fetch input.\n * @param init Fetch init.\n * @returns Uppercase method. The default is GET.\n */\nfunction readFetchMethod(input: unknown, init: RequestInit | undefined): string {\n let requested: unknown = init?.method;\n\n if (requested === undefined && typeof input === \"object\" && input !== null) {\n requested = (input as { method?: unknown }).method;\n }\n\n return toMethod(requested ?? \"GET\");\n}\n\n/**\n * Tests if a fetch input is an object that is not a Request or a URL of this realm.\n * An example is a Request from an iframe.\n * @param input Fetch input.\n * @returns True for a foreign object.\n */\nfunction isForeignInput(input: unknown): boolean {\n return typeof input === \"object\" && !(input instanceof URL) && !(input instanceof Request);\n}\n\n/**\n * Converts a method argument to text. A method that is not a string does not throw.\n * @param method Method argument of the caller.\n * @returns Uppercase method for a string, or the text form of another value.\n */\nfunction toMethod(method: unknown): string {\n return typeof method === \"string\" ? method.toUpperCase() : String(method);\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Prevents a second wrap on a wrapped function. */\n private installed = false;\n\n /** Restore functions of the installed wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** True after the report of a request during a custom transport call. It reports one time. */\n private warnedTransport = false;\n\n /**\n * @param ctx Capture context containing configuration, diagnostics, logger, breadcrumbs, and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments configured network transport APIs. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /**\n * Restores each host function that still holds the wrapper of this capture.\n * A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n }\n\n /**\n * Tests if a URL matches ignore patterns.\n * @param url Request target URL.\n * @returns True if telemetry must exclude the URL.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Without it, a failed POST\n // makes a log record. That record causes a new POST, and the loop does not stop.\n // A custom transport has no known URL. Its request starts inside the library scope.\n return isLibraryRequest() || matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /**\n * Tests if a request gets the trace headers.\n * @param url Request target URL.\n * @returns True if the URL is in propagateTraceHeaderTo.\n */\n private propagates(url: string): boolean {\n // Add headers only to allowlisted URLs. A traceparent on a third-party request causes\n // a CORS preflight. The third party does not answer it, and its API stops working.\n const targets = this.ctx.config.capture.propagateTraceHeaderTo;\n if (targets.length === 0) {\n return false;\n }\n\n // A string target is an origin. A relative URL resolves against the page.\n const origin = this.ctx.diagnostics.guard(\n \"capture.header_failed\",\n \"The library could not read the origin of a request URL. Only a RegExp target can match it.\",\n () => new URL(url, location.href).origin,\n );\n\n return targets.some((target) =>\n typeof target === \"string\" ? target === origin : target.test(url),\n );\n }\n\n /** Instruments globalThis.fetch with tracing injection and outcome logging. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\") {\n return;\n }\n\n // Uninstall clears the flag. A wrapper that stays in place then only calls the original.\n let active = true;\n const prepare = (input: RequestInfo | URL, init: RequestInit | undefined) =>\n this.prepareFetch(input, init);\n const record = (plan: FetchPlan, status: number, durationMs: number, error: unknown): void => {\n this.record(\n plan.method,\n plan.url,\n status,\n durationMs,\n error,\n plan.span,\n plan.routingContextId,\n );\n };\n\n const restore = patch(globalThis, \"fetch\", (original: FetchFn) => {\n const call = original.bind(globalThis);\n\n return async function instrumentedFetch(input, init) {\n const plan = active ? prepare(input, init) : undefined;\n if (!plan) {\n return call(input, init);\n }\n\n const startedAt = performance.now();\n try {\n const response = await call(plan.input, plan.init);\n record(plan, response.status, performance.now() - startedAt, undefined);\n return response;\n } catch (error) {\n record(plan, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n });\n\n this.restores.push(() => {\n active = false;\n restore();\n });\n }\n\n /**\n * Reads a fetch call and adds the trace headers to an allowlisted request.\n * @param input Fetch input of the caller.\n * @param init Fetch init of the caller.\n * @returns The plan, or undefined to send the request unchanged and record nothing.\n */\n private prepareFetch(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n ): FetchPlan | undefined {\n // A read here runs inside the fetch call of the caller. A throw must not fail the request.\n const read = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a fetch request. It sends the request unchanged.\",\n (): { method: string; url: string; propagate: boolean } | undefined => {\n const url = readUrl(input);\n if (this.ignored(url)) {\n return undefined;\n }\n\n return { method: readFetchMethod(input, init), url, propagate: this.propagates(url) };\n },\n );\n\n if (!read) {\n return undefined;\n }\n\n const { method, url } = read;\n const plan: FetchPlan = {\n method,\n url,\n input,\n init,\n routingContextId: this.ctx.config.securityContext.id,\n };\n // An init with headers replaces all headers of a foreign Request, for example\n // Authorization. Send a foreign input without the trace headers.\n if (!read.propagate || isForeignInput(input)) {\n return plan;\n }\n\n try {\n const trace = this.ctx.tracing.request();\n const injected = Object.entries(trace.headers);\n\n if (input instanceof Request) {\n // Do not spread a non-empty init with a Request input. That runs the Request\n // constructor on `input` again and reads its body. A second read of a body\n // causes a TypeError.\n const headers = new Headers(input.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n plan.input = new Request(input, { headers });\n } else {\n const headers = new Headers(init?.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n plan.init = { ...init, headers };\n }\n\n // Record the client span only for a request that carries its traceparent.\n plan.span = trace.span;\n } catch (error) {\n // Send the request that the caller gave, without changes. A missing header is\n // better than a failed request.\n plan.input = input;\n plan.init = init;\n this.ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n\n return plan;\n }\n\n /** Instruments XMLHttpRequest open and send prototype methods. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\") {\n return;\n }\n\n // Uninstall clears the flag. A wrapper that stays in place then only calls the original.\n let active = true;\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const propagates = (url: string): boolean => this.propagates(url);\n const record = (meta: XhrMeta, status: number, durationMs: number): void => {\n this.record(\n meta.method,\n meta.url,\n status,\n durationMs,\n undefined,\n meta.span,\n meta.routingContextId,\n );\n };\n\n const proto = xhrMethods();\n\n const restoreOpen = patch(\n proto,\n \"open\",\n (originalOpen) =>\n function (this: Tracked, method: unknown, url: unknown, ...rest: never[]) {\n if (active) {\n // A read here runs inside the open call of the caller. A throw must not fail it.\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read an XMLHttpRequest. It does not record the request.\",\n () => {\n this.__uiobs = { method: toMethod(method), url: readUrl(url), startedAt: 0 };\n },\n );\n }\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n },\n );\n\n const restoreSend = patch(\n proto,\n \"send\",\n (originalSend) =>\n function (this: Tracked, ...args: never[]) {\n const meta = active ? this.__uiobs : undefined;\n if (meta) {\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${meta.method} ${meta.url}.`,\n () => {\n if (ignored(meta.url)) {\n return;\n }\n\n meta.startedAt = performance.now();\n meta.routingContextId = ctx.config.securityContext.id;\n // A reused XHR gets a new listener at each send. The old one must not fire again.\n this.addEventListener(\n \"loadend\",\n () => {\n record(meta, this.status, performance.now() - meta.startedAt);\n },\n { once: true },\n );\n\n // setRequestHeader works only between open and send.\n if (propagates(meta.url)) {\n meta.span = addTraceHeaders(this, meta.url, ctx);\n }\n },\n );\n }\n originalSend.apply(this, args);\n },\n );\n\n this.restores.push(() => {\n active = false;\n restoreOpen();\n restoreSend();\n });\n }\n\n /**\n * Records request outcome attributes and breadcrumb entry.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The method removes the query unless you set fullUrls.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error Caught error instance on failed requests.\n * @param span Client span that the traceparent of the request names.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n span?: ClientSpan,\n routingContextId?: string,\n ): void {\n if (\n this.ctx.isActive?.() === false ||\n (this.ctx.config.securityContext.isolation &&\n routingContextId !== undefined &&\n routingContextId !== this.ctx.config.securityContext.id)\n )\n return;\n // Remove the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL. Only the recorded URL loses the query string.\n const url = recordedUrl(\n target,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n // A request of the transport after an await records a value. That value causes the next send.\n if (!this.warnedTransport && isTransportPending()) {\n this.warnedTransport = true;\n this.ctx.diagnostics.report(\n \"capture.transport_request\",\n `Network capture saw ${method} ${url} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`,\n );\n }\n\n // The histogram has its own guard. A URL that does not parse must not stop the record.\n if (this.ctx.config.capture.httpMetrics) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the duration of ${method} ${url}.`,\n () => {\n const attributes = durationAttributes(method, target, status, error);\n this.ctx.recordMetric(HTTP_DURATION, durationMs / MS_PER_SECOND, attributes);\n },\n );\n }\n\n if (span) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the span of ${method} ${url}.`,\n () => {\n const endMs = Date.now();\n this.ctx.recordSpan({\n ...span,\n name: method,\n kind: \"client\",\n startMs: endMs - durationMs,\n endMs,\n error: status === 0 || status >= 400,\n attributes: { ...durationAttributes(method, target, status, error), \"url.full\": url },\n });\n },\n );\n }\n\n // This code runs inside the fetch call of the caller. An error here must not cause\n // the request of the caller to fail.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG. The default minLevel of INFO drops it.\n // Only failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n\n/**\n * Adds the trace headers to an open XHR. A failure sends the request without them.\n * @param xhr Request between open and send.\n * @param url Request target URL, for the diagnostic.\n * @param ctx Capture context with tracing and diagnostics.\n * @returns The client span that the traceparent names, or undefined.\n */\nfunction addTraceHeaders(\n xhr: XMLHttpRequest,\n url: string,\n ctx: CaptureContext,\n): ClientSpan | undefined {\n try {\n const trace = ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n xhr.setRequestHeader(key, value);\n }\n return trace.span;\n } catch (error) {\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n return undefined;\n }\n}\n"],"mappings":"kMAgBA,IAAMW,EAAgB,IAMhBC,EAA+B,CACnC,KAAM,+BACN,KAAM,YACN,KAAM,IACN,WAAY,CAAC,KAAO,IAAM,KAAO,IAAM,KAAO,GAAK,IAAM,GAAK,IAAM,EAAG,IAAK,EAAG,IAAK,EAAE,CACxF,EAWA,SAASC,EACP,EACA,EACA,EACA,EACkB,CAElB,IAAMC,EAAO,OAAO,SAAa,IAAc,SAAS,KAAO,IAAA,GACzDC,EAA+B,CACnC,sBAAuBC,EACvB,iBAAkB,IAAI,IAAIC,EAAKH,CAAI,CAAC,CAAC,QACvC,EAEA,GAAII,IAAW,EAAG,CAEhB,IAAMC,EAAOnB,EAAAA,EAAYoB,CAAK,EAAIA,EAAM,KAAO,GAE/C,MADA,GAAW,cAAgBD,IAAS,GAAK,SAAWA,EAC7CJ,CACT,CAOA,MALA,GAAW,6BAA+BG,EACtCA,GAAU,MACZ,EAAW,cAAgB,OAAOA,CAAM,GAGnCH,CACT,CA4BA,SAASM,GAAyB,CAChC,OAAO,eAAe,SACxB,CAyBA,SAASC,EAAQ,EAAwB,CACvC,GAAI,OAAOC,GAAU,SACnB,OAAOA,EAGT,GAAIA,aAAiB,IACnB,OAAOA,EAAM,KAGf,GAAI,OAAOA,GAAU,UAAYA,EAAgB,CAC/C,GAAM,CAAE,OAAQA,EAChB,GAAI,OAAON,GAAQ,SACjB,OAAOA,CAEX,CAGA,OAAO,OAAOM,CAAK,CACrB,CAQA,SAASC,EAAgB,EAAgB,EAAuC,CAC9E,IAAIC,EAAqBC,GAAM,OAM/B,OAJID,IAAc,IAAA,IAAa,OAAOF,GAAU,UAAYA,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