@launchdarkly/o11y 1.4.1 → 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 +14 -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-D8kkCWo3.js → common-1QcQF8EE.js} +513 -498
- package/dist/{common-D8kkCWo3.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-BCebRa17.js → observe-TWCqC5wb.js} +2072 -1967
- package/dist/observe-TWCqC5wb.js.map +1 -0
- package/dist/observe.d.ts +73 -0
- package/dist/observe.js +3 -3
- package/dist/{record-DG2IcHxO.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-BCebRa17.js.map +0 -1
- package/dist/record-DG2IcHxO.js.map +0 -1
package/dist/record.d.ts
CHANGED
|
@@ -77,10 +77,26 @@ declare type attributeMutation = {
|
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Attributes is a map from string to attribute values.
|
|
82
|
+
*
|
|
83
|
+
* Note: only the own enumerable keys are counted as valid attribute keys.
|
|
84
|
+
*/
|
|
85
|
+
declare interface Attributes {
|
|
86
|
+
[attributeKey: string]: AttributeValue | undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
80
89
|
declare type attributes = cssTextKeyAttr & {
|
|
81
90
|
[key: string]: string | number | true | null;
|
|
82
91
|
};
|
|
83
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Attribute values may be any non-nullish primitive value except an object.
|
|
95
|
+
*
|
|
96
|
+
* null or undefined attribute values are invalid and will result in undefined behavior.
|
|
97
|
+
*/
|
|
98
|
+
declare type AttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
|
|
99
|
+
|
|
84
100
|
declare type CanvasArg = SerializedCanvasArg | string | number | boolean | null | CanvasArg[];
|
|
85
101
|
|
|
86
102
|
declare enum CanvasContext {
|
|
@@ -318,6 +334,34 @@ declare type Exact<T extends {
|
|
|
318
334
|
[K in keyof T]: T[K];
|
|
319
335
|
};
|
|
320
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Defines Exception.
|
|
339
|
+
*
|
|
340
|
+
* string or an object with one of (message or name or code) and optional stack
|
|
341
|
+
*/
|
|
342
|
+
declare type Exception = ExceptionWithCode | ExceptionWithMessage | ExceptionWithName | string;
|
|
343
|
+
|
|
344
|
+
declare interface ExceptionWithCode {
|
|
345
|
+
code: string | number;
|
|
346
|
+
name?: string;
|
|
347
|
+
message?: string;
|
|
348
|
+
stack?: string;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
declare interface ExceptionWithMessage {
|
|
352
|
+
code?: string | number;
|
|
353
|
+
message: string;
|
|
354
|
+
name?: string;
|
|
355
|
+
stack?: string;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
declare interface ExceptionWithName {
|
|
359
|
+
code?: string | number;
|
|
360
|
+
message?: string;
|
|
361
|
+
name: string;
|
|
362
|
+
stack?: string;
|
|
363
|
+
}
|
|
364
|
+
|
|
321
365
|
declare type FeedbackMessage = {
|
|
322
366
|
type: MessageType.Feedback;
|
|
323
367
|
verbatim: string;
|
|
@@ -622,6 +666,33 @@ declare type Hook = Omit<Hook_2, 'afterEvaluation'> & {
|
|
|
622
666
|
}): EvaluationSeriesData;
|
|
623
667
|
};
|
|
624
668
|
|
|
669
|
+
/**
|
|
670
|
+
* Defines High-Resolution Time.
|
|
671
|
+
*
|
|
672
|
+
* The first number, HrTime[0], is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
|
|
673
|
+
* The second number, HrTime[1], represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
|
|
674
|
+
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
|
|
675
|
+
* The first number is calculated by converting and truncating the Epoch time in milliseconds to seconds:
|
|
676
|
+
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
|
|
677
|
+
* The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
|
|
678
|
+
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
|
|
679
|
+
* This is represented in HrTime format as [1609504210, 150000000].
|
|
680
|
+
*/
|
|
681
|
+
declare type HrTime = [number, number];
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Describes the request behind an auto-instrumented browser `fetch` or
|
|
685
|
+
* `XMLHttpRequest` span.
|
|
686
|
+
*/
|
|
687
|
+
declare type HttpSpanRequest = {
|
|
688
|
+
/** Which instrumentation created the span. */
|
|
689
|
+
type: 'fetch' | 'xhr';
|
|
690
|
+
/** Upper-cased HTTP method, e.g. `GET`. */
|
|
691
|
+
method: string;
|
|
692
|
+
/** The concrete request URL, e.g. `https://app.example.com/api/users/42`. */
|
|
693
|
+
url: string;
|
|
694
|
+
};
|
|
695
|
+
|
|
625
696
|
declare type IdentifyMessage = {
|
|
626
697
|
type: MessageType.Identify;
|
|
627
698
|
userIdentifier: string;
|
|
@@ -705,6 +776,30 @@ declare interface LDPlugin {
|
|
|
705
776
|
getHooks?(metadata: LDPluginEnvironmentMetadata): Hook[];
|
|
706
777
|
}
|
|
707
778
|
|
|
779
|
+
/**
|
|
780
|
+
* A pointer from the current {@link Span} to another span in the same trace or
|
|
781
|
+
* in a different trace.
|
|
782
|
+
* Few examples of Link usage.
|
|
783
|
+
* 1. Batch Processing: A batch of elements may contain elements associated
|
|
784
|
+
* with one or more traces/spans. Since there can only be one parent
|
|
785
|
+
* SpanContext, Link is used to keep reference to SpanContext of all
|
|
786
|
+
* elements in the batch.
|
|
787
|
+
* 2. Public Endpoint: A SpanContext in incoming client request on a public
|
|
788
|
+
* endpoint is untrusted from service provider perspective. In such case it
|
|
789
|
+
* is advisable to start a new trace with appropriate sampling decision.
|
|
790
|
+
* However, it is desirable to associate incoming SpanContext to new trace
|
|
791
|
+
* initiated on service provider side so two traces (from Client and from
|
|
792
|
+
* Service Provider) can be correlated.
|
|
793
|
+
*/
|
|
794
|
+
declare interface Link {
|
|
795
|
+
/** The {@link SpanContext} of a linked span. */
|
|
796
|
+
context: SpanContext;
|
|
797
|
+
/** A set of {@link SpanAttributes} on the link. */
|
|
798
|
+
attributes?: SpanAttributes;
|
|
799
|
+
/** Count of attributes of the link that were dropped due to collection limits */
|
|
800
|
+
droppedAttributesCount?: number;
|
|
801
|
+
}
|
|
802
|
+
|
|
708
803
|
declare type listenerHandler = () => void;
|
|
709
804
|
|
|
710
805
|
declare type loadedEvent = {
|
|
@@ -1105,6 +1200,32 @@ declare type OtelInstrumentatonOptions = {
|
|
|
1105
1200
|
|
|
1106
1201
|
declare type OtelOptions = {
|
|
1107
1202
|
instrumentations?: OtelInstrumentatonOptions;
|
|
1203
|
+
/**
|
|
1204
|
+
* Called for each auto-instrumented `fetch` and `XMLHttpRequest` span just
|
|
1205
|
+
* before it ends, so the response and error status are already on it.
|
|
1206
|
+
* Use it to rename the span or add attributes, for example to give it a
|
|
1207
|
+
* route template:
|
|
1208
|
+
*
|
|
1209
|
+
* ```ts
|
|
1210
|
+
* onHttpRequestSpan: (span, { method, url }) => {
|
|
1211
|
+
* const route = matchRoute(url) // '/api/users/{userId}'
|
|
1212
|
+
* if (!route) return
|
|
1213
|
+
* span.updateName(`${method} ${route}`)
|
|
1214
|
+
* span.setAttributes({
|
|
1215
|
+
* 'http.route': route,
|
|
1216
|
+
* 'url.template': route,
|
|
1217
|
+
* 'launchdarkly.operation.name': route,
|
|
1218
|
+
* })
|
|
1219
|
+
* }
|
|
1220
|
+
* ```
|
|
1221
|
+
*
|
|
1222
|
+
* The span's trace and span ids are fixed when the request starts, so
|
|
1223
|
+
* renaming does not affect the `traceparent` sent to your backend.
|
|
1224
|
+
* Errors thrown by the callback are swallowed. Requires
|
|
1225
|
+
* `networkRecording` to be enabled, as the instrumentations are not
|
|
1226
|
+
* installed otherwise.
|
|
1227
|
+
*/
|
|
1228
|
+
onHttpRequestSpan?: (span: Span, request: HttpSpanRequest) => void;
|
|
1108
1229
|
};
|
|
1109
1230
|
|
|
1110
1231
|
declare class Plugin_2<T extends RecordOptions | ObserveOptions> {
|
|
@@ -1408,6 +1529,7 @@ declare class RecordSDK implements Record_3 {
|
|
|
1408
1529
|
_isCrossOriginIframe: boolean;
|
|
1409
1530
|
_eventBytesSinceSnapshot: number;
|
|
1410
1531
|
_lastSnapshotTime: number;
|
|
1532
|
+
_snapshotPayloadIds: Set<number>;
|
|
1411
1533
|
_lastVisibilityChangeTime: number;
|
|
1412
1534
|
pushPayloadTimerId: ReturnType<typeof setTimeout> | undefined;
|
|
1413
1535
|
hasSessionUnloaded: boolean;
|
|
@@ -1682,6 +1804,208 @@ declare type SessionShortcutOptions = false | string;
|
|
|
1682
1804
|
|
|
1683
1805
|
declare type Source = 'segment' | 'LaunchDarkly' | undefined;
|
|
1684
1806
|
|
|
1807
|
+
/**
|
|
1808
|
+
* An interface that represents a span. A span represents a single operation
|
|
1809
|
+
* within a trace. Examples of span might include remote procedure calls or a
|
|
1810
|
+
* in-process function calls to sub-components. A Trace has a single, top-level
|
|
1811
|
+
* "root" Span that in turn may have zero or more child Spans, which in turn
|
|
1812
|
+
* may have children.
|
|
1813
|
+
*
|
|
1814
|
+
* Spans are created by the {@link Tracer.startSpan} method.
|
|
1815
|
+
*/
|
|
1816
|
+
declare interface Span {
|
|
1817
|
+
/**
|
|
1818
|
+
* Returns the {@link SpanContext} object associated with this Span.
|
|
1819
|
+
*
|
|
1820
|
+
* Get an immutable, serializable identifier for this span that can be used
|
|
1821
|
+
* to create new child spans. Returned SpanContext is usable even after the
|
|
1822
|
+
* span ends.
|
|
1823
|
+
*
|
|
1824
|
+
* @returns the SpanContext object associated with this Span.
|
|
1825
|
+
*/
|
|
1826
|
+
spanContext(): SpanContext;
|
|
1827
|
+
/**
|
|
1828
|
+
* Sets an attribute to the span.
|
|
1829
|
+
*
|
|
1830
|
+
* Sets a single Attribute with the key and value passed as arguments.
|
|
1831
|
+
*
|
|
1832
|
+
* @param key the key for this attribute.
|
|
1833
|
+
* @param value the value for this attribute. Setting a value null or
|
|
1834
|
+
* undefined is invalid and will result in undefined behavior.
|
|
1835
|
+
*/
|
|
1836
|
+
setAttribute(key: string, value: SpanAttributeValue): this;
|
|
1837
|
+
/**
|
|
1838
|
+
* Sets attributes to the span.
|
|
1839
|
+
*
|
|
1840
|
+
* @param attributes the attributes that will be added.
|
|
1841
|
+
* null or undefined attribute values
|
|
1842
|
+
* are invalid and will result in undefined behavior.
|
|
1843
|
+
*/
|
|
1844
|
+
setAttributes(attributes: SpanAttributes): this;
|
|
1845
|
+
/**
|
|
1846
|
+
* Adds an event to the Span.
|
|
1847
|
+
*
|
|
1848
|
+
* @param name the name of the event.
|
|
1849
|
+
* @param [attributesOrStartTime] the attributes that will be added; these are
|
|
1850
|
+
* associated with this event. Can be also a start time
|
|
1851
|
+
* if type is {@type TimeInput} and 3rd param is undefined
|
|
1852
|
+
* @param [startTime] start time of the event.
|
|
1853
|
+
*/
|
|
1854
|
+
addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, startTime?: TimeInput): this;
|
|
1855
|
+
/**
|
|
1856
|
+
* Adds a single link to the span.
|
|
1857
|
+
*
|
|
1858
|
+
* Links added after the creation will not affect the sampling decision.
|
|
1859
|
+
* It is preferred span links be added at span creation.
|
|
1860
|
+
*
|
|
1861
|
+
* @param link the link to add.
|
|
1862
|
+
*/
|
|
1863
|
+
addLink(link: Link): this;
|
|
1864
|
+
/**
|
|
1865
|
+
* Adds multiple links to the span.
|
|
1866
|
+
*
|
|
1867
|
+
* Links added after the creation will not affect the sampling decision.
|
|
1868
|
+
* It is preferred span links be added at span creation.
|
|
1869
|
+
*
|
|
1870
|
+
* @param links the links to add.
|
|
1871
|
+
*/
|
|
1872
|
+
addLinks(links: Link[]): this;
|
|
1873
|
+
/**
|
|
1874
|
+
* Sets a status to the span. If used, this will override the default Span
|
|
1875
|
+
* status. Default is {@link SpanStatusCode.UNSET}. SetStatus overrides the value
|
|
1876
|
+
* of previous calls to SetStatus on the Span.
|
|
1877
|
+
*
|
|
1878
|
+
* @param status the SpanStatus to set.
|
|
1879
|
+
*/
|
|
1880
|
+
setStatus(status: SpanStatus): this;
|
|
1881
|
+
/**
|
|
1882
|
+
* Updates the Span name.
|
|
1883
|
+
*
|
|
1884
|
+
* This will override the name provided via {@link Tracer.startSpan}.
|
|
1885
|
+
*
|
|
1886
|
+
* Upon this update, any sampling behavior based on Span name will depend on
|
|
1887
|
+
* the implementation.
|
|
1888
|
+
*
|
|
1889
|
+
* @param name the Span name.
|
|
1890
|
+
*/
|
|
1891
|
+
updateName(name: string): this;
|
|
1892
|
+
/**
|
|
1893
|
+
* Marks the end of Span execution.
|
|
1894
|
+
*
|
|
1895
|
+
* Call to End of a Span MUST not have any effects on child spans. Those may
|
|
1896
|
+
* still be running and can be ended later.
|
|
1897
|
+
*
|
|
1898
|
+
* Do not return `this`. The Span generally should not be used after it
|
|
1899
|
+
* is ended so chaining is not desired in this context.
|
|
1900
|
+
*
|
|
1901
|
+
* @param [endTime] the time to set as Span's end time. If not provided,
|
|
1902
|
+
* use the current time as the span's end time.
|
|
1903
|
+
*/
|
|
1904
|
+
end(endTime?: TimeInput): void;
|
|
1905
|
+
/**
|
|
1906
|
+
* Returns the flag whether this span will be recorded.
|
|
1907
|
+
*
|
|
1908
|
+
* @returns true if this Span is active and recording information like events
|
|
1909
|
+
* with the `AddEvent` operation and attributes using `setAttributes`.
|
|
1910
|
+
*/
|
|
1911
|
+
isRecording(): boolean;
|
|
1912
|
+
/**
|
|
1913
|
+
* Sets exception as a span event
|
|
1914
|
+
* @param exception the exception the only accepted values are string or Error
|
|
1915
|
+
* @param [time] the time to set as Span's event time. If not provided,
|
|
1916
|
+
* use the current time.
|
|
1917
|
+
*/
|
|
1918
|
+
recordException(exception: Exception, time?: TimeInput): void;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* @deprecated please use {@link Attributes}
|
|
1923
|
+
*/
|
|
1924
|
+
declare type SpanAttributes = Attributes;
|
|
1925
|
+
|
|
1926
|
+
/**
|
|
1927
|
+
* @deprecated please use {@link AttributeValue}
|
|
1928
|
+
*/
|
|
1929
|
+
declare type SpanAttributeValue = AttributeValue;
|
|
1930
|
+
|
|
1931
|
+
/**
|
|
1932
|
+
* A SpanContext represents the portion of a {@link Span} which must be
|
|
1933
|
+
* serialized and propagated along side of a {@link Baggage}.
|
|
1934
|
+
*/
|
|
1935
|
+
declare interface SpanContext {
|
|
1936
|
+
/**
|
|
1937
|
+
* The ID of the trace that this span belongs to. It is worldwide unique
|
|
1938
|
+
* with practically sufficient probability by being made as 16 randomly
|
|
1939
|
+
* generated bytes, encoded as a 32 lowercase hex characters corresponding to
|
|
1940
|
+
* 128 bits.
|
|
1941
|
+
*/
|
|
1942
|
+
traceId: string;
|
|
1943
|
+
/**
|
|
1944
|
+
* The ID of the Span. It is globally unique with practically sufficient
|
|
1945
|
+
* probability by being made as 8 randomly generated bytes, encoded as a 16
|
|
1946
|
+
* lowercase hex characters corresponding to 64 bits.
|
|
1947
|
+
*/
|
|
1948
|
+
spanId: string;
|
|
1949
|
+
/**
|
|
1950
|
+
* Only true if the SpanContext was propagated from a remote parent.
|
|
1951
|
+
*/
|
|
1952
|
+
isRemote?: boolean;
|
|
1953
|
+
/**
|
|
1954
|
+
* Trace flags to propagate.
|
|
1955
|
+
*
|
|
1956
|
+
* It is represented as 1 byte (bitmap). Bit to represent whether trace is
|
|
1957
|
+
* sampled or not. When set, the least significant bit documents that the
|
|
1958
|
+
* caller may have recorded trace data. A caller who does not record trace
|
|
1959
|
+
* data out-of-band leaves this flag unset.
|
|
1960
|
+
*
|
|
1961
|
+
* see {@link TraceFlags} for valid flag values.
|
|
1962
|
+
*/
|
|
1963
|
+
traceFlags: number;
|
|
1964
|
+
/**
|
|
1965
|
+
* Tracing-system-specific info to propagate.
|
|
1966
|
+
*
|
|
1967
|
+
* The tracestate field value is a `list` as defined below. The `list` is a
|
|
1968
|
+
* series of `list-members` separated by commas `,`, and a list-member is a
|
|
1969
|
+
* key/value pair separated by an equals sign `=`. Spaces and horizontal tabs
|
|
1970
|
+
* surrounding `list-members` are ignored. There can be a maximum of 32
|
|
1971
|
+
* `list-members` in a `list`.
|
|
1972
|
+
* More Info: https://www.w3.org/TR/trace-context/#tracestate-field
|
|
1973
|
+
*
|
|
1974
|
+
* Examples:
|
|
1975
|
+
* Single tracing system (generic format):
|
|
1976
|
+
* tracestate: rojo=00f067aa0ba902b7
|
|
1977
|
+
* Multiple tracing systems (with different formatting):
|
|
1978
|
+
* tracestate: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE
|
|
1979
|
+
*/
|
|
1980
|
+
traceState?: TraceState;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
declare interface SpanStatus {
|
|
1984
|
+
/** The status code of this message. */
|
|
1985
|
+
code: SpanStatusCode;
|
|
1986
|
+
/** A developer-facing error message. */
|
|
1987
|
+
message?: string;
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* An enumeration of status codes.
|
|
1992
|
+
*/
|
|
1993
|
+
declare enum SpanStatusCode {
|
|
1994
|
+
/**
|
|
1995
|
+
* The default status.
|
|
1996
|
+
*/
|
|
1997
|
+
UNSET = 0,
|
|
1998
|
+
/**
|
|
1999
|
+
* The operation has been validated by an Application developer or
|
|
2000
|
+
* Operator to have completed successfully.
|
|
2001
|
+
*/
|
|
2002
|
+
OK = 1,
|
|
2003
|
+
/**
|
|
2004
|
+
* The operation contains an error.
|
|
2005
|
+
*/
|
|
2006
|
+
ERROR = 2
|
|
2007
|
+
}
|
|
2008
|
+
|
|
1685
2009
|
declare interface StartOptions {
|
|
1686
2010
|
/**
|
|
1687
2011
|
* Specifies whether console warn messages should not be created.
|
|
@@ -1768,6 +2092,51 @@ declare type textNode = {
|
|
|
1768
2092
|
isStyle?: true;
|
|
1769
2093
|
};
|
|
1770
2094
|
|
|
2095
|
+
/**
|
|
2096
|
+
* Defines TimeInput.
|
|
2097
|
+
*
|
|
2098
|
+
* hrtime, epoch milliseconds, performance.now() or Date
|
|
2099
|
+
*/
|
|
2100
|
+
declare type TimeInput = HrTime | number | Date;
|
|
2101
|
+
|
|
2102
|
+
declare interface TraceState {
|
|
2103
|
+
/**
|
|
2104
|
+
* Create a new TraceState which inherits from this TraceState and has the
|
|
2105
|
+
* given key set.
|
|
2106
|
+
* The new entry will always be added in the front of the list of states.
|
|
2107
|
+
*
|
|
2108
|
+
* @param key key of the TraceState entry.
|
|
2109
|
+
* @param value value of the TraceState entry.
|
|
2110
|
+
*/
|
|
2111
|
+
set(key: string, value: string): TraceState;
|
|
2112
|
+
/**
|
|
2113
|
+
* Return a new TraceState which inherits from this TraceState but does not
|
|
2114
|
+
* contain the given key.
|
|
2115
|
+
*
|
|
2116
|
+
* @param key the key for the TraceState entry to be removed.
|
|
2117
|
+
*/
|
|
2118
|
+
unset(key: string): TraceState;
|
|
2119
|
+
/**
|
|
2120
|
+
* Returns the value to which the specified key is mapped, or `undefined` if
|
|
2121
|
+
* this map contains no mapping for the key.
|
|
2122
|
+
*
|
|
2123
|
+
* @param key with which the specified value is to be associated.
|
|
2124
|
+
* @returns the value to which the specified key is mapped, or `undefined` if
|
|
2125
|
+
* this map contains no mapping for the key.
|
|
2126
|
+
*/
|
|
2127
|
+
get(key: string): string | undefined;
|
|
2128
|
+
/**
|
|
2129
|
+
* Serializes the TraceState to a `list` as defined below. The `list` is a
|
|
2130
|
+
* series of `list-members` separated by commas `,`, and a list-member is a
|
|
2131
|
+
* key/value pair separated by an equals sign `=`. Spaces and horizontal tabs
|
|
2132
|
+
* surrounding `list-members` are ignored. There can be a maximum of 32
|
|
2133
|
+
* `list-members` in a `list`.
|
|
2134
|
+
*
|
|
2135
|
+
* @returns the serialized string.
|
|
2136
|
+
*/
|
|
2137
|
+
serialize(): string;
|
|
2138
|
+
}
|
|
2139
|
+
|
|
1771
2140
|
declare type viewportResizeData = {
|
|
1772
2141
|
source: IncrementalSource.ViewportResize;
|
|
1773
2142
|
} & viewportResizeDimension;
|
package/dist/record.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@launchdarkly/o11y",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Shared browser foundation for @launchdarkly/observability and @launchdarkly/session-replay. Capture frontend metrics, errors, logs, traces, and session replays.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"launchdarkly",
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
var i = (e, r, t) => new Promise((a, s) => {
|
|
2
|
-
var n = (o) => {
|
|
3
|
-
try {
|
|
4
|
-
l(t.next(o));
|
|
5
|
-
} catch (d) {
|
|
6
|
-
s(d);
|
|
7
|
-
}
|
|
8
|
-
}, b = (o) => {
|
|
9
|
-
try {
|
|
10
|
-
l(t.throw(o));
|
|
11
|
-
} catch (d) {
|
|
12
|
-
s(d);
|
|
13
|
-
}
|
|
14
|
-
}, l = (o) => o.done ? a(o.value) : Promise.resolve(o.value).then(n, b);
|
|
15
|
-
l((t = t.apply(e, r)).next());
|
|
16
|
-
});
|
|
17
|
-
import { B as _, d as h } from "./buffer-CwCRPuMA.js";
|
|
18
|
-
const f = () => {
|
|
19
|
-
const e = {
|
|
20
|
-
end: () => {
|
|
21
|
-
},
|
|
22
|
-
spanContext: () => ({
|
|
23
|
-
traceId: "",
|
|
24
|
-
spanId: "",
|
|
25
|
-
traceFlags: 0
|
|
26
|
-
}),
|
|
27
|
-
setAttribute: (r, t) => e,
|
|
28
|
-
setAttributes: (r) => e,
|
|
29
|
-
addEvent: (r, t, a) => e,
|
|
30
|
-
addLinks: (r) => e,
|
|
31
|
-
setStatus: (r) => e,
|
|
32
|
-
recordException: () => {
|
|
33
|
-
},
|
|
34
|
-
addLink: () => e,
|
|
35
|
-
updateName: () => e,
|
|
36
|
-
isRecording: () => !1
|
|
37
|
-
};
|
|
38
|
-
return e;
|
|
39
|
-
};
|
|
40
|
-
function c(e, r, t) {
|
|
41
|
-
if (typeof t == "function")
|
|
42
|
-
return t;
|
|
43
|
-
if (typeof r == "function")
|
|
44
|
-
return r;
|
|
45
|
-
if (typeof e == "function")
|
|
46
|
-
return e;
|
|
47
|
-
}
|
|
48
|
-
class p extends _ {
|
|
49
|
-
_startSdk() {
|
|
50
|
-
return i(this, null, function* () {
|
|
51
|
-
yield this._sdk.start();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// Never buffered: with `manualStart`, `start()` may run before the plugin
|
|
55
|
-
// has attached an SDK. It then stays pending and resolves once `load`
|
|
56
|
-
// attaches and starts the SDK.
|
|
57
|
-
start() {
|
|
58
|
-
return i(this, null, function* () {
|
|
59
|
-
return this._start();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
// Never buffered, and never throws: before an SDK is attached it just
|
|
63
|
-
// cancels a start that has not run yet.
|
|
64
|
-
stop() {
|
|
65
|
-
return i(this, null, function* () {
|
|
66
|
-
yield this._stop(() => this._sdk.stop());
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
recordGauge(r) {
|
|
70
|
-
return this._bufferCall("recordGauge", [r]);
|
|
71
|
-
}
|
|
72
|
-
recordCount(r) {
|
|
73
|
-
return this._bufferCall("recordCount", [r]);
|
|
74
|
-
}
|
|
75
|
-
recordIncr(r) {
|
|
76
|
-
return this._bufferCall("recordIncr", [r]);
|
|
77
|
-
}
|
|
78
|
-
recordHistogram(r) {
|
|
79
|
-
return this._bufferCall("recordHistogram", [r]);
|
|
80
|
-
}
|
|
81
|
-
recordUpDownCounter(r) {
|
|
82
|
-
return this._bufferCall("recordUpDownCounter", [r]);
|
|
83
|
-
}
|
|
84
|
-
// The callback holds the caller's own work, so it must never be buffered:
|
|
85
|
-
// deferring it would replay that work at an arbitrary later time, or drop it.
|
|
86
|
-
startSpan(r, t, a, s) {
|
|
87
|
-
var n;
|
|
88
|
-
return this._isReady ? this._bufferCall("startSpan", [r, t, a, s]) : (this._logNoopSpanWarning(), (n = c(t, a, s)) == null ? void 0 : n(f()));
|
|
89
|
-
}
|
|
90
|
-
startManualSpan(r, t, a, s) {
|
|
91
|
-
var n;
|
|
92
|
-
return this._isReady ? this._bufferCall("startManualSpan", [r, t, a, s]) : (this._logNoopSpanWarning(), (n = c(t, a, s)) == null ? void 0 : n(f()));
|
|
93
|
-
}
|
|
94
|
-
_logNoopSpanWarning() {
|
|
95
|
-
h(
|
|
96
|
-
"startSpan/startManualSpan called before start()",
|
|
97
|
-
"span-before-start",
|
|
98
|
-
"warn",
|
|
99
|
-
"The span callback runs on a no-op span and the span is not recorded."
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
register(r, t) {
|
|
103
|
-
return this._bufferCall("register", [r, t]);
|
|
104
|
-
}
|
|
105
|
-
recordLog(r, t, a) {
|
|
106
|
-
return this._bufferCall("recordLog", [r, t, a]);
|
|
107
|
-
}
|
|
108
|
-
recordError(r, t, a, s, n) {
|
|
109
|
-
return this._bufferCall("recordError", [
|
|
110
|
-
r,
|
|
111
|
-
t,
|
|
112
|
-
a,
|
|
113
|
-
s,
|
|
114
|
-
n
|
|
115
|
-
]);
|
|
116
|
-
}
|
|
117
|
-
setLDContextKeyAttributes(r) {
|
|
118
|
-
return this._bufferCall("setLDContextKeyAttributes", [r]);
|
|
119
|
-
}
|
|
120
|
-
getLDContextKeyAttributes() {
|
|
121
|
-
return this._isLoaded ? this._callSdk("getLDContextKeyAttributes", []) : void 0;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
let u;
|
|
125
|
-
typeof globalThis != "undefined" ? globalThis.LDObserve ? u = globalThis.LDObserve : (u = new p(), globalThis.LDObserve = u) : u = new p();
|
|
126
|
-
export {
|
|
127
|
-
u as L,
|
|
128
|
-
f as g
|
|
129
|
-
};
|
|
130
|
-
//# sourceMappingURL=LDObserve-BQr7RYVC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LDObserve-BQr7RYVC.js","sources":["../src/client/otel/utils.ts","../src/sdk/LDObserve.ts"],"sourcesContent":["import {\n\tAttributes,\n\tAttributeValue,\n\tLink,\n\tSpan,\n\tSpanStatus,\n\tTimeInput,\n} from '@opentelemetry/api'\n\nexport const getNoopSpan = () => {\n\tconst noopSpan: Span = {\n\t\tend: () => {},\n\t\tspanContext: () => ({\n\t\t\ttraceId: '',\n\t\t\tspanId: '',\n\t\t\ttraceFlags: 0,\n\t\t}),\n\t\tsetAttribute: (_key: string, _value: AttributeValue) => noopSpan,\n\t\tsetAttributes: (_attributes: Attributes) => noopSpan,\n\t\taddEvent: (\n\t\t\t_name: string,\n\t\t\t_attributesOrStartTime?: Attributes | TimeInput,\n\t\t\t_startTime?: TimeInput,\n\t\t) => noopSpan,\n\t\taddLinks: (_links: Link[]) => noopSpan,\n\t\tsetStatus: (_status: SpanStatus) => noopSpan,\n\t\trecordException: () => {},\n\t\taddLink: () => noopSpan,\n\t\tupdateName: () => noopSpan,\n\t\tisRecording: () => false,\n\t}\n\n\treturn noopSpan\n}\n","import type { Observe } from '../api/observe'\nimport type { LDClient } from '../integrations/launchdarkly'\nimport type { ErrorMessageType } from '../client/types/shared-types'\nimport type { OTelMetric as Metric } from '../client/types/types'\nimport type { Attributes, Context, Span, SpanOptions } from '@opentelemetry/api'\nimport type { LDPluginEnvironmentMetadata } from '../plugins/plugin'\nimport { BufferedClass } from './buffer'\nimport { getNoopSpan } from '../client/otel/utils'\nimport { ConsoleMethods } from '../client/types/client'\nimport { internalLogOnce } from './util'\n\n/**\n * Resolves the span callback from whichever argument position it was passed in,\n * matching the overloads `startSpan` and `startManualSpan` accept.\n */\nfunction resolveSpanCallback(\n\toptions: unknown,\n\tcontext: unknown,\n\tfn: unknown,\n): ((span: Span) => any) | undefined {\n\tif (typeof fn === 'function') {\n\t\treturn fn as (span: Span) => any\n\t}\n\tif (typeof context === 'function') {\n\t\treturn context as (span: Span) => any\n\t}\n\tif (typeof options === 'function') {\n\t\treturn options as (span: Span) => any\n\t}\n\treturn undefined\n}\n\nclass _LDObserve extends BufferedClass<Observe> implements Observe {\n\tprotected async _startSdk() {\n\t\tawait this._sdk.start()\n\t}\n\n\t// Never buffered: with `manualStart`, `start()` may run before the plugin\n\t// has attached an SDK. It then stays pending and resolves once `load`\n\t// attaches and starts the SDK.\n\tasync start() {\n\t\treturn this._start()\n\t}\n\n\t// Never buffered, and never throws: before an SDK is attached it just\n\t// cancels a start that has not run yet.\n\tasync stop() {\n\t\tawait this._stop(() => this._sdk.stop())\n\t}\n\n\trecordGauge(metric: Metric) {\n\t\treturn this._bufferCall('recordGauge', [metric])\n\t}\n\n\trecordCount(metric: Metric) {\n\t\treturn this._bufferCall('recordCount', [metric])\n\t}\n\n\trecordIncr(metric: Omit<Metric, 'value'>) {\n\t\treturn this._bufferCall('recordIncr', [metric])\n\t}\n\n\trecordHistogram(metric: Metric) {\n\t\treturn this._bufferCall('recordHistogram', [metric])\n\t}\n\n\trecordUpDownCounter(metric: Metric) {\n\t\treturn this._bufferCall('recordUpDownCounter', [metric])\n\t}\n\n\t// The callback holds the caller's own work, so it must never be buffered:\n\t// deferring it would replay that work at an arbitrary later time, or drop it.\n\tstartSpan(\n\t\tname: string,\n\t\toptions: SpanOptions | ((span?: Span) => any),\n\t\tcontext?: Context | ((span?: Span) => any),\n\t\tfn?: (span?: Span) => any,\n\t) {\n\t\tif (!this._isReady) {\n\t\t\tthis._logNoopSpanWarning()\n\t\t\treturn resolveSpanCallback(options, context, fn)?.(getNoopSpan())\n\t\t}\n\t\treturn this._bufferCall('startSpan', [name, options, context, fn])\n\t}\n\n\tstartManualSpan(\n\t\tname: string,\n\t\toptions: SpanOptions | ((span: Span) => any),\n\t\tcontext?: Context | ((span: Span) => any),\n\t\tfn?: (span: Span) => any,\n\t) {\n\t\tif (!this._isReady) {\n\t\t\tthis._logNoopSpanWarning()\n\t\t\treturn resolveSpanCallback(options, context, fn)?.(getNoopSpan())\n\t\t}\n\t\treturn this._bufferCall('startManualSpan', [name, options, context, fn])\n\t}\n\n\tprivate _logNoopSpanWarning() {\n\t\tinternalLogOnce(\n\t\t\t'startSpan/startManualSpan called before start()',\n\t\t\t'span-before-start',\n\t\t\t'warn',\n\t\t\t'The span callback runs on a no-op span and the span is not recorded.',\n\t\t)\n\t}\n\n\tregister(\n\t\tclient: LDClient,\n\t\tenvironmentMetadata: LDPluginEnvironmentMetadata,\n\t) {\n\t\treturn this._bufferCall('register', [client, environmentMetadata])\n\t}\n\n\trecordLog(message: any, level: ConsoleMethods, metadata?: Attributes) {\n\t\treturn this._bufferCall('recordLog', [message, level, metadata])\n\t}\n\n\trecordError(\n\t\terror: Error,\n\t\tmessage?: string,\n\t\tpayload?: { [key: string]: string },\n\t\tsource?: string,\n\t\ttype?: ErrorMessageType,\n\t) {\n\t\treturn this._bufferCall('recordError', [\n\t\t\terror,\n\t\t\tmessage,\n\t\t\tpayload,\n\t\t\tsource,\n\t\t\ttype,\n\t\t])\n\t}\n\n\tsetLDContextKeyAttributes(contextKeys: Attributes) {\n\t\treturn this._bufferCall('setLDContextKeyAttributes', [contextKeys])\n\t}\n\n\tgetLDContextKeyAttributes(): Attributes | undefined {\n\t\t// A getter: read directly once attached rather than buffering.\n\t\treturn this._isLoaded\n\t\t\t? this._callSdk('getLDContextKeyAttributes', [])\n\t\t\t: undefined\n\t}\n}\n\ninterface GlobalThis {\n\tLDObserve?: _LDObserve\n}\ndeclare var globalThis: GlobalThis\n\nexport let LDObserve!: _LDObserve\nif (typeof globalThis !== 'undefined') {\n\tif (globalThis.LDObserve) {\n\t\tLDObserve = globalThis.LDObserve\n\t} else {\n\t\tLDObserve = new _LDObserve()\n\t\tglobalThis.LDObserve = LDObserve\n\t}\n} else {\n\tLDObserve = new _LDObserve()\n}\n"],"names":["getNoopSpan","noopSpan","_key","_value","_attributes","_name","_attributesOrStartTime","_startTime","_links","_status","resolveSpanCallback","options","context","fn","_LDObserve","BufferedClass","__async","metric","name","_a","internalLogOnce","client","environmentMetadata","message","level","metadata","error","payload","source","type","contextKeys","LDObserve"],"mappings":"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"}
|