@mark1russell7/otel-ts 0.7.0 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -330,19 +330,36 @@ The tracker does not listen to `beforeunload` or `unload`. These events can prev
330
330
 
331
331
  Some monitors record their values at the end of the page. An example is the final Web Vitals of a page. The order of `pagehide` listeners is not the same in all browsers. Chromium calls `window` listeners in registration order. Thus, a library that stops in its own `pagehide` listener can stop before a monitor records its values.
332
332
 
333
- This library flushes in the `export` phase of the shared lifecycle tracker. A monitor that subscribes to the same tracker in the `observe` phase records its values first, whatever the order of the scripts. `@lag/core` does this by default.
333
+ This library flushes in the `export` phase of the shared lifecycle tracker. A monitor that subscribes to the same tracker in the `observe` phase records its values first, whatever the order of the scripts. [`@mark1russell7/lag`](https://www.npmjs.com/package/@mark1russell7/lag) does this by default.
334
334
 
335
335
  Values that a monitor keeps until a checkpoint can go out in each flush. Record them in an `onBeforeFlush()` listener:
336
336
 
337
337
  ```ts
338
338
  import { init } from "@mark1russell7/otel-ts";
339
- import { createBrowserDeps, setupAllMonitors } from "@lag/core";
339
+ import { createBrowserDeps, setupAllMonitors } from "@mark1russell7/lag";
340
340
 
341
341
  const otel = init({ serviceName: "checkout-web" });
342
342
  const monitors = setupAllMonitors(createBrowserDeps(window, { /* options */ }));
343
343
  otel.onBeforeFlush(() => monitors.flush());
344
344
  ```
345
345
 
346
+ ### The monitors of lag
347
+
348
+ The entry `@mark1russell7/otel-ts/lag` connects the monitors of `@mark1russell7/lag` to an instance in one call. `lagDeps()` gives the meter, the logger, the event sink and the span sink of the instance, with the name `lag`. `connect()` adds the `onBeforeFlush()` listener of the example above.
349
+
350
+ ```ts
351
+ import { init } from "@mark1russell7/otel-ts";
352
+ import { lagDeps } from "@mark1russell7/otel-ts/lag";
353
+ import { createBrowserDeps, setupAllMonitors } from "@mark1russell7/lag";
354
+
355
+ const otel = init({ serviceName: "checkout-web" });
356
+ const lag = lagDeps(otel);
357
+ const monitors = setupAllMonitors(createBrowserDeps(window, lag));
358
+ lag.connect(monitors);
359
+ ```
360
+
361
+ The spans go to the global tracer, which is the tracer of the instance when tracing is on. The option `tracer` gives another tracer, and the option `name` gives another name. `@mark1russell7/lag` 0.4.2 or later is an optional peer dependency. Only an app that imports this entry needs it.
362
+
346
363
  The listener gets the cause of the flush. For a page hide, `cause.transition` is the transition of the lifecycle state. For a call of `forceFlush()` or `shutdown()`, `cause.transition` is undefined.
347
364
 
348
365
  The library calls each listener synchronously before each flush. These flushes include each page hide and the stop at `pagehide`. They also include each `forceFlush()` call and the first `shutdown()` call.