@launchdarkly/o11y 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/LDObserve-o8Ro1UV8.js +160 -0
- package/dist/LDObserve-o8Ro1UV8.js.map +1 -0
- package/dist/LDObserve.d.ts +44 -0
- package/dist/LDObserve.js +1 -1
- package/dist/{common-7gIdCuSo.js → common-1QcQF8EE.js} +513 -498
- package/dist/{common-7gIdCuSo.js.map → common-1QcQF8EE.js.map} +1 -1
- package/dist/index.d.ts +85 -0
- package/dist/index.js +209 -207
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +113 -113
- package/dist/index.umd.js.map +1 -1
- package/dist/{observe-DVzqBVcI.js → observe-TWCqC5wb.js} +2074 -1968
- package/dist/observe-TWCqC5wb.js.map +1 -0
- package/dist/observe.d.ts +73 -0
- package/dist/observe.js +3 -3
- package/dist/{record-CwkFdJT0.js → record-Bgkzgi9x.js} +489 -487
- package/dist/record-Bgkzgi9x.js.map +1 -0
- package/dist/record.d.ts +369 -0
- package/dist/record.js +2 -2
- package/package.json +1 -1
- package/dist/LDObserve-BQr7RYVC.js +0 -130
- package/dist/LDObserve-BQr7RYVC.js.map +0 -1
- package/dist/observe-DVzqBVcI.js.map +0 -1
- package/dist/record-CwkFdJT0.js.map +0 -1
package/dist/observe.d.ts
CHANGED
|
@@ -234,6 +234,19 @@ declare type Hook = Omit<Hook_2, 'afterEvaluation'> & {
|
|
|
234
234
|
*/
|
|
235
235
|
declare type HrTime = [number, number];
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Describes the request behind an auto-instrumented browser `fetch` or
|
|
239
|
+
* `XMLHttpRequest` span.
|
|
240
|
+
*/
|
|
241
|
+
declare type HttpSpanRequest = {
|
|
242
|
+
/** Which instrumentation created the span. */
|
|
243
|
+
type: 'fetch' | 'xhr';
|
|
244
|
+
/** Upper-cased HTTP method, e.g. `GET`. */
|
|
245
|
+
method: string;
|
|
246
|
+
/** The concrete request URL, e.g. `https://app.example.com/api/users/42`. */
|
|
247
|
+
url: string;
|
|
248
|
+
};
|
|
249
|
+
|
|
237
250
|
declare type IntegrationOptions = {
|
|
238
251
|
amplitude?: AmplitudeIntegrationOptions;
|
|
239
252
|
intercom?: IntercomIntegrationOptions;
|
|
@@ -555,6 +568,40 @@ declare interface Observe_2 {
|
|
|
555
568
|
* Useful when you don't want to emit a console log to the browser dev tools but still want to report a custom log.
|
|
556
569
|
*/
|
|
557
570
|
recordLog: (message: any, level: ConsoleMethods, metadata?: Attributes) => void;
|
|
571
|
+
/**
|
|
572
|
+
* Adds attributes to all telemetry recorded from now on: every span
|
|
573
|
+
* (including automatically instrumented ones such as document load,
|
|
574
|
+
* fetch/XHR, clicks and page views), log, error and metric.
|
|
575
|
+
*
|
|
576
|
+
* Calling it again merges with the attributes already set; a `null` or
|
|
577
|
+
* `undefined` value removes that key. Attributes passed to an individual
|
|
578
|
+
* call (for example `recordLog` metadata or metric attributes) take
|
|
579
|
+
* precedence over these. Keys in namespaces the SDK sets itself
|
|
580
|
+
* (`highlight.*`, `launchdarkly.*`, `session.*`, `context.contextKeys.*`)
|
|
581
|
+
* are ignored.
|
|
582
|
+
*
|
|
583
|
+
* Attributes are held in memory for the current page load only: they are
|
|
584
|
+
* never persisted, and a full page load starts without them.
|
|
585
|
+
*
|
|
586
|
+
* Each attribute is also added to every metric, so a value with many
|
|
587
|
+
* distinct values (such as a user ID) creates as many metric series.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```typescript
|
|
591
|
+
* LDObserve.setAttributes({ utm_campaign: 'spring_promo', utm_source: 'email' })
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
setAttributes(attributes: Record<string, AttributeValue | null | undefined>): void;
|
|
595
|
+
/**
|
|
596
|
+
* Removes attributes previously added with `setAttributes`. Telemetry
|
|
597
|
+
* recorded afterwards no longer carries them.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```typescript
|
|
601
|
+
* LDObserve.removeAttributes(['utm_campaign'])
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
removeAttributes(keys: string[]): void;
|
|
558
605
|
register(client: LDClientMin, environmentMetadata: LDPluginEnvironmentMetadata): void;
|
|
559
606
|
getHooks?(metadata: LDPluginEnvironmentMetadata): Hook[];
|
|
560
607
|
setLDContextKeyAttributes(contextKeys: Attributes): void;
|
|
@@ -685,6 +732,32 @@ declare interface OTelMetric {
|
|
|
685
732
|
|
|
686
733
|
declare type OtelOptions = {
|
|
687
734
|
instrumentations?: OtelInstrumentatonOptions;
|
|
735
|
+
/**
|
|
736
|
+
* Called for each auto-instrumented `fetch` and `XMLHttpRequest` span just
|
|
737
|
+
* before it ends, so the response and error status are already on it.
|
|
738
|
+
* Use it to rename the span or add attributes, for example to give it a
|
|
739
|
+
* route template:
|
|
740
|
+
*
|
|
741
|
+
* ```ts
|
|
742
|
+
* onHttpRequestSpan: (span, { method, url }) => {
|
|
743
|
+
* const route = matchRoute(url) // '/api/users/{userId}'
|
|
744
|
+
* if (!route) return
|
|
745
|
+
* span.updateName(`${method} ${route}`)
|
|
746
|
+
* span.setAttributes({
|
|
747
|
+
* 'http.route': route,
|
|
748
|
+
* 'url.template': route,
|
|
749
|
+
* 'launchdarkly.operation.name': route,
|
|
750
|
+
* })
|
|
751
|
+
* }
|
|
752
|
+
* ```
|
|
753
|
+
*
|
|
754
|
+
* The span's trace and span ids are fixed when the request starts, so
|
|
755
|
+
* renaming does not affect the `traceparent` sent to your backend.
|
|
756
|
+
* Errors thrown by the callback are swallowed. Requires
|
|
757
|
+
* `networkRecording` to be enabled, as the instrumentations are not
|
|
758
|
+
* installed otherwise.
|
|
759
|
+
*/
|
|
760
|
+
onHttpRequestSpan?: (span: Span, request: HttpSpanRequest) => void;
|
|
688
761
|
};
|
|
689
762
|
|
|
690
763
|
declare class Plugin_2<T extends RecordOptions | ObserveOptions> {
|
package/dist/observe.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import { O as e } from "./observe-
|
|
3
|
-
import "./LDObserve-
|
|
1
|
+
import "./common-1QcQF8EE.js";
|
|
2
|
+
import { O as e } from "./observe-TWCqC5wb.js";
|
|
3
|
+
import "./LDObserve-o8Ro1UV8.js";
|
|
4
4
|
import "./buffer-CwCRPuMA.js";
|
|
5
5
|
export {
|
|
6
6
|
e as Observe
|