@microsoft/applicationinsights-debugplugin-js 3.4.0-nightlybeta3.2507-22 → 3.4.0-nightlybeta3.2601-13
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/browser/es5/{ai.dbg.3.4.0-nightlybeta3.2507-22.cjs.js → ai.dbg.3.4.0-nightlybeta3.2601-13.cjs.js} +33 -23
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.cjs.js.map +1 -0
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.cjs.min.js +6 -0
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.cjs.min.js.map +1 -0
- package/browser/es5/{ai.dbg.3.4.0-nightlybeta3.2507-22.gbl.js → ai.dbg.3.4.0-nightlybeta3.2601-13.gbl.js} +35 -25
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.gbl.js.map +1 -0
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.gbl.min.js +6 -0
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.gbl.min.js.map +1 -0
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.integrity.json +66 -0
- package/browser/es5/{ai.dbg.3.4.0-nightlybeta3.2507-22.js → ai.dbg.3.4.0-nightlybeta3.2601-13.js} +35 -25
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.js.map +1 -0
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.min.js +6 -0
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2601-13.min.js.map +1 -0
- package/browser/es5/ai.dbg.3.cjs.js +32 -22
- package/browser/es5/ai.dbg.3.cjs.js.map +1 -1
- package/browser/es5/ai.dbg.3.cjs.min.js +2 -2
- package/browser/es5/ai.dbg.3.cjs.min.js.map +1 -1
- package/browser/es5/ai.dbg.3.gbl.js +34 -24
- package/browser/es5/ai.dbg.3.gbl.js.map +1 -1
- package/browser/es5/ai.dbg.3.gbl.min.js +2 -2
- package/browser/es5/ai.dbg.3.gbl.min.js.map +1 -1
- package/browser/es5/ai.dbg.3.integrity.json +25 -25
- package/browser/es5/ai.dbg.3.js +34 -24
- package/browser/es5/ai.dbg.3.js.map +1 -1
- package/browser/es5/ai.dbg.3.min.js +2 -2
- package/browser/es5/ai.dbg.3.min.js.map +1 -1
- package/dist/es5/applicationinsights-debugplugin-js.js +32 -22
- package/dist/es5/applicationinsights-debugplugin-js.js.map +1 -1
- package/dist/es5/applicationinsights-debugplugin-js.min.js +2 -2
- package/dist/es5/applicationinsights-debugplugin-js.min.js.map +1 -1
- package/dist-es5/DebugPlugin.js +1 -1
- package/dist-es5/__DynamicConstants.js +1 -1
- package/dist-es5/applicationinsights-debugplugin-js.js +1 -1
- package/dist-es5/components/Dashboard.js +1 -1
- package/dist-es5/components/LogEntry.js +1 -1
- package/dist-es5/components/debugBins.js +1 -1
- package/dist-es5/components/filterList.js +1 -1
- package/dist-es5/components/helpers.js +1 -1
- package/dist-es5/components/styleNodeSrc.js +1 -1
- package/dist-es5/interfaces/IDebugPluginConfig.js +1 -1
- package/package.json +3 -3
- package/types/applicationinsights-debugplugin-js.d.ts +1 -1
- package/types/applicationinsights-debugplugin-js.namespaced.d.ts +1664 -67
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.cjs.js.map +0 -1
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.cjs.min.js +0 -6
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.cjs.min.js.map +0 -1
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.gbl.js.map +0 -1
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.gbl.min.js +0 -6
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.gbl.min.js.map +0 -1
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.integrity.json +0 -66
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.js.map +0 -1
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.min.js +0 -6
- package/browser/es5/ai.dbg.3.4.0-nightlybeta3.2507-22.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft.ApplicationInsights, 3.4.0-nightlybeta3.
|
|
2
|
+
* Microsoft.ApplicationInsights, 3.4.0-nightlybeta3.2601-13
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -134,6 +134,51 @@ declare namespace ApplicationInsights {
|
|
|
134
134
|
PENDING = 3
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Const enum for attribute change operation types
|
|
139
|
+
*/
|
|
140
|
+
const enum eAttributeChangeOp {
|
|
141
|
+
/**
|
|
142
|
+
* Clear operation - clearing all attributes
|
|
143
|
+
*/
|
|
144
|
+
Clear = 0,
|
|
145
|
+
/**
|
|
146
|
+
* Set operation - setting an attribute value (generic)
|
|
147
|
+
*/
|
|
148
|
+
Set = 1,
|
|
149
|
+
/**
|
|
150
|
+
* Add operation - adding a new attribute that didn't exist before
|
|
151
|
+
*/
|
|
152
|
+
Add = 2,
|
|
153
|
+
/**
|
|
154
|
+
* Delete operation - deleting an attribute
|
|
155
|
+
*/
|
|
156
|
+
Delete = 3,
|
|
157
|
+
/**
|
|
158
|
+
* Dropped attributes - attributes that were dropped due to size limits
|
|
159
|
+
*/
|
|
160
|
+
DroppedAttributes = 4
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Identifies the source of an attribute value in iterator operations
|
|
165
|
+
* @since 3.4.0
|
|
166
|
+
*/
|
|
167
|
+
const enum eAttributeFilter {
|
|
168
|
+
/**
|
|
169
|
+
* The attribute exists local to the current container instance
|
|
170
|
+
*/
|
|
171
|
+
Local = 0,
|
|
172
|
+
/**
|
|
173
|
+
* The attribute does not exist locally and is inherited from a parent container or attributes object
|
|
174
|
+
*/
|
|
175
|
+
Inherited = 1,
|
|
176
|
+
/**
|
|
177
|
+
* The attribute exists or has been deleted locally (only) to the current container instance
|
|
178
|
+
*/
|
|
179
|
+
LocalOrDeleted = 2
|
|
180
|
+
}
|
|
181
|
+
|
|
137
182
|
const enum _eInternalMessageId {
|
|
138
183
|
BrowserDoesNotSupportLocalStorage = 0,
|
|
139
184
|
BrowserCannotReadLocalStorage = 1,
|
|
@@ -226,7 +271,11 @@ declare namespace ApplicationInsights {
|
|
|
226
271
|
SdkLdrUpdate = 111,
|
|
227
272
|
InitPromiseException = 112,
|
|
228
273
|
StatsBeatManagerException = 113,
|
|
229
|
-
StatsBeatException = 114
|
|
274
|
+
StatsBeatException = 114,
|
|
275
|
+
AttributeError = 115,
|
|
276
|
+
SpanError = 116,
|
|
277
|
+
TraceError = 117,
|
|
278
|
+
NotImplementedError = 118
|
|
230
279
|
}
|
|
231
280
|
|
|
232
281
|
const enum eLoggingSeverity {
|
|
@@ -264,6 +313,57 @@ declare namespace ApplicationInsights {
|
|
|
264
313
|
|
|
265
314
|
type EnumValue<E = any> = EnumCls<E>;
|
|
266
315
|
|
|
316
|
+
/**
|
|
317
|
+
* The defined set of Span Kinds as defined by the OpenTelemetry.
|
|
318
|
+
*/
|
|
319
|
+
const enum eOTelSpanKind {
|
|
320
|
+
/** Default value. Indicates that the span is used internally. */
|
|
321
|
+
INTERNAL = 0,
|
|
322
|
+
/**
|
|
323
|
+
* Indicates that the span covers server-side handling of an RPC or other
|
|
324
|
+
* remote request.
|
|
325
|
+
*/
|
|
326
|
+
SERVER = 1,
|
|
327
|
+
/**
|
|
328
|
+
* Indicates that the span covers the client-side wrapper around an RPC or
|
|
329
|
+
* other remote request.
|
|
330
|
+
*/
|
|
331
|
+
CLIENT = 2,
|
|
332
|
+
/**
|
|
333
|
+
* Indicates that the span describes producer sending a message to a
|
|
334
|
+
* broker. Unlike client and server, there is no direct critical path latency
|
|
335
|
+
* relationship between producer and consumer spans.
|
|
336
|
+
*/
|
|
337
|
+
PRODUCER = 3,
|
|
338
|
+
/**
|
|
339
|
+
* Indicates that the span describes consumer receiving a message from a
|
|
340
|
+
* broker. Unlike client and server, there is no direct critical path latency
|
|
341
|
+
* relationship between producer and consumer spans.
|
|
342
|
+
*/
|
|
343
|
+
CONSUMER = 4
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* An enumeration of status codes, matching the OpenTelemetry specification.
|
|
348
|
+
*
|
|
349
|
+
* @since 3.4.0
|
|
350
|
+
*/
|
|
351
|
+
const enum eOTelSpanStatusCode {
|
|
352
|
+
/**
|
|
353
|
+
* The default status.
|
|
354
|
+
*/
|
|
355
|
+
UNSET = 0,
|
|
356
|
+
/**
|
|
357
|
+
* The operation has been validated by an Application developer or
|
|
358
|
+
* Operator to have completed successfully.
|
|
359
|
+
*/
|
|
360
|
+
OK = 1,
|
|
361
|
+
/**
|
|
362
|
+
* The operation contains an error.
|
|
363
|
+
*/
|
|
364
|
+
ERROR = 2
|
|
365
|
+
}
|
|
366
|
+
|
|
267
367
|
/**
|
|
268
368
|
* Controls how the SDK should look for trace headers (traceparent/tracestate) from the initial page load
|
|
269
369
|
* The values are bitwise OR'd together to allow for multiple values to be set at once.
|
|
@@ -308,8 +408,7 @@ declare namespace ApplicationInsights {
|
|
|
308
408
|
*/
|
|
309
409
|
type FinallyPromiseHandler = (() => void) | undefined | null;
|
|
310
410
|
|
|
311
|
-
interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider {
|
|
312
|
-
readonly config: CfgType;
|
|
411
|
+
interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider, ITraceHost<CfgType> {
|
|
313
412
|
/**
|
|
314
413
|
* The current logger instance for this instance.
|
|
315
414
|
*/
|
|
@@ -430,14 +529,13 @@ declare namespace ApplicationInsights {
|
|
|
430
529
|
*/
|
|
431
530
|
flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
|
|
432
531
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
* Sets the current distributed trace context for this instance if available
|
|
532
|
+
* Set the trace provider for creating spans.
|
|
533
|
+
* This allows different SKUs to provide their own span implementations.
|
|
534
|
+
*
|
|
535
|
+
* @param provider - The trace provider to use for span creation
|
|
536
|
+
* @since 3.4.0
|
|
439
537
|
*/
|
|
440
|
-
|
|
538
|
+
setTraceProvider(provider: ICachedValue<ITraceProvider>): void;
|
|
441
539
|
/**
|
|
442
540
|
* Watches and tracks changes for accesses to the current config, and if the accessed config changes the
|
|
443
541
|
* handler will be recalled.
|
|
@@ -465,6 +563,150 @@ declare namespace ApplicationInsights {
|
|
|
465
563
|
_setPendingStatus?: () => void;
|
|
466
564
|
}
|
|
467
565
|
|
|
566
|
+
/**
|
|
567
|
+
* Information about what changed in an attribute container
|
|
568
|
+
*/
|
|
569
|
+
interface IAttributeChangeInfo<V extends OTelAttributeValue = OTelAttributeValue> {
|
|
570
|
+
/**
|
|
571
|
+
* The Id of the container that is initiated the change (not the immediate sender -- which is always the parent)
|
|
572
|
+
* As children only receive listener notifications from their parent in reaction to both changes
|
|
573
|
+
* they make and any changes they receive from their parent
|
|
574
|
+
*/
|
|
575
|
+
frm: string;
|
|
576
|
+
/**
|
|
577
|
+
* Operation type that occurred
|
|
578
|
+
*/
|
|
579
|
+
op: eAttributeChangeOp;
|
|
580
|
+
/**
|
|
581
|
+
* The key that was changed (only present for 'set' operations)
|
|
582
|
+
*/
|
|
583
|
+
k?: string;
|
|
584
|
+
/**
|
|
585
|
+
* The old value (only present for 'set' operations when replacing existing value)
|
|
586
|
+
*/
|
|
587
|
+
prev?: V;
|
|
588
|
+
/**
|
|
589
|
+
* The new value (only present for 'set' operations)
|
|
590
|
+
*/
|
|
591
|
+
val?: V;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Interface for an attribute container
|
|
596
|
+
* @since 3.4.0
|
|
597
|
+
*/
|
|
598
|
+
interface IAttributeContainer<V extends OTelAttributeValue = OTelAttributeValue> {
|
|
599
|
+
/**
|
|
600
|
+
* Unique identifier for the attribute container
|
|
601
|
+
*/
|
|
602
|
+
readonly id: string;
|
|
603
|
+
/**
|
|
604
|
+
* The number of attributes that have been set
|
|
605
|
+
* @returns The number of attributes that have been set
|
|
606
|
+
*/
|
|
607
|
+
readonly size: number;
|
|
608
|
+
/**
|
|
609
|
+
* The number of attributes that were dropped due to the attribute limit being reached
|
|
610
|
+
* @returns The number of attributes that were dropped due to the attribute limit being reached
|
|
611
|
+
*/
|
|
612
|
+
readonly droppedAttributes: number;
|
|
613
|
+
/**
|
|
614
|
+
* Return a snapshot of the current attributes, including inherited ones.
|
|
615
|
+
* This value is read-only and reflects the state of the attributes at the time of access,
|
|
616
|
+
* and the returned instance will not change if any attributes are modified later, you will need
|
|
617
|
+
* to access the attributes property again to get the latest state.
|
|
618
|
+
*
|
|
619
|
+
* Note: As this causes a snapshot to be taken, it is an expensive operation as it enumerates all
|
|
620
|
+
* attributes, so you SHOULD use this property sparingly.
|
|
621
|
+
* @returns A read-only snapshot of the current attributes
|
|
622
|
+
*/
|
|
623
|
+
readonly attributes: IOTelAttributes;
|
|
624
|
+
/**
|
|
625
|
+
* Clear all existing attributes from the container, this will also remove any inherited attributes
|
|
626
|
+
* from this instance only (it will not change the inherited attributes / container(s))
|
|
627
|
+
*/
|
|
628
|
+
clear: () => void;
|
|
629
|
+
/**
|
|
630
|
+
* Get the value of an attribute by key
|
|
631
|
+
* @param key - The attribute key to retrieve
|
|
632
|
+
* @param source - Optional filter to only check attributes from a specific source (Local or Inherited)
|
|
633
|
+
* @returns The attribute value if found, undefined otherwise
|
|
634
|
+
*/
|
|
635
|
+
get: (key: string, source?: eAttributeFilter) => V | undefined;
|
|
636
|
+
/**
|
|
637
|
+
* Check if an attribute exists by key
|
|
638
|
+
* @param key - The attribute key to check
|
|
639
|
+
* @param source - Optional filter to only check attributes from a specific source (Local or Inherited)
|
|
640
|
+
* @returns True if the attribute exists, false otherwise
|
|
641
|
+
*/
|
|
642
|
+
has: (key: string, source?: eAttributeFilter) => boolean;
|
|
643
|
+
/**
|
|
644
|
+
* Set the value of an attribute by key on this instance.
|
|
645
|
+
* @param key - The attribute key to set
|
|
646
|
+
* @param value - The value to assign to the named attribute
|
|
647
|
+
* @returns true if the value was successfully set / replaced
|
|
648
|
+
*/
|
|
649
|
+
set: (key: string, value: V) => boolean;
|
|
650
|
+
/**
|
|
651
|
+
* Delete an existing attribute, if the key doesn't exist this will return false. If the key does
|
|
652
|
+
* exist then it will be removed from this instance and any inherited value will be hidden (even if
|
|
653
|
+
* the inherited value changes)
|
|
654
|
+
* @param key - The attribute key to delete
|
|
655
|
+
* @returns True if the attribute was deleted, false if it didn't exist (which includes if it has already been deleted)
|
|
656
|
+
*/
|
|
657
|
+
del: (key: string) => boolean;
|
|
658
|
+
/**
|
|
659
|
+
* The keys() method returns a new iterator object that contains the existing keys for each element
|
|
660
|
+
* in this attribute container. It will return all locally set keys first and then the inherited keys.
|
|
661
|
+
* When a key exists in both the local and inherited attributes, only the local key will be returned.
|
|
662
|
+
* If the key has been deleted locally, it will not be included in the iterator.
|
|
663
|
+
* @returns An iterator over the keys of the attribute container
|
|
664
|
+
*/
|
|
665
|
+
keys: () => Iterator<string>;
|
|
666
|
+
/**
|
|
667
|
+
* The entries() method of returns a new iterator object that contains the [key, value, source?] tuples for
|
|
668
|
+
* each attribute, it returns all existing attributes of this instance including all inherited ones. If the
|
|
669
|
+
* same key exists in both the local and inherited attributes, only the first (non-deleted) tuple will be returned.
|
|
670
|
+
* If the key has been deleted, it will not be included in the iterator.
|
|
671
|
+
*
|
|
672
|
+
* The source value of the tuple identifies the origin of the attribute (Local or Inherited).
|
|
673
|
+
* @returns An iterator over the entries of the attribute container
|
|
674
|
+
*/
|
|
675
|
+
entries: () => Iterator<[string, V, eAttributeFilter]>;
|
|
676
|
+
/**
|
|
677
|
+
* The forEach() method of executes a provided function once per each key/value pair in this attribute container,
|
|
678
|
+
* it will process all local attributes first, then the inherited attributes. If the same key exists in both the
|
|
679
|
+
* local and inherited attributes, only the first (non-deleted) key/value pair will be processed.
|
|
680
|
+
* If a key has been deleted, it will not be included in the set of processed key/value pairs.
|
|
681
|
+
* @param callback - The function to execute for each key/value pair
|
|
682
|
+
* @param thisArg - Optional value to use as `this` when executing `callback`
|
|
683
|
+
*/
|
|
684
|
+
forEach: (callback: (key: string, value: V, source?: eAttributeFilter) => void, thisArg?: any) => void;
|
|
685
|
+
/**
|
|
686
|
+
* The values() method returns a new iterator instance that contains the values for each element in this
|
|
687
|
+
* attribute container. It will return all locally set values first and then the inherited values. If the
|
|
688
|
+
* same key is present in both the local or inherited attributes only the first (non-deleted) value will be
|
|
689
|
+
* returned. If a key has been deleted, it will not be included in the iterator.
|
|
690
|
+
* @returns An iterator over the values of the attribute container
|
|
691
|
+
*/
|
|
692
|
+
values: () => Iterator<V>;
|
|
693
|
+
/**
|
|
694
|
+
* Register a callback listener for any attribute changes, this will include local and inherited changes.
|
|
695
|
+
* @param callback - Function to be called when attributes change, receives change information
|
|
696
|
+
* @returns IUnloadHook instance with rm() function to remove this listener, once called it will never be invoked again
|
|
697
|
+
*/
|
|
698
|
+
listen: (callback: (changeInfo: IAttributeChangeInfo<V>) => void) => IUnloadHook;
|
|
699
|
+
/**
|
|
700
|
+
* Create a child attribute container that inherits from this one, optionally taking a snapshot
|
|
701
|
+
* so that any future changes to the parent container do not affect the child container.
|
|
702
|
+
* The child will use all of the configuration from the parent container.
|
|
703
|
+
* @param name - Optional name for the child container
|
|
704
|
+
* @param snapshot - If true, the child container will be a snapshot of the current state
|
|
705
|
+
* @returns A new attribute container instance
|
|
706
|
+
*/
|
|
707
|
+
child: (name?: string, snapshot?: boolean) => IAttributeContainer;
|
|
708
|
+
}
|
|
709
|
+
|
|
468
710
|
interface IBaseProcessingContext {
|
|
469
711
|
/**
|
|
470
712
|
* The current core instance for the request
|
|
@@ -529,6 +771,30 @@ declare namespace ApplicationInsights {
|
|
|
529
771
|
createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
|
|
530
772
|
}
|
|
531
773
|
|
|
774
|
+
/**
|
|
775
|
+
* A generic interface for holding a cached value
|
|
776
|
+
* @since 0.10.5
|
|
777
|
+
* @group Helpers
|
|
778
|
+
* @group Cache
|
|
779
|
+
* @typeParam T - The type of the value to be cached
|
|
780
|
+
* @example
|
|
781
|
+
* ```ts
|
|
782
|
+
* let cachedValue: ICachedValue<string> = {
|
|
783
|
+
* v: "some value"
|
|
784
|
+
* };
|
|
785
|
+
* ```
|
|
786
|
+
*/
|
|
787
|
+
interface ICachedValue<T> {
|
|
788
|
+
/**
|
|
789
|
+
* Returns the current cached value
|
|
790
|
+
*/
|
|
791
|
+
v: T;
|
|
792
|
+
/**
|
|
793
|
+
* Returns the current cached value
|
|
794
|
+
*/
|
|
795
|
+
toJSON(): T;
|
|
796
|
+
}
|
|
797
|
+
|
|
532
798
|
/**
|
|
533
799
|
* Provides data transmission capabilities
|
|
534
800
|
*/
|
|
@@ -555,7 +821,7 @@ declare namespace ApplicationInsights {
|
|
|
555
821
|
* you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
|
|
556
822
|
* will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
|
|
557
823
|
* will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
|
|
558
|
-
* @param
|
|
824
|
+
* @param isAsync - send data asynchronously when true
|
|
559
825
|
* @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
|
|
560
826
|
* If the caller doesn't return true the caller should assume that it may never be called.
|
|
561
827
|
* @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
|
|
@@ -563,9 +829,9 @@ declare namespace ApplicationInsights {
|
|
|
563
829
|
* should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
|
|
564
830
|
* [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
|
|
565
831
|
* the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
|
|
566
|
-
* and
|
|
832
|
+
* and isAsync is true.
|
|
567
833
|
*/
|
|
568
|
-
flush?(
|
|
834
|
+
flush?(isAsync: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void | IPromise<boolean>;
|
|
569
835
|
/**
|
|
570
836
|
* Get offline support
|
|
571
837
|
* @returns IInternalOfflineSupport
|
|
@@ -648,7 +914,7 @@ declare namespace ApplicationInsights {
|
|
|
648
914
|
/**
|
|
649
915
|
* Configuration provided to SDK core
|
|
650
916
|
*/
|
|
651
|
-
interface IConfiguration {
|
|
917
|
+
interface IConfiguration extends IOTelConfig {
|
|
652
918
|
/**
|
|
653
919
|
* Instrumentation key of resource. Either this or connectionString must be specified.
|
|
654
920
|
*/
|
|
@@ -964,6 +1230,14 @@ declare namespace ApplicationInsights {
|
|
|
964
1230
|
* @param cookieValue - The value to set to expire the cookie
|
|
965
1231
|
*/
|
|
966
1232
|
delCookie?: (name: string, cookieValue: string) => void;
|
|
1233
|
+
/**
|
|
1234
|
+
* Defaults to false, when true this will disable the deferral behavior that occurs when cookies are disabled,
|
|
1235
|
+
* reverting to the previous behavior where cookie operations would simply return false when cookies are disabled.
|
|
1236
|
+
* This is provided to maintain backward compatibility if applications depend on the previous behavior.
|
|
1237
|
+
* When false (default), cookie operations are deferred until cookies are enabled, supporting consent scenarios.
|
|
1238
|
+
* @since v3.3.10
|
|
1239
|
+
*/
|
|
1240
|
+
disableCookieDefer?: boolean;
|
|
967
1241
|
}
|
|
968
1242
|
|
|
969
1243
|
interface ICustomProperties {
|
|
@@ -1056,6 +1330,10 @@ declare namespace ApplicationInsights {
|
|
|
1056
1330
|
* / Promise to allow any listeners to wait for the operation to complete.
|
|
1057
1331
|
*/
|
|
1058
1332
|
unload?(isAsync?: boolean): void | IPromise<void>;
|
|
1333
|
+
/**
|
|
1334
|
+
* A flag that indicates whether this logger is in debug (throw real exceptions) mode
|
|
1335
|
+
*/
|
|
1336
|
+
readonly dbgMode?: boolean;
|
|
1059
1337
|
}
|
|
1060
1338
|
|
|
1061
1339
|
interface IDistributedTraceContext {
|
|
@@ -1134,8 +1412,12 @@ declare namespace ApplicationInsights {
|
|
|
1134
1412
|
* with practically sufficient probability by being made as 16 randomly
|
|
1135
1413
|
* generated bytes, encoded as a 32 lowercase hex characters corresponding to
|
|
1136
1414
|
* 128 bits.
|
|
1415
|
+
* @remarks It is NOT recommended that you dynamically change this value after creation and it is actively
|
|
1416
|
+
* being used as this may affect anyone accessing this context (as a parent for instance). You should logically
|
|
1417
|
+
* treat this as readonly after creation.
|
|
1137
1418
|
* @remarks If you update this value, it will only update for the current context, not the parent context,
|
|
1138
|
-
* if you need to update the current and ALL parent contexts, use the `setTraceId` method
|
|
1419
|
+
* if you need to update the current and ALL parent contexts, use the `setTraceId` method which
|
|
1420
|
+
* provides the previous behavior.
|
|
1139
1421
|
* @since 3.4.0
|
|
1140
1422
|
*/
|
|
1141
1423
|
traceId: string;
|
|
@@ -1173,8 +1455,8 @@ declare namespace ApplicationInsights {
|
|
|
1173
1455
|
traceFlags?: number;
|
|
1174
1456
|
/**
|
|
1175
1457
|
* Returns the current trace state which will be used to propgate context across different services.
|
|
1176
|
-
* Updating (adding / removing keys) of the trace state will modify the current context.
|
|
1177
|
-
* @remarks Unlike the OpenTelemetry {@link
|
|
1458
|
+
* Updating (adding / removing keys) of the trace state will modify the current context.IOTelTraceState
|
|
1459
|
+
* @remarks Unlike the OpenTelemetry {@link IOTelTraceState}, this value is a mutable object, so you can
|
|
1178
1460
|
* modify it directly you do not need to reassign the new value to this property.
|
|
1179
1461
|
* @since 3.4.0
|
|
1180
1462
|
*/
|
|
@@ -1254,7 +1536,7 @@ declare namespace ApplicationInsights {
|
|
|
1254
1536
|
* Identifies configuration override values when given feature is enabled
|
|
1255
1537
|
* NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
|
|
1256
1538
|
* you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: \{["extensionConfig.Analytics.disableAjaxTrackig"]:1\}
|
|
1257
|
-
*
|
|
1539
|
+
* @default undefined
|
|
1258
1540
|
*/
|
|
1259
1541
|
onCfg?: {
|
|
1260
1542
|
[field: string]: any;
|
|
@@ -1263,7 +1545,7 @@ declare namespace ApplicationInsights {
|
|
|
1263
1545
|
* Identifies configuration override values when given feature is disabled
|
|
1264
1546
|
* NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
|
|
1265
1547
|
* you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: \{["extensionConfig.Analytics.disableAjaxTrackig"]:1\}
|
|
1266
|
-
*
|
|
1548
|
+
* @default undefined
|
|
1267
1549
|
*/
|
|
1268
1550
|
offCfg?: {
|
|
1269
1551
|
[field: string]: any;
|
|
@@ -1359,8 +1641,9 @@ declare namespace ApplicationInsights {
|
|
|
1359
1641
|
* @param events - The array of events that have been discarded.
|
|
1360
1642
|
* @param reason - The reason for discarding the events. The EventsDiscardedReason
|
|
1361
1643
|
* constant should be used to check the different values.
|
|
1644
|
+
* @param sendType - [Optional] The send type used when the events were discarded.
|
|
1362
1645
|
*/
|
|
1363
|
-
eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
|
|
1646
|
+
eventsDiscarded?: (events: ITelemetryItem[], reason: number, sendType?: number) => void;
|
|
1364
1647
|
/**
|
|
1365
1648
|
* [Optional] A function called when the events have been requested to be sent to the sever.
|
|
1366
1649
|
* @param sendReason - The reason why the event batch is being sent.
|
|
@@ -1428,8 +1711,9 @@ declare namespace ApplicationInsights {
|
|
|
1428
1711
|
* @param events - The array of events that have been discarded by the SDK.
|
|
1429
1712
|
* @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
|
|
1430
1713
|
* constant should be used to check the different values.
|
|
1714
|
+
* @param sendType - [Optional] The send type used when the events were discarded.
|
|
1431
1715
|
*/
|
|
1432
|
-
eventsDiscarded(events: ITelemetryItem[], reason: number): void;
|
|
1716
|
+
eventsDiscarded(events: ITelemetryItem[], reason: number, sendType?: number): void;
|
|
1433
1717
|
/**
|
|
1434
1718
|
* [Optional] A function called when the events have been requested to be sent to the sever.
|
|
1435
1719
|
* @param sendReason - The reason why the event batch is being sent.
|
|
@@ -1481,74 +1765,1053 @@ declare namespace ApplicationInsights {
|
|
|
1481
1765
|
|
|
1482
1766
|
type _InternalMessageId = number | _eInternalMessageId;
|
|
1483
1767
|
|
|
1484
|
-
/** IPayloadData describes interface of payload sent via POST channel */
|
|
1485
|
-
interface IPayloadData {
|
|
1486
|
-
urlString: string;
|
|
1487
|
-
data: Uint8Array | string;
|
|
1488
|
-
headers?: {
|
|
1489
|
-
[name: string]: string;
|
|
1490
|
-
};
|
|
1491
|
-
timeout?: number;
|
|
1492
|
-
disableXhrSync?: boolean;
|
|
1493
|
-
disableFetchKeepAlive?: boolean;
|
|
1494
|
-
sendReason?: SendRequestReason;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
1768
|
/**
|
|
1498
|
-
*
|
|
1769
|
+
* The main OpenTelemetry API interface that provides access to all OpenTelemetry functionality.
|
|
1770
|
+
* This interface extends the IOTelTracerProvider and serves as the entry point for OpenTelemetry operations.
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
* ```typescript
|
|
1774
|
+
* // Get a tracer from the API instance
|
|
1775
|
+
* const tracer = otelApi.getTracer("my-component");
|
|
1776
|
+
*
|
|
1777
|
+
* // Create a span
|
|
1778
|
+
* const span = tracer.startSpan("operation");
|
|
1779
|
+
*
|
|
1780
|
+
* // Access context manager
|
|
1781
|
+
* const currentContext = otelApi.context.active();
|
|
1782
|
+
*
|
|
1783
|
+
* // Access trace API
|
|
1784
|
+
* const activeSpan = otelApi.trace.getActiveSpan();
|
|
1785
|
+
* ```
|
|
1786
|
+
*
|
|
1787
|
+
* @since 3.4.0
|
|
1499
1788
|
*/
|
|
1500
|
-
interface
|
|
1789
|
+
interface IOTelApi extends IOTelTracerProvider {
|
|
1501
1790
|
/**
|
|
1502
|
-
* The
|
|
1791
|
+
* The configuration object that contains all OpenTelemetry-specific settings.
|
|
1792
|
+
* This includes tracing configuration, error handlers, and other OpenTelemetry options.
|
|
1793
|
+
*
|
|
1794
|
+
* @remarks
|
|
1795
|
+
* Changes to this configuration after initialization may not take effect until
|
|
1796
|
+
* the next telemetry operation, depending on the implementation.
|
|
1503
1797
|
*/
|
|
1504
|
-
|
|
1798
|
+
cfg: IOTelConfig;
|
|
1505
1799
|
/**
|
|
1506
|
-
* The
|
|
1800
|
+
* The current {@link ITraceHost} instance for this IOTelApi instance, this is effectively
|
|
1801
|
+
* the OpenTelemetry ContextAPI instance without the static methods.
|
|
1802
|
+
* @returns The ContextManager instance
|
|
1507
1803
|
*/
|
|
1508
|
-
|
|
1804
|
+
host: ITraceHost;
|
|
1509
1805
|
/**
|
|
1510
|
-
* The
|
|
1511
|
-
* the
|
|
1806
|
+
* The current {@link ITraceApi} instance for this IOTelApi instance, this is
|
|
1807
|
+
* effectively the OpenTelemetry TraceAPI instance without the static methods.
|
|
1808
|
+
* @returns The current {@link ITraceApi} instance
|
|
1512
1809
|
*/
|
|
1513
|
-
|
|
1810
|
+
trace: ITraceApi;
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* Configuration interface for OpenTelemetry attribute limits.
|
|
1815
|
+
* These limits help control the size and number of attributes to prevent
|
|
1816
|
+
* excessive memory usage and ensure consistent performance.
|
|
1817
|
+
*
|
|
1818
|
+
* @example
|
|
1819
|
+
* ```typescript
|
|
1820
|
+
* const limits: IOTelAttributeLimits = {
|
|
1821
|
+
* attributeCountLimit: 128, // Maximum 128 attributes
|
|
1822
|
+
* attributeValueLengthLimit: 4096 // Maximum 4KB per attribute value
|
|
1823
|
+
* };
|
|
1824
|
+
* ```
|
|
1825
|
+
*
|
|
1826
|
+
* @remarks
|
|
1827
|
+
* When limits are exceeded:
|
|
1828
|
+
* - Additional attributes beyond `attributeCountLimit` are dropped
|
|
1829
|
+
* - Attribute values longer than `attributeValueLengthLimit` are truncated
|
|
1830
|
+
* - The behavior may vary based on the specific implementation
|
|
1831
|
+
*
|
|
1832
|
+
* @since 3.4.0
|
|
1833
|
+
*/
|
|
1834
|
+
interface IOTelAttributeLimits {
|
|
1514
1835
|
/**
|
|
1515
|
-
*
|
|
1836
|
+
* Maximum allowed length for attribute values in characters.
|
|
1837
|
+
*
|
|
1838
|
+
* @remarks
|
|
1839
|
+
* - Values longer than this limit will be truncated
|
|
1840
|
+
* - Applies to string attribute values only
|
|
1841
|
+
* - Numeric and boolean values are not affected by this limit
|
|
1842
|
+
* - Array values have this limit applied to each individual element
|
|
1843
|
+
*
|
|
1844
|
+
* @defaultValue 4096
|
|
1845
|
+
*
|
|
1846
|
+
* @example
|
|
1847
|
+
* ```typescript
|
|
1848
|
+
* // If attributeValueLengthLimit is 100:
|
|
1849
|
+
* span.setAttribute("description", "a".repeat(200)); // Will be truncated to 100 characters
|
|
1850
|
+
* span.setAttribute("count", 12345); // Not affected (number)
|
|
1851
|
+
* span.setAttribute("enabled", true); // Not affected (boolean)
|
|
1852
|
+
* ```
|
|
1516
1853
|
*/
|
|
1517
|
-
|
|
1854
|
+
attributeValueLengthLimit?: number;
|
|
1518
1855
|
/**
|
|
1519
|
-
*
|
|
1520
|
-
*
|
|
1856
|
+
* Maximum number of attributes allowed per telemetry item.
|
|
1857
|
+
*
|
|
1858
|
+
* @remarks
|
|
1859
|
+
* - Attributes added beyond this limit will be dropped
|
|
1860
|
+
* - The order of attributes matters; earlier attributes take precedence
|
|
1861
|
+
* - This limit applies to the total count of attributes, regardless of their type
|
|
1862
|
+
* - Inherited or default attributes count toward this limit
|
|
1863
|
+
*
|
|
1864
|
+
* @defaultValue 128
|
|
1865
|
+
*
|
|
1866
|
+
* @example
|
|
1867
|
+
* ```typescript
|
|
1868
|
+
* // If attributeCountLimit is 5:
|
|
1869
|
+
* span.setAttributes({
|
|
1870
|
+
* "attr1": "value1", // Kept
|
|
1871
|
+
* "attr2": "value2", // Kept
|
|
1872
|
+
* "attr3": "value3", // Kept
|
|
1873
|
+
* "attr4": "value4", // Kept
|
|
1874
|
+
* "attr5": "value5", // Kept
|
|
1875
|
+
* "attr6": "value6" // Dropped (exceeds limit)
|
|
1876
|
+
* });
|
|
1877
|
+
* ```
|
|
1521
1878
|
*/
|
|
1522
|
-
|
|
1879
|
+
attributeCountLimit?: number;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
/**
|
|
1883
|
+
* Attributes is a map from string to attribute values.
|
|
1884
|
+
*
|
|
1885
|
+
* Note: only the own enumerable keys are counted as valid attribute keys.
|
|
1886
|
+
*
|
|
1887
|
+
* @since 3.4.0
|
|
1888
|
+
*/
|
|
1889
|
+
interface IOTelAttributes {
|
|
1890
|
+
[key: string]: OTelAttributeValue | undefined;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/**
|
|
1894
|
+
* OpenTelemetry configuration interface
|
|
1895
|
+
* Provides configuration specific to the OpenTelemetry extensions
|
|
1896
|
+
*/
|
|
1897
|
+
interface IOTelConfig {
|
|
1523
1898
|
/**
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1899
|
+
* Configuration interface for OpenTelemetry tracing functionality.
|
|
1900
|
+
* This interface contains all the settings that control how traces are created,
|
|
1901
|
+
* processed, and managed within the OpenTelemetry system.
|
|
1902
|
+
*
|
|
1903
|
+
* @example
|
|
1904
|
+
* ```typescript
|
|
1905
|
+
* const traceCfg: ITraceCfg = {
|
|
1906
|
+
* serviceName: "my-service",
|
|
1907
|
+
* generalLimits: {
|
|
1908
|
+
* attributeCountLimit: 128,
|
|
1909
|
+
* attributeValueLengthLimit: 4096
|
|
1910
|
+
* },
|
|
1911
|
+
* spanLimits: {
|
|
1912
|
+
* attributeCountLimit: 128,
|
|
1913
|
+
* linkCountLimit: 128,
|
|
1914
|
+
* eventCountLimit: 128
|
|
1915
|
+
* }
|
|
1916
|
+
* };
|
|
1917
|
+
* ```
|
|
1918
|
+
*
|
|
1919
|
+
* @since 3.4.0
|
|
1526
1920
|
*/
|
|
1527
|
-
|
|
1921
|
+
traceCfg?: ITraceCfg;
|
|
1528
1922
|
/**
|
|
1529
|
-
*
|
|
1923
|
+
* Error handlers for OpenTelemetry operations.
|
|
1924
|
+
* This interface allows you to specify custom error handling logic for various
|
|
1925
|
+
* OpenTelemetry components, enabling better control over how errors are managed
|
|
1926
|
+
* within the OpenTelemetry system.
|
|
1927
|
+
*
|
|
1928
|
+
* @see {@link IOTelErrorHandlers}
|
|
1929
|
+
*
|
|
1930
|
+
* @example
|
|
1931
|
+
* ```typescript
|
|
1932
|
+
* const errorHandlers: IOTelErrorHandlers = {
|
|
1933
|
+
* attribError: (message, key, value) => {
|
|
1934
|
+
* console.warn(`Attribute error for ${key}:`, message);
|
|
1935
|
+
* }
|
|
1936
|
+
* };
|
|
1937
|
+
* ```
|
|
1530
1938
|
*/
|
|
1531
|
-
|
|
1939
|
+
errorHandlers?: IOTelErrorHandlers;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
/**
|
|
1943
|
+
* Configuration interface for OpenTelemetry error handling callbacks.
|
|
1944
|
+
* Provides hooks to customize how different types of errors and diagnostic
|
|
1945
|
+
* messages are handled within the OpenTelemetry system.
|
|
1946
|
+
*
|
|
1947
|
+
* @example
|
|
1948
|
+
* ```typescript
|
|
1949
|
+
* const errorHandlers: IOTelErrorHandlers = {
|
|
1950
|
+
* attribError: (message, key, value) => {
|
|
1951
|
+
* console.warn(`Attribute error for ${key}:`, message);
|
|
1952
|
+
* },
|
|
1953
|
+
* spanError: (message, spanName) => {
|
|
1954
|
+
* logger.error(`Span ${spanName} error:`, message);
|
|
1955
|
+
* },
|
|
1956
|
+
* warn: (message) => {
|
|
1957
|
+
* logger.warn(message);
|
|
1958
|
+
* },
|
|
1959
|
+
* error: (message) => {
|
|
1960
|
+
* logger.error(message);
|
|
1961
|
+
* }
|
|
1962
|
+
* };
|
|
1963
|
+
* ```
|
|
1964
|
+
*
|
|
1965
|
+
* @remarks
|
|
1966
|
+
* If handlers are not provided, default behavior will be used:
|
|
1967
|
+
* - `attribError`: Throws an `OTelInvalidAttributeError`
|
|
1968
|
+
* - `spanError`: Logs to console or calls warn handler
|
|
1969
|
+
* - `debug`: Logs to console.log
|
|
1970
|
+
* - `warn`: Logs to console.warn
|
|
1971
|
+
* - `error`: Logs to console.error
|
|
1972
|
+
* - `notImplemented`: Logs to console.error
|
|
1973
|
+
*
|
|
1974
|
+
* @since 3.4.0
|
|
1975
|
+
*/
|
|
1976
|
+
interface IOTelErrorHandlers {
|
|
1532
1977
|
/**
|
|
1533
|
-
*
|
|
1978
|
+
* Handles attribute-related errors, such as invalid attribute values or keys.
|
|
1979
|
+
* Called when an attribute operation fails validation or processing.
|
|
1980
|
+
*
|
|
1981
|
+
* @param message - Descriptive error message explaining what went wrong
|
|
1982
|
+
* @param key - The attribute key that caused the error
|
|
1983
|
+
* @param value - The attribute value that caused the error (may be of any type)
|
|
1984
|
+
*
|
|
1985
|
+
* @remarks
|
|
1986
|
+
* Common scenarios that trigger this handler:
|
|
1987
|
+
* - Invalid attribute key format
|
|
1988
|
+
* - Attribute value exceeds length limits
|
|
1989
|
+
* - Unsupported attribute value type
|
|
1990
|
+
* - Attribute count exceeds limits
|
|
1991
|
+
*
|
|
1992
|
+
* @default Throws an `OTelInvalidAttributeError`
|
|
1993
|
+
*
|
|
1994
|
+
* @example
|
|
1995
|
+
* ```typescript
|
|
1996
|
+
* attribError: (message, key, value) => {
|
|
1997
|
+
* metrics.increment('otel.attribute.errors', { key, type: typeof value });
|
|
1998
|
+
* logger.warn(`Attribute ${key} rejected: ${message}`);
|
|
1999
|
+
* }
|
|
2000
|
+
* ```
|
|
1534
2001
|
*/
|
|
1535
|
-
|
|
2002
|
+
attribError?: (message: string, key: string, value: any) => void;
|
|
1536
2003
|
/**
|
|
1537
|
-
*
|
|
2004
|
+
* Handles span-related errors that occur during span operations.
|
|
2005
|
+
* Called when a span operation fails or encounters an unexpected condition.
|
|
2006
|
+
*
|
|
2007
|
+
* @param message - Descriptive error message explaining the span error
|
|
2008
|
+
* @param spanName - The name of the span that encountered the error
|
|
2009
|
+
*
|
|
2010
|
+
* @remarks
|
|
2011
|
+
* Common scenarios that trigger this handler:
|
|
2012
|
+
* - Span operation called on an ended span
|
|
2013
|
+
* - Invalid span configuration
|
|
2014
|
+
* - Span processor errors
|
|
2015
|
+
* - Context propagation failures
|
|
2016
|
+
*
|
|
2017
|
+
* @default Logs to console or calls the warn handler
|
|
2018
|
+
*
|
|
2019
|
+
* @example
|
|
2020
|
+
* ```typescript
|
|
2021
|
+
* spanError: (message, spanName) => {
|
|
2022
|
+
* metrics.increment('otel.span.errors', { span_name: spanName });
|
|
2023
|
+
* logger.error(`Span operation failed for "${spanName}": ${message}`);
|
|
2024
|
+
* }
|
|
2025
|
+
* ```
|
|
1538
2026
|
*/
|
|
1539
|
-
|
|
2027
|
+
spanError?: (message: string, spanName: string) => void;
|
|
1540
2028
|
/**
|
|
1541
|
-
*
|
|
2029
|
+
* Handles debug-level diagnostic messages.
|
|
2030
|
+
* Used for detailed troubleshooting information that is typically
|
|
2031
|
+
* only relevant during development or when diagnosing issues.
|
|
2032
|
+
*
|
|
2033
|
+
* @param message - Debug message to be handled
|
|
2034
|
+
*
|
|
2035
|
+
* @remarks
|
|
2036
|
+
* Debug messages are typically:
|
|
2037
|
+
* - Verbose operational details
|
|
2038
|
+
* - Internal state information
|
|
2039
|
+
* - Performance metrics
|
|
2040
|
+
* - Development-time diagnostics
|
|
2041
|
+
*
|
|
2042
|
+
* @default Logs to console.log
|
|
2043
|
+
*
|
|
2044
|
+
* @example
|
|
2045
|
+
* ```typescript
|
|
2046
|
+
* debug: (message) => {
|
|
2047
|
+
* if (process.env.NODE_ENV === 'development') {
|
|
2048
|
+
* console.debug('[OTel Debug]', message);
|
|
2049
|
+
* }
|
|
2050
|
+
* }
|
|
2051
|
+
* ```
|
|
1542
2052
|
*/
|
|
1543
|
-
|
|
2053
|
+
debug?: (message: string) => void;
|
|
1544
2054
|
/**
|
|
1545
|
-
*
|
|
2055
|
+
* Handles warning-level messages for non-fatal issues.
|
|
2056
|
+
* Used for conditions that are unusual but don't prevent continued operation.
|
|
2057
|
+
*
|
|
2058
|
+
* @param message - Warning message to be handled
|
|
2059
|
+
*
|
|
2060
|
+
* @remarks
|
|
2061
|
+
* Warning scenarios include:
|
|
2062
|
+
* - Configuration issues that fall back to defaults
|
|
2063
|
+
* - Performance degradation
|
|
2064
|
+
* - Deprecated API usage
|
|
2065
|
+
* - Resource limit approaches
|
|
2066
|
+
*
|
|
2067
|
+
* @default Logs to console.warn
|
|
2068
|
+
*
|
|
2069
|
+
* @example
|
|
2070
|
+
* ```typescript
|
|
2071
|
+
* warn: (message) => {
|
|
2072
|
+
* logger.warn('[OTel Warning]', message);
|
|
2073
|
+
* metrics.increment('otel.warnings');
|
|
2074
|
+
* }
|
|
2075
|
+
* ```
|
|
1546
2076
|
*/
|
|
1547
|
-
|
|
2077
|
+
warn?: (message: string) => void;
|
|
1548
2078
|
/**
|
|
1549
|
-
*
|
|
1550
|
-
|
|
1551
|
-
|
|
2079
|
+
* Handles general error conditions that may affect functionality.
|
|
2080
|
+
* Used for significant errors that should be investigated but may not be fatal.
|
|
2081
|
+
*
|
|
2082
|
+
* @param message - Error message to be handled
|
|
2083
|
+
*
|
|
2084
|
+
* @remarks
|
|
2085
|
+
* Error scenarios include:
|
|
2086
|
+
* - Failed network requests
|
|
2087
|
+
* - Configuration validation failures
|
|
2088
|
+
* - Resource allocation failures
|
|
2089
|
+
* - Unexpected runtime conditions
|
|
2090
|
+
*
|
|
2091
|
+
* @default Logs to console.error
|
|
2092
|
+
*
|
|
2093
|
+
* @example
|
|
2094
|
+
* ```typescript
|
|
2095
|
+
* error: (message) => {
|
|
2096
|
+
* logger.error('[OTel Error]', message);
|
|
2097
|
+
* errorReporting.captureException(new Error(message));
|
|
2098
|
+
* }
|
|
2099
|
+
* ```
|
|
2100
|
+
*/
|
|
2101
|
+
error?: (message: string) => void;
|
|
2102
|
+
/**
|
|
2103
|
+
* Handles errors related to unimplemented functionality.
|
|
2104
|
+
* Called when a method or feature is not yet implemented or is intentionally
|
|
2105
|
+
* disabled in the current configuration.
|
|
2106
|
+
*
|
|
2107
|
+
* @param message - Message describing the unimplemented functionality
|
|
2108
|
+
*
|
|
2109
|
+
* @remarks
|
|
2110
|
+
* Common scenarios:
|
|
2111
|
+
* - Placeholder methods that haven't been implemented
|
|
2112
|
+
* - Features disabled in the current build
|
|
2113
|
+
* - Platform-specific functionality not available
|
|
2114
|
+
* - Optional features not included in the configuration
|
|
2115
|
+
*
|
|
2116
|
+
* @default Logs to console.error
|
|
2117
|
+
*
|
|
2118
|
+
* @example
|
|
2119
|
+
* ```typescript
|
|
2120
|
+
* notImplemented: (message) => {
|
|
2121
|
+
* logger.warn(`[OTel Not Implemented] ${message}`);
|
|
2122
|
+
* if (process.env.NODE_ENV === 'development') {
|
|
2123
|
+
* console.trace('Not implemented method called');
|
|
2124
|
+
* }
|
|
2125
|
+
* }
|
|
2126
|
+
* ```
|
|
2127
|
+
*/
|
|
2128
|
+
notImplemented?: (message: string) => void;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
interface IOTelExceptionWithCode {
|
|
2132
|
+
code: string | number;
|
|
2133
|
+
name?: string;
|
|
2134
|
+
message?: string;
|
|
2135
|
+
stack?: string;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
interface IOTelExceptionWithMessage {
|
|
2139
|
+
code?: string | number;
|
|
2140
|
+
message: string;
|
|
2141
|
+
name?: string;
|
|
2142
|
+
stack?: string;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
interface IOTelExceptionWithName {
|
|
2146
|
+
code?: string | number;
|
|
2147
|
+
message?: string;
|
|
2148
|
+
name: string;
|
|
2149
|
+
stack?: string;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
/**
|
|
2153
|
+
* Enhanced high-resolution time interface that extends the base tuple with additional properties.
|
|
2154
|
+
* Provides a more structured way to work with high-resolution timestamps.
|
|
2155
|
+
*
|
|
2156
|
+
* @example
|
|
2157
|
+
* ```typescript
|
|
2158
|
+
* const hrTime: IOTelHrTime = {
|
|
2159
|
+
* 0: 1609459200, // seconds since Unix epoch
|
|
2160
|
+
* 1: 500000000, // nanoseconds (0-999,999,999)
|
|
2161
|
+
* };
|
|
2162
|
+
* ```
|
|
2163
|
+
*
|
|
2164
|
+
* @since 3.4.0
|
|
2165
|
+
*/
|
|
2166
|
+
interface IOTelHrTime extends OTelHrTimeBase {
|
|
2167
|
+
/**
|
|
2168
|
+
* Seconds since Unix epoch (January 1, 1970 00:00:00 UTC).
|
|
2169
|
+
* Must be a non-negative integer.
|
|
2170
|
+
*/
|
|
2171
|
+
0: number;
|
|
2172
|
+
/**
|
|
2173
|
+
* Nanoseconds within the second specified by index 0.
|
|
2174
|
+
* Must be in the range [0, 999999999].
|
|
2175
|
+
*/
|
|
2176
|
+
1: number;
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
/**
|
|
2180
|
+
* Provides an OpenTelemetry compatible interface for spans conforming to the OpenTelemetry API specification (v1.9.0).
|
|
2181
|
+
*
|
|
2182
|
+
* A span represents an operation within a trace and is the fundamental unit of work in distributed tracing.
|
|
2183
|
+
* Spans can be thought of as a grouping mechanism for a set of operations that are executed as part of
|
|
2184
|
+
* a single logical unit of work, providing timing information and contextual data about the operation.
|
|
2185
|
+
*
|
|
2186
|
+
* Spans form a tree structure within a trace, with a single root span that may have zero or more child spans,
|
|
2187
|
+
* which in turn may have their own children. This hierarchical structure allows for detailed analysis of
|
|
2188
|
+
* complex, multi-step operations across distributed systems.
|
|
2189
|
+
*
|
|
2190
|
+
* @since 3.4.0
|
|
2191
|
+
*
|
|
2192
|
+
* @remarks
|
|
2193
|
+
* - All spans created by this library implement the ISpan interface and extend the IReadableSpan interface
|
|
2194
|
+
* - Spans should be ended by calling `end()` when the operation completes
|
|
2195
|
+
* - Once ended, spans should generally not be used for further operations
|
|
2196
|
+
* - Spans automatically track timing information from creation to end
|
|
2197
|
+
*
|
|
2198
|
+
* @example
|
|
2199
|
+
* ```typescript
|
|
2200
|
+
* // Basic span usage
|
|
2201
|
+
* const span = tracer.startSpan('user-authentication');
|
|
2202
|
+
* span.setAttribute('user.id', '12345');
|
|
2203
|
+
* span.setAttribute('auth.method', 'oauth2');
|
|
2204
|
+
*
|
|
2205
|
+
* try {
|
|
2206
|
+
* const result = await authenticateUser();
|
|
2207
|
+
* span.setStatus({ code: SpanStatusCode.OK });
|
|
2208
|
+
* span.setAttribute('auth.success', true);
|
|
2209
|
+
* } catch (error) {
|
|
2210
|
+
* span.recordException(error);
|
|
2211
|
+
* span.setStatus({
|
|
2212
|
+
* code: SpanStatusCode.ERROR,
|
|
2213
|
+
* message: 'Authentication failed'
|
|
2214
|
+
* });
|
|
2215
|
+
* } finally {
|
|
2216
|
+
* span.end();
|
|
2217
|
+
* }
|
|
2218
|
+
* ```
|
|
2219
|
+
*/
|
|
2220
|
+
interface IOTelSpan {
|
|
2221
|
+
/**
|
|
2222
|
+
* Returns the span context object associated with this span.
|
|
2223
|
+
*
|
|
2224
|
+
* The span context is an immutable, serializable identifier that uniquely identifies
|
|
2225
|
+
* this span within a trace. It contains the trace ID, span ID, and trace flags that
|
|
2226
|
+
* can be used to create new child spans or propagate trace context across process boundaries.
|
|
2227
|
+
*
|
|
2228
|
+
* The returned span context remains valid even after the span has ended, making it
|
|
2229
|
+
* useful for asynchronous operations and cross-service communication.
|
|
2230
|
+
*
|
|
2231
|
+
* @returns The immutable span context associated with this span
|
|
2232
|
+
*
|
|
2233
|
+
* @remarks
|
|
2234
|
+
* - The span context is the primary mechanism for trace propagation
|
|
2235
|
+
* - Context can be serialized and transmitted across network boundaries
|
|
2236
|
+
* - Contains trace ID (unique to the entire trace) and span ID (unique to this span)
|
|
2237
|
+
*
|
|
2238
|
+
* @example
|
|
2239
|
+
* ```typescript
|
|
2240
|
+
* const span = tracer.startSpan('parent-operation');
|
|
2241
|
+
* const spanContext = span.spanContext();
|
|
2242
|
+
*
|
|
2243
|
+
* // Use context to create child spans in other parts of the system
|
|
2244
|
+
* const childSpan = tracer.startSpan('child-operation', {
|
|
2245
|
+
* parent: spanContext
|
|
2246
|
+
* });
|
|
2247
|
+
*
|
|
2248
|
+
* // Context can be serialized for cross-service propagation
|
|
2249
|
+
* const traceId = spanContext.traceId;
|
|
2250
|
+
* const spanId = spanContext.spanId;
|
|
2251
|
+
* ```
|
|
2252
|
+
*/
|
|
2253
|
+
spanContext(): IDistributedTraceContext;
|
|
2254
|
+
/**
|
|
2255
|
+
* Sets a single attribute on the span with the specified key and value.
|
|
2256
|
+
*
|
|
2257
|
+
* Attributes provide contextual information about the operation represented by the span.
|
|
2258
|
+
* They are key-value pairs that help with filtering, grouping, and understanding spans
|
|
2259
|
+
* in trace analysis tools. Attributes should represent meaningful properties of the operation.
|
|
2260
|
+
*
|
|
2261
|
+
* @param key - The attribute key, should be descriptive and follow naming conventions
|
|
2262
|
+
* @param value - The attribute value; null or undefined values are invalid and result in undefined behavior
|
|
2263
|
+
*
|
|
2264
|
+
* @returns This span instance for method chaining
|
|
2265
|
+
*
|
|
2266
|
+
* @remarks
|
|
2267
|
+
* - Attribute keys should follow semantic conventions when available
|
|
2268
|
+
* - Common attributes include service.name, http.method, db.statement, etc.
|
|
2269
|
+
* - Setting null or undefined values is invalid and may cause unexpected behavior
|
|
2270
|
+
* - Attributes set after span creation don't affect sampling decisions
|
|
2271
|
+
*
|
|
2272
|
+
* @example
|
|
2273
|
+
* ```typescript
|
|
2274
|
+
* const span = tracer.startSpan('http-request');
|
|
2275
|
+
*
|
|
2276
|
+
* // Set individual attributes with descriptive keys
|
|
2277
|
+
* span.setAttribute('http.method', 'POST')
|
|
2278
|
+
* .setAttribute('http.url', 'https://api.example.com/users')
|
|
2279
|
+
* .setAttribute('http.status_code', 201)
|
|
2280
|
+
* .setAttribute('user.id', '12345')
|
|
2281
|
+
* .setAttribute('request.size', 1024);
|
|
2282
|
+
* ```
|
|
2283
|
+
*/
|
|
2284
|
+
setAttribute(key: string, value: OTelAttributeValue): this;
|
|
2285
|
+
/**
|
|
2286
|
+
* Sets multiple attributes on the span at once using an attributes object.
|
|
2287
|
+
*
|
|
2288
|
+
* This method allows efficient batch setting of multiple attributes in a single call.
|
|
2289
|
+
* All attributes in the provided object will be added to the span, supplementing any
|
|
2290
|
+
* existing attributes (duplicate keys will be overwritten).
|
|
2291
|
+
*
|
|
2292
|
+
* @param attributes - An object containing key-value pairs to set as span attributes
|
|
2293
|
+
*
|
|
2294
|
+
* @returns This span instance for method chaining
|
|
2295
|
+
*
|
|
2296
|
+
* @remarks
|
|
2297
|
+
* - Null or undefined attribute values are invalid and will result in undefined behavior
|
|
2298
|
+
* - More efficient than multiple `setAttribute` calls for bulk operations
|
|
2299
|
+
* - Existing attributes with the same keys will be overwritten
|
|
2300
|
+
*
|
|
2301
|
+
* @example
|
|
2302
|
+
* ```typescript
|
|
2303
|
+
* const span = tracer.startSpan('database-query');
|
|
2304
|
+
*
|
|
2305
|
+
* // Set multiple attributes efficiently
|
|
2306
|
+
* span.setAttributes({
|
|
2307
|
+
* 'db.system': 'postgresql',
|
|
2308
|
+
* 'db.name': 'user_database',
|
|
2309
|
+
* 'db.table': 'users',
|
|
2310
|
+
* 'db.operation': 'SELECT',
|
|
2311
|
+
* 'db.rows_affected': 5,
|
|
2312
|
+
* 'query.duration_ms': 15.7
|
|
2313
|
+
* });
|
|
2314
|
+
* ```
|
|
2315
|
+
*/
|
|
2316
|
+
setAttributes(attributes: IOTelAttributes): this;
|
|
2317
|
+
/**
|
|
2318
|
+
* The {@link IAttributeContainer | attribute container} associated with this span, providing
|
|
2319
|
+
* advanced attribute management capabilities. Rather than using the {@link IReadableSpan#attributes}
|
|
2320
|
+
* directly which returns a readonly {@link IOTelAttributes} map that is a snapshot of the attributes at
|
|
2321
|
+
* the time of access, the attribute container offers methods to get, set, delete, and iterate over attributes
|
|
2322
|
+
* with fine-grained control.
|
|
2323
|
+
* It is recommended that you only access the {@link IReadableSpan#attributes} property sparingly due to the
|
|
2324
|
+
* performance cost of taking a snapshot of all attributes.
|
|
2325
|
+
*/
|
|
2326
|
+
readonly attribContainer: IAttributeContainer;
|
|
2327
|
+
/**
|
|
2328
|
+
* Sets the status of the span to indicate the success or failure of the operation.
|
|
2329
|
+
*
|
|
2330
|
+
* The span status provides a standardized way to indicate whether the operation
|
|
2331
|
+
* completed successfully, encountered an error, or is in an unknown state.
|
|
2332
|
+
* This status is used by observability tools to provide meaningful insights
|
|
2333
|
+
* about system health and operation outcomes.
|
|
2334
|
+
*
|
|
2335
|
+
* @param status - The status object containing code and optional message
|
|
2336
|
+
*
|
|
2337
|
+
* @returns This span instance for method chaining
|
|
2338
|
+
*
|
|
2339
|
+
* @remarks
|
|
2340
|
+
* - Default status is UNSET until explicitly set
|
|
2341
|
+
* - Setting status overrides any previous status values
|
|
2342
|
+
* - ERROR status should be accompanied by a descriptive message when possible
|
|
2343
|
+
* - Status should reflect the final outcome of the operation
|
|
2344
|
+
*
|
|
2345
|
+
* @example
|
|
2346
|
+
* ```typescript
|
|
2347
|
+
* const span = tracer.startSpan('payment-processing');
|
|
2348
|
+
*
|
|
2349
|
+
* try {
|
|
2350
|
+
* const result = await processPayment(paymentData);
|
|
2351
|
+
*
|
|
2352
|
+
* // Indicate successful completion
|
|
2353
|
+
* span.setStatus({
|
|
2354
|
+
* code: SpanStatusCode.OK
|
|
2355
|
+
* });
|
|
2356
|
+
*
|
|
2357
|
+
* } catch (error) {
|
|
2358
|
+
* // Indicate operation failed
|
|
2359
|
+
* span.setStatus({
|
|
2360
|
+
* code: SpanStatusCode.ERROR,
|
|
2361
|
+
* message: 'Payment processing failed: ' + error.message
|
|
2362
|
+
* });
|
|
2363
|
+
*
|
|
2364
|
+
* span.recordException(error);
|
|
2365
|
+
* }
|
|
2366
|
+
* ```
|
|
2367
|
+
*/
|
|
2368
|
+
setStatus(status: IOTelSpanStatus): this;
|
|
2369
|
+
/**
|
|
2370
|
+
* Updates the name of the span, overriding the name provided during creation.
|
|
2371
|
+
*
|
|
2372
|
+
* Span names should be descriptive and represent the operation being performed.
|
|
2373
|
+
* Updating the name can be useful when the operation's scope becomes clearer
|
|
2374
|
+
* during execution, or when implementing generic spans that need specific naming
|
|
2375
|
+
* based on runtime conditions.
|
|
2376
|
+
*
|
|
2377
|
+
* @param name - The new name for the span, should be descriptive of the operation
|
|
2378
|
+
*
|
|
2379
|
+
* @returns This span instance for method chaining
|
|
2380
|
+
*
|
|
2381
|
+
* @remarks
|
|
2382
|
+
* - Name updates may affect sampling behavior depending on implementation
|
|
2383
|
+
* - Choose names that are meaningful but not too specific to avoid cardinality issues
|
|
2384
|
+
* - Follow naming conventions consistent with your observability strategy
|
|
2385
|
+
* - Consider the impact on existing traces and dashboards when changing names
|
|
2386
|
+
*
|
|
2387
|
+
* @example
|
|
2388
|
+
* ```typescript
|
|
2389
|
+
* const span = tracer.startSpan('generic-operation');
|
|
2390
|
+
*
|
|
2391
|
+
* // Update name based on runtime determination
|
|
2392
|
+
* if (operationType === 'user-registration') {
|
|
2393
|
+
* span.updateName('user-registration');
|
|
2394
|
+
* span.setAttribute('operation.type', 'registration');
|
|
2395
|
+
* } else if (operationType === 'user-login') {
|
|
2396
|
+
* span.updateName('user-authentication');
|
|
2397
|
+
* span.setAttribute('operation.type', 'authentication');
|
|
2398
|
+
* }
|
|
2399
|
+
* ```
|
|
2400
|
+
*/
|
|
2401
|
+
updateName(name: string): this;
|
|
2402
|
+
/**
|
|
2403
|
+
* Marks the end of the span's execution and records the end timestamp.
|
|
2404
|
+
*
|
|
2405
|
+
* This method finalizes the span and makes it available for export to tracing systems.
|
|
2406
|
+
* Once ended, the span should not be used for further operations. The span's duration
|
|
2407
|
+
* is calculated from its start time to the end time provided or current time.
|
|
2408
|
+
*
|
|
2409
|
+
* @param endTime - Optional end time; if not provided, current time is used
|
|
2410
|
+
*
|
|
2411
|
+
* @remarks
|
|
2412
|
+
* - This method does NOT return `this` to discourage chaining after span completion
|
|
2413
|
+
* - Ending a span has no effect on child spans, which may continue running
|
|
2414
|
+
* - Child spans can be ended independently after their parent has ended
|
|
2415
|
+
* - The span becomes eligible for export once ended
|
|
2416
|
+
* - Calling end() multiple times has no additional effect
|
|
2417
|
+
*
|
|
2418
|
+
* @example
|
|
2419
|
+
* ```typescript
|
|
2420
|
+
* const span = tracer.startSpan('file-processing');
|
|
2421
|
+
*
|
|
2422
|
+
* try {
|
|
2423
|
+
* // Perform the operation
|
|
2424
|
+
* const result = await processFile(filePath);
|
|
2425
|
+
*
|
|
2426
|
+
* // Record success
|
|
2427
|
+
* span.setStatus({ code: SpanStatusCode.OK });
|
|
2428
|
+
* span.setAttribute('file.size', result.size);
|
|
2429
|
+
*
|
|
2430
|
+
* } catch (error) {
|
|
2431
|
+
* span.recordException(error);
|
|
2432
|
+
* span.setStatus({
|
|
2433
|
+
* code: SpanStatusCode.ERROR,
|
|
2434
|
+
* message: error.message
|
|
2435
|
+
* });
|
|
2436
|
+
* } finally {
|
|
2437
|
+
* // Always end the span
|
|
2438
|
+
* span.end();
|
|
2439
|
+
* // Don't use span after this point
|
|
2440
|
+
* }
|
|
2441
|
+
*
|
|
2442
|
+
* // Custom end time example
|
|
2443
|
+
* const customEndTime = Date.now() * 1000000; // nanoseconds
|
|
2444
|
+
* span.end(customEndTime);
|
|
2445
|
+
* ```
|
|
2446
|
+
*/
|
|
2447
|
+
end(endTime?: OTelTimeInput): void;
|
|
2448
|
+
/**
|
|
2449
|
+
* Returns whether this span is actively recording information.
|
|
2450
|
+
*
|
|
2451
|
+
* A recording span accepts and stores attributes, events, status, and other span data.
|
|
2452
|
+
* Non-recording spans (typically due to sampling decisions) may ignore operations
|
|
2453
|
+
* like setAttribute() to optimize performance. This method allows conditional
|
|
2454
|
+
* logic to avoid expensive operations on non-recording spans.
|
|
2455
|
+
*
|
|
2456
|
+
* @returns True if the span is actively recording information, false otherwise
|
|
2457
|
+
*
|
|
2458
|
+
* @remarks
|
|
2459
|
+
* - Recording status is typically determined at span creation time
|
|
2460
|
+
* - Non-recording spans still provide valid span context for propagation
|
|
2461
|
+
* - Use this check to avoid expensive attribute calculations for non-recording spans
|
|
2462
|
+
* - Recording status remains constant throughout the span's lifetime
|
|
2463
|
+
*
|
|
2464
|
+
* @example
|
|
2465
|
+
* ```typescript
|
|
2466
|
+
* const span = tracer.startSpan('data-processing');
|
|
2467
|
+
*
|
|
2468
|
+
* // Only perform expensive operations if span is recording
|
|
2469
|
+
* if (span.isRecording()) {
|
|
2470
|
+
* const metadata = await expensiveMetadataCalculation();
|
|
2471
|
+
* span.setAttributes({
|
|
2472
|
+
* 'process.metadata': JSON.stringify(metadata),
|
|
2473
|
+
* 'process.complexity': metadata.complexity,
|
|
2474
|
+
* 'process.estimated_duration': metadata.estimatedMs
|
|
2475
|
+
* });
|
|
2476
|
+
* }
|
|
2477
|
+
*
|
|
2478
|
+
* // Always safe to set basic attributes
|
|
2479
|
+
* span.setAttribute('process.started', true);
|
|
2480
|
+
* ```
|
|
2481
|
+
*/
|
|
2482
|
+
isRecording(): boolean;
|
|
2483
|
+
/**
|
|
2484
|
+
* Records an exception as a span event with automatic error status handling.
|
|
2485
|
+
*
|
|
2486
|
+
* This method captures exception information and automatically creates a span event
|
|
2487
|
+
* with standardized exception attributes. It's the recommended way to handle errors
|
|
2488
|
+
* within spans, providing consistent error reporting across the application.
|
|
2489
|
+
*
|
|
2490
|
+
* @param exception - The exception to record; accepts string messages or Error objects
|
|
2491
|
+
* @param time - Optional timestamp for when the exception occurred; defaults to current time
|
|
2492
|
+
*
|
|
2493
|
+
* @remarks
|
|
2494
|
+
* - Automatically extracts exception type, message, and stack trace when available
|
|
2495
|
+
* - Creates a standardized span event with exception details
|
|
2496
|
+
* - Does NOT automatically set span status to ERROR - call setStatus() explicitly if needed
|
|
2497
|
+
* - Exception events are useful for debugging and error analysis
|
|
2498
|
+
*
|
|
2499
|
+
* @example
|
|
2500
|
+
* ```typescript
|
|
2501
|
+
* const span = tracer.startSpan('risky-operation');
|
|
2502
|
+
*
|
|
2503
|
+
* try {
|
|
2504
|
+
* await performRiskyOperation();
|
|
2505
|
+
* span.setStatus({ code: SpanStatusCode.OK });
|
|
2506
|
+
*
|
|
2507
|
+
* } catch (error) {
|
|
2508
|
+
* // Record the exception details
|
|
2509
|
+
* span.recordException(error);
|
|
2510
|
+
*
|
|
2511
|
+
* // Explicitly set error status
|
|
2512
|
+
* span.setStatus({
|
|
2513
|
+
* code: SpanStatusCode.ERROR,
|
|
2514
|
+
* message: 'Operation failed due to: ' + error.message
|
|
2515
|
+
* });
|
|
2516
|
+
*
|
|
2517
|
+
* // Re-throw if needed
|
|
2518
|
+
* throw error;
|
|
2519
|
+
* } finally {
|
|
2520
|
+
* span.end();
|
|
2521
|
+
* }
|
|
2522
|
+
*
|
|
2523
|
+
* // Recording string exceptions
|
|
2524
|
+
* span.recordException('Custom error message occurred');
|
|
2525
|
+
*
|
|
2526
|
+
* // Recording with custom timestamp
|
|
2527
|
+
* const errorTime = Date.now() * 1000000; // nanoseconds
|
|
2528
|
+
* span.recordException(error, errorTime);
|
|
2529
|
+
* ```
|
|
2530
|
+
*/
|
|
2531
|
+
recordException(exception: OTelException, time?: OTelTimeInput): void;
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* Options for creating a span.
|
|
2536
|
+
*/
|
|
2537
|
+
interface IOTelSpanOptions {
|
|
2538
|
+
/**
|
|
2539
|
+
* The SpanKind of a span of this span, this is used to specify
|
|
2540
|
+
* the relationship between the span and its parent span.
|
|
2541
|
+
* @see {@link eOTelSpanKind} for possible values.
|
|
2542
|
+
* @default eOTelSpanKind.INTERNAL
|
|
2543
|
+
*/
|
|
2544
|
+
kind?: OTelSpanKind;
|
|
2545
|
+
/**
|
|
2546
|
+
* A span's attributes
|
|
2547
|
+
*/
|
|
2548
|
+
attributes?: IOTelAttributes;
|
|
2549
|
+
/** A manually specified start time for the created `Span` object. */
|
|
2550
|
+
startTime?: OTelTimeInput;
|
|
2551
|
+
/** The new span should be a root span. (Ignore parent from context). */
|
|
2552
|
+
root?: boolean;
|
|
2553
|
+
/** Specify whether the span should be a recording span, default is true */
|
|
2554
|
+
recording?: boolean;
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
interface IOTelSpanStatus {
|
|
2558
|
+
/**
|
|
2559
|
+
* The status code of this message.
|
|
2560
|
+
*/
|
|
2561
|
+
code: eOTelSpanStatusCode;
|
|
2562
|
+
/**
|
|
2563
|
+
* A developer-facing error message.
|
|
2564
|
+
*/
|
|
2565
|
+
message?: string;
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* OpenTelemetry tracer interface for creating and managing spans within a trace.
|
|
2570
|
+
*
|
|
2571
|
+
* A tracer is responsible for creating spans that represent units of work within a distributed system.
|
|
2572
|
+
* Each tracer is typically associated with a specific instrumentation library or component,
|
|
2573
|
+
* allowing for fine-grained control over how different parts of an application generate telemetry.
|
|
2574
|
+
*
|
|
2575
|
+
* @example
|
|
2576
|
+
* ```typescript
|
|
2577
|
+
* // Get a tracer instance
|
|
2578
|
+
* const tracer = otelApi.getTracer('my-service');
|
|
2579
|
+
*
|
|
2580
|
+
* // Create a simple span
|
|
2581
|
+
* const span = tracer.startSpan('database-query');
|
|
2582
|
+
* span.setAttribute('db.operation', 'SELECT');
|
|
2583
|
+
* span.end();
|
|
2584
|
+
*
|
|
2585
|
+
* // Create an active span with automatic context management
|
|
2586
|
+
* tracer.startActiveSpan('process-request', (span) => {
|
|
2587
|
+
* span.setAttribute('request.id', '12345');
|
|
2588
|
+
*
|
|
2589
|
+
* // Any spans created within this block will be children of this span
|
|
2590
|
+
* processRequest();
|
|
2591
|
+
*
|
|
2592
|
+
* span.end();
|
|
2593
|
+
* });
|
|
2594
|
+
* ```
|
|
2595
|
+
*
|
|
2596
|
+
* @see {@link IReadableSpan} - Interface for individual spans
|
|
2597
|
+
* @see {@link IOTelSpanOptions} - Configuration options for span creation
|
|
2598
|
+
*
|
|
2599
|
+
* @since 3.4.0
|
|
2600
|
+
*/
|
|
2601
|
+
interface IOTelTracer {
|
|
2602
|
+
/**
|
|
2603
|
+
* Creates and starts a new span without setting it as the active span in the current context.
|
|
2604
|
+
*
|
|
2605
|
+
* This method creates a span but does NOT modify the current execution context.
|
|
2606
|
+
* The caller is responsible for managing the span's lifecycle, including calling `end()`
|
|
2607
|
+
* when the operation completes.
|
|
2608
|
+
*
|
|
2609
|
+
* @param name - The name of the span, should be descriptive of the operation being traced
|
|
2610
|
+
* @param options - Optional configuration for span creation (parent context, attributes, etc.)
|
|
2611
|
+
* @param context - Optional context to use for extracting the parent span; if not provided, uses current context
|
|
2612
|
+
*
|
|
2613
|
+
* @returns The newly created span, or null if span creation failed
|
|
2614
|
+
*
|
|
2615
|
+
* @remarks
|
|
2616
|
+
* - The returned span must be manually ended by calling `span.end()`
|
|
2617
|
+
* - This span will not automatically become the parent for spans created in nested operations
|
|
2618
|
+
* - Use `startActiveSpan` if you want automatic context management
|
|
2619
|
+
*
|
|
2620
|
+
* @example
|
|
2621
|
+
* ```typescript
|
|
2622
|
+
* const span = tracer.startSpan('database-operation');
|
|
2623
|
+
* if (span) {
|
|
2624
|
+
* try {
|
|
2625
|
+
* span.setAttribute('db.table', 'users');
|
|
2626
|
+
* span.setAttribute('db.operation', 'SELECT');
|
|
2627
|
+
*
|
|
2628
|
+
* // Perform database operation
|
|
2629
|
+
* const result = await db.query('SELECT * FROM users');
|
|
2630
|
+
*
|
|
2631
|
+
* span.setAttributes({
|
|
2632
|
+
* 'db.rows_affected': result.length,
|
|
2633
|
+
* 'operation.success': true
|
|
2634
|
+
* });
|
|
2635
|
+
* } catch (error) {
|
|
2636
|
+
* span.setStatus({
|
|
2637
|
+
* code: SpanStatusCode.ERROR,
|
|
2638
|
+
* message: error.message
|
|
2639
|
+
* });
|
|
2640
|
+
* span.recordException(error);
|
|
2641
|
+
* } finally {
|
|
2642
|
+
* span.end(); // Always end the span
|
|
2643
|
+
* }
|
|
2644
|
+
* }
|
|
2645
|
+
* ```
|
|
2646
|
+
*/
|
|
2647
|
+
startSpan(name: string, options?: IOTelSpanOptions): IReadableSpan | null;
|
|
2648
|
+
/**
|
|
2649
|
+
* Creates and starts a new span, sets it as the active span in the current context,
|
|
2650
|
+
* and executes a provided function within this context.
|
|
2651
|
+
*
|
|
2652
|
+
* This method creates a span, makes it active during the execution of the provided
|
|
2653
|
+
* function, and automatically ends the span when the function completes (or throws).
|
|
2654
|
+
* This provides automatic span lifecycle management and context propagation.
|
|
2655
|
+
*
|
|
2656
|
+
* @param name - The name of the span, should be descriptive of the operation being traced
|
|
2657
|
+
* @param options - Optional configuration for span creation (parent context, attributes, etc.)
|
|
2658
|
+
* @param fn - The function to execute within the span's active context
|
|
2659
|
+
*
|
|
2660
|
+
* @returns The result of executing the provided function
|
|
2661
|
+
*
|
|
2662
|
+
* @remarks
|
|
2663
|
+
* - The span is automatically ended when the function completes or throws an exception
|
|
2664
|
+
* - The span becomes the active parent for any spans created within the function
|
|
2665
|
+
* - If the function throws an error, the span status is automatically set to ERROR
|
|
2666
|
+
* - This is the recommended method for most tracing scenarios due to automatic lifecycle management
|
|
2667
|
+
* - Multiple overloads available for different parameter combinations
|
|
2668
|
+
*
|
|
2669
|
+
* @example
|
|
2670
|
+
* ```typescript
|
|
2671
|
+
* // Synchronous operation with just name and function
|
|
2672
|
+
* const result = tracer.startActiveSpan('user-service', (span) => {
|
|
2673
|
+
* span.setAttribute('operation', 'get-user-details');
|
|
2674
|
+
* return { user: getUserData(), timestamp: new Date().toISOString() };
|
|
2675
|
+
* });
|
|
2676
|
+
*
|
|
2677
|
+
* // With options
|
|
2678
|
+
* const result2 = tracer.startActiveSpan('database-query',
|
|
2679
|
+
* { attributes: { 'db.table': 'users' } },
|
|
2680
|
+
* (span) => {
|
|
2681
|
+
* span.setAttribute('db.operation', 'SELECT');
|
|
2682
|
+
* return database.getUser('123');
|
|
2683
|
+
* }
|
|
2684
|
+
* );
|
|
2685
|
+
*
|
|
2686
|
+
* // With full context control
|
|
2687
|
+
* const result3 = tracer.startActiveSpan('external-api',
|
|
2688
|
+
* { attributes: { 'service.name': 'payment-api' } },
|
|
2689
|
+
* currentContext,
|
|
2690
|
+
* async (span) => {
|
|
2691
|
+
* try {
|
|
2692
|
+
* const response = await fetch('/api/payment');
|
|
2693
|
+
* span.setAttributes({
|
|
2694
|
+
* 'http.status_code': response.status,
|
|
2695
|
+
* 'operation.success': response.ok
|
|
2696
|
+
* });
|
|
2697
|
+
* return response.json();
|
|
2698
|
+
* } catch (error) {
|
|
2699
|
+
* span.setAttribute('error.type', error.constructor.name);
|
|
2700
|
+
* throw error; // Error automatically recorded
|
|
2701
|
+
* }
|
|
2702
|
+
* }
|
|
2703
|
+
* );
|
|
2704
|
+
* ```
|
|
2705
|
+
*/
|
|
2706
|
+
startActiveSpan<F extends (span: IReadableSpan) => unknown>(name: string, fn: F): ReturnType<F>;
|
|
2707
|
+
startActiveSpan<F extends (span: IReadableSpan) => unknown>(name: string, options: IOTelSpanOptions, fn: F): ReturnType<F>;
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
interface IOTelTracerOptions {
|
|
2711
|
+
/**
|
|
2712
|
+
* The schemaUrl of the tracer or instrumentation library
|
|
2713
|
+
*/
|
|
2714
|
+
schemaUrl?: string;
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
/**
|
|
2718
|
+
* OpenTelemetry Trace API for getting tracers.
|
|
2719
|
+
* This provides the standard OpenTelemetry trace API entry point.
|
|
2720
|
+
*/
|
|
2721
|
+
interface IOTelTracerProvider {
|
|
2722
|
+
/**
|
|
2723
|
+
* Returns a Tracer, creating one if one with the given name and version is
|
|
2724
|
+
* not already created. This may return
|
|
2725
|
+
* - The same Tracer instance if one has already been created with the same name and version
|
|
2726
|
+
* - A new Tracer instance if one has not already been created with the same name and version
|
|
2727
|
+
* - A non-operational Tracer if the provider is not operational
|
|
2728
|
+
*
|
|
2729
|
+
* @param name - The name of the tracer or instrumentation library.
|
|
2730
|
+
* @param version - The version of the tracer or instrumentation library.
|
|
2731
|
+
* @param options - The options of the tracer or instrumentation library.
|
|
2732
|
+
* @returns Tracer A Tracer with the given name and version
|
|
2733
|
+
*/
|
|
2734
|
+
getTracer(name: string, version?: string, options?: IOTelTracerOptions): IOTelTracer;
|
|
2735
|
+
/**
|
|
2736
|
+
* Forces the tracer provider to flush any buffered data.
|
|
2737
|
+
* @returns A promise that resolves when the flush is complete.
|
|
2738
|
+
*/
|
|
2739
|
+
forceFlush?: () => IPromise<void> | void;
|
|
2740
|
+
/**
|
|
2741
|
+
* Shuts down the tracer provider and releases any resources.
|
|
2742
|
+
* @returns A promise that resolves when the shutdown is complete.
|
|
2743
|
+
*/
|
|
2744
|
+
shutdown?: () => IPromise<void> | void;
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
/** IPayloadData describes interface of payload sent via POST channel */
|
|
2748
|
+
interface IPayloadData {
|
|
2749
|
+
urlString: string;
|
|
2750
|
+
data: Uint8Array | string;
|
|
2751
|
+
headers?: {
|
|
2752
|
+
[name: string]: string;
|
|
2753
|
+
};
|
|
2754
|
+
timeout?: number;
|
|
2755
|
+
disableXhrSync?: boolean;
|
|
2756
|
+
disableFetchKeepAlive?: boolean;
|
|
2757
|
+
sendReason?: SendRequestReason;
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
/**
|
|
2761
|
+
* This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
|
|
2762
|
+
*/
|
|
2763
|
+
interface IPerfEvent {
|
|
2764
|
+
/**
|
|
2765
|
+
* The name of the performance event
|
|
2766
|
+
*/
|
|
2767
|
+
name: string;
|
|
2768
|
+
/**
|
|
2769
|
+
* The start time of the performance event
|
|
2770
|
+
*/
|
|
2771
|
+
start: number;
|
|
2772
|
+
/**
|
|
2773
|
+
* The payload (contents) of the perfEvent, may be null or only set after the event has completed depending on
|
|
2774
|
+
* the runtime environment.
|
|
2775
|
+
*/
|
|
2776
|
+
payload: any;
|
|
2777
|
+
/**
|
|
2778
|
+
* Is this occurring from an asynchronous event
|
|
2779
|
+
*/
|
|
2780
|
+
isAsync: boolean;
|
|
2781
|
+
/**
|
|
2782
|
+
* Identifies the total inclusive time spent for this event, including the time spent for child events,
|
|
2783
|
+
* this will be undefined until the event is completed
|
|
2784
|
+
*/
|
|
2785
|
+
time?: number;
|
|
2786
|
+
/**
|
|
2787
|
+
* Identifies the exclusive time spent in for this event (not including child events),
|
|
2788
|
+
* this will be undefined until the event is completed.
|
|
2789
|
+
*/
|
|
2790
|
+
exTime?: number;
|
|
2791
|
+
/**
|
|
2792
|
+
* The Parent event that was started before this event was created
|
|
2793
|
+
*/
|
|
2794
|
+
parent?: IPerfEvent;
|
|
2795
|
+
/**
|
|
2796
|
+
* The child perf events that are contained within the total time of this event.
|
|
2797
|
+
*/
|
|
2798
|
+
childEvts?: IPerfEvent[];
|
|
2799
|
+
/**
|
|
2800
|
+
* Identifies whether this event is a child event of a parent
|
|
2801
|
+
*/
|
|
2802
|
+
isChildEvt: () => boolean;
|
|
2803
|
+
/**
|
|
2804
|
+
* Get the names additional context associated with this perf event
|
|
2805
|
+
*/
|
|
2806
|
+
getCtx?: (key: string) => any;
|
|
2807
|
+
/**
|
|
2808
|
+
* Set the named additional context to be associated with this perf event, this will replace any existing value
|
|
2809
|
+
*/
|
|
2810
|
+
setCtx?: (key: string, value: any) => void;
|
|
2811
|
+
/**
|
|
2812
|
+
* Mark this event as completed, calculating the total execution time.
|
|
2813
|
+
*/
|
|
2814
|
+
complete: () => void;
|
|
1552
2815
|
}
|
|
1553
2816
|
|
|
1554
2817
|
/**
|
|
@@ -1800,7 +3063,7 @@ declare namespace ApplicationInsights {
|
|
|
1800
3063
|
* });
|
|
1801
3064
|
* ```
|
|
1802
3065
|
*/
|
|
1803
|
-
then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>):
|
|
3066
|
+
then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
|
|
1804
3067
|
/**
|
|
1805
3068
|
* Attaches a callback for only the rejection of the Promise.
|
|
1806
3069
|
* @param onRejected - The callback to execute when the Promise is rejected.
|
|
@@ -1851,7 +3114,7 @@ declare namespace ApplicationInsights {
|
|
|
1851
3114
|
* // expected output: Uh-oh!
|
|
1852
3115
|
* ```
|
|
1853
3116
|
*/
|
|
1854
|
-
catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null):
|
|
3117
|
+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
|
|
1855
3118
|
/**
|
|
1856
3119
|
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
1857
3120
|
* resolved value cannot be modified from the callback.
|
|
@@ -1881,6 +3144,73 @@ declare namespace ApplicationInsights {
|
|
|
1881
3144
|
finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
|
|
1882
3145
|
}
|
|
1883
3146
|
|
|
3147
|
+
/**
|
|
3148
|
+
* Provides an OpenTelemetry compatible Interface for the Open Telemetry Sdk-Trace-Base (1.8.0 and 2.0.0) ReadableSpan type.
|
|
3149
|
+
*
|
|
3150
|
+
* The IReadableSpan interface is used to represent a span that can be read and exported, while the OpenTelemetry
|
|
3151
|
+
* specification defines a ReadableSpan as a Span that has been ended and is ready to be exported. By default all
|
|
3152
|
+
* spans created by this library implement the IReadableSpan interface which also extends the {@link IOTelSpan} interface.
|
|
3153
|
+
*
|
|
3154
|
+
* This interface is defined to provide compatibility with exporters defined by the OpenTelemetry Trace SDK.
|
|
3155
|
+
* @since 3.4.0
|
|
3156
|
+
*/
|
|
3157
|
+
interface IReadableSpan extends IOTelSpan {
|
|
3158
|
+
/**
|
|
3159
|
+
* The span's unique identifier.
|
|
3160
|
+
*/
|
|
3161
|
+
readonly name: string;
|
|
3162
|
+
/**
|
|
3163
|
+
* Identifies the type (or kind) that this span is representing.
|
|
3164
|
+
*/
|
|
3165
|
+
readonly kind: OTelSpanKind;
|
|
3166
|
+
readonly spanContext: () => IDistributedTraceContext;
|
|
3167
|
+
readonly parentSpanId?: string;
|
|
3168
|
+
readonly parentSpanContext?: IDistributedTraceContext;
|
|
3169
|
+
readonly startTime: IOTelHrTime;
|
|
3170
|
+
readonly endTime: IOTelHrTime;
|
|
3171
|
+
readonly status: IOTelSpanStatus;
|
|
3172
|
+
/**
|
|
3173
|
+
* Provides a snapshot of the span's attributes at the time this span was ended.
|
|
3174
|
+
* @returns A read-only snapshot of the span's attributes
|
|
3175
|
+
* @remarks
|
|
3176
|
+
* It is recommended that you only access this property sparingly due to the
|
|
3177
|
+
* performance cost of taking a snapshot of all attributes.
|
|
3178
|
+
*/
|
|
3179
|
+
readonly attributes: IOTelAttributes;
|
|
3180
|
+
readonly duration: IOTelHrTime;
|
|
3181
|
+
readonly ended: boolean;
|
|
3182
|
+
readonly droppedAttributesCount: number;
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
/**
|
|
3186
|
+
* Represents the execution scope for a span, combining the trace instance and the active span.
|
|
3187
|
+
* This interface is used as the context for executing functions within a span's scope.
|
|
3188
|
+
*
|
|
3189
|
+
* @since 3.4.0
|
|
3190
|
+
*/
|
|
3191
|
+
interface ISpanScope<T extends ITraceHost = ITraceHost> {
|
|
3192
|
+
/**
|
|
3193
|
+
* The trace host (core or AISKU instance).
|
|
3194
|
+
* @since 3.4.0
|
|
3195
|
+
*/
|
|
3196
|
+
readonly host: T;
|
|
3197
|
+
/**
|
|
3198
|
+
* The active span for this execution scope.
|
|
3199
|
+
* @since 3.4.0
|
|
3200
|
+
*/
|
|
3201
|
+
readonly span: IReadableSpan;
|
|
3202
|
+
/**
|
|
3203
|
+
* The previously active span before this scope was created, if any.
|
|
3204
|
+
* @since 3.4.0
|
|
3205
|
+
*/
|
|
3206
|
+
readonly prvSpan?: IReadableSpan;
|
|
3207
|
+
/**
|
|
3208
|
+
* Restores the previous active span in the trace instance.
|
|
3209
|
+
* @since 3.4.0
|
|
3210
|
+
*/
|
|
3211
|
+
restore(): void;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
1884
3214
|
interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
|
|
1885
3215
|
remove(): void;
|
|
1886
3216
|
}
|
|
@@ -2140,6 +3470,205 @@ declare namespace ApplicationInsights {
|
|
|
2140
3470
|
enabled: boolean;
|
|
2141
3471
|
}
|
|
2142
3472
|
|
|
3473
|
+
/**
|
|
3474
|
+
* ITraceApi provides an interface definition which is simular to the OpenTelemetry TraceAPI
|
|
3475
|
+
*/
|
|
3476
|
+
interface ITraceApi {
|
|
3477
|
+
/**
|
|
3478
|
+
* Returns a Tracer, creating one if one with the given name and version
|
|
3479
|
+
* if one has not already created.
|
|
3480
|
+
*
|
|
3481
|
+
* @param name - The name of the tracer or instrumentation library.
|
|
3482
|
+
* @param version - The version of the tracer or instrumentation library.
|
|
3483
|
+
* @param options - The options of the tracer or instrumentation library.
|
|
3484
|
+
* @returns Tracer A Tracer with the given name and version
|
|
3485
|
+
*/
|
|
3486
|
+
getTracer(name: string, version?: string, options?: IOTelTracerOptions): IOTelTracer;
|
|
3487
|
+
/**
|
|
3488
|
+
* Wrap the given {@link IDistributedTraceContext} in a new non-recording {@link IReadableSpan}
|
|
3489
|
+
*
|
|
3490
|
+
* @param spanContext - The {@link IDistributedTraceContext} to be wrapped
|
|
3491
|
+
* @returns a new non-recording {@link IReadableSpan} with the provided context
|
|
3492
|
+
*/
|
|
3493
|
+
wrapSpanContext(spanContext: IDistributedTraceContext): IReadableSpan;
|
|
3494
|
+
/**
|
|
3495
|
+
* Returns true if this {@link IDistributedTraceContext} is valid.
|
|
3496
|
+
* @return true if this {@link IDistributedTraceContext} is valid.
|
|
3497
|
+
*/
|
|
3498
|
+
isSpanContextValid(spanContext: IDistributedTraceContext): boolean;
|
|
3499
|
+
/**
|
|
3500
|
+
* Gets the span from the current context, if one exists.
|
|
3501
|
+
*/
|
|
3502
|
+
getActiveSpan(): IReadableSpan | undefined | null;
|
|
3503
|
+
/**
|
|
3504
|
+
* Set or clear the current active span.
|
|
3505
|
+
* @param span - The span to set as the active span, or null/undefined to clear the active span.
|
|
3506
|
+
* @return An ISpanScope instance returned by the host, or void if there is no defined host.
|
|
3507
|
+
*/
|
|
3508
|
+
setActiveSpan(span: IReadableSpan | undefined | null): ISpanScope | undefined | null;
|
|
3509
|
+
}
|
|
3510
|
+
|
|
3511
|
+
/**
|
|
3512
|
+
* Configuration interface for OpenTelemetry compatible tracing functionality.
|
|
3513
|
+
* This interface contains all the settings that control how traces are created,
|
|
3514
|
+
* processed, and managed within the OpenTelemetry system.
|
|
3515
|
+
*
|
|
3516
|
+
* @example
|
|
3517
|
+
* ```typescript
|
|
3518
|
+
* const traceCfg: ITraceCfg = {
|
|
3519
|
+
* serviceName: "my-service",
|
|
3520
|
+
* generalLimits: {
|
|
3521
|
+
* attributeCountLimit: 128,
|
|
3522
|
+
* attributeValueLengthLimit: 4096
|
|
3523
|
+
* },
|
|
3524
|
+
* spanLimits: {
|
|
3525
|
+
* attributeCountLimit: 128,
|
|
3526
|
+
* linkCountLimit: 128,
|
|
3527
|
+
* eventCountLimit: 128
|
|
3528
|
+
* }
|
|
3529
|
+
* };
|
|
3530
|
+
* ```
|
|
3531
|
+
*
|
|
3532
|
+
* @since 3.4.0
|
|
3533
|
+
*/
|
|
3534
|
+
interface ITraceCfg {
|
|
3535
|
+
/**
|
|
3536
|
+
* Global attribute limits that apply to all telemetry items.
|
|
3537
|
+
* These limits help prevent excessive memory usage and ensure consistent
|
|
3538
|
+
* behavior across different telemetry types.
|
|
3539
|
+
*
|
|
3540
|
+
* @remarks
|
|
3541
|
+
* These limits are inherited by more specific configurations unless overridden.
|
|
3542
|
+
* For example, spans will use these limits unless `spanLimits` specifies different values.
|
|
3543
|
+
*/
|
|
3544
|
+
generalLimits?: IOTelAttributeLimits;
|
|
3545
|
+
/**
|
|
3546
|
+
* The name of the service generating telemetry data.
|
|
3547
|
+
* This name will be included in all telemetry items as a resource attribute.
|
|
3548
|
+
*
|
|
3549
|
+
* @remarks
|
|
3550
|
+
* The service name is crucial for identifying and filtering telemetry data
|
|
3551
|
+
* in observability systems. It should be consistent across all instances
|
|
3552
|
+
* of the same service.
|
|
3553
|
+
*
|
|
3554
|
+
* @example
|
|
3555
|
+
* ```typescript
|
|
3556
|
+
* serviceName: "user-authentication-service"
|
|
3557
|
+
* ```
|
|
3558
|
+
*/
|
|
3559
|
+
serviceName?: string;
|
|
3560
|
+
/**
|
|
3561
|
+
* A flag that indicates whether the tracing (creating of a "trace" event) should be suppressed
|
|
3562
|
+
* when a {@link IOTelSpan} ends and the span {@link IOTelSpan#isRecording | isRecording} is true.
|
|
3563
|
+
* This value is also inherited by spans when they are created.
|
|
3564
|
+
*/
|
|
3565
|
+
suppressTracing?: boolean;
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
/**
|
|
3569
|
+
* Interface for OpenTelemetry trace operations.
|
|
3570
|
+
* This interface provides span creation, context management, and trace provider operations
|
|
3571
|
+
* that are common across different SDK implementations (Core, AISKU, etc.).
|
|
3572
|
+
*
|
|
3573
|
+
* @since 3.4.0
|
|
3574
|
+
*/
|
|
3575
|
+
interface ITraceHost<CfgType extends IConfiguration = IConfiguration> {
|
|
3576
|
+
readonly config: CfgType;
|
|
3577
|
+
/**
|
|
3578
|
+
* Gets the current distributed trace active context for this instance
|
|
3579
|
+
* @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true. By default this
|
|
3580
|
+
* will use any located parent as defined by the {@link IConfiguration.traceHdrMode} configuration for each new instance created.
|
|
3581
|
+
*/
|
|
3582
|
+
getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
|
|
3583
|
+
/**
|
|
3584
|
+
* Sets the current distributed trace context for this instance if available
|
|
3585
|
+
*/
|
|
3586
|
+
setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
|
|
3587
|
+
/**
|
|
3588
|
+
* Start a new span with the given name and optional parent context.
|
|
3589
|
+
*
|
|
3590
|
+
* Note: This method only creates and returns the span. It does not automatically
|
|
3591
|
+
* set the span as the active trace context. Context management should be handled
|
|
3592
|
+
* separately using setTraceCtx() if needed.
|
|
3593
|
+
*
|
|
3594
|
+
* @param name - The name of the span
|
|
3595
|
+
* @param options - Options for creating the span (kind, attributes, startTime)
|
|
3596
|
+
* @param parent - Optional parent context. If not provided, uses the current active trace context
|
|
3597
|
+
* @returns A new span instance, or null if no trace provider is available
|
|
3598
|
+
* @since 3.4.0
|
|
3599
|
+
*
|
|
3600
|
+
* @see {@link IReadableSpan} - Interface for individual spans
|
|
3601
|
+
* @see {@link IOTelSpanOptions} - Configuration options for span creation
|
|
3602
|
+
*/
|
|
3603
|
+
startSpan(name: string, options?: IOTelSpanOptions, parent?: IDistributedTraceContext): IReadableSpan | null;
|
|
3604
|
+
/**
|
|
3605
|
+
* Return the current active span, if no trace provider is available null will be returned
|
|
3606
|
+
* but when a trace provider is available a span instance will always be returned, even if
|
|
3607
|
+
* there is no active span (in which case a non-recording span will be returned).
|
|
3608
|
+
* @param createNew - Optional flag to create a non-recording span if no active span exists, defaults to true.
|
|
3609
|
+
* When false, returns the existing active span or null without creating a non-recording span, which can improve
|
|
3610
|
+
* performance when only checking if an active span exists.
|
|
3611
|
+
* @returns The current active span or null if no trace provider is available or if createNew is false and no active span exists
|
|
3612
|
+
* @since 3.4.0
|
|
3613
|
+
*/
|
|
3614
|
+
getActiveSpan(createNew?: boolean): IReadableSpan | null;
|
|
3615
|
+
/**
|
|
3616
|
+
* Set the current Active Span, if no trace provider is available the span will be not be set as the active span.
|
|
3617
|
+
* @param span - The span to set as the active span
|
|
3618
|
+
* @returns An ISpanScope instance that provides the current scope, the span will always be the span passed in
|
|
3619
|
+
* even when no trace provider is available
|
|
3620
|
+
* @since 3.4.0
|
|
3621
|
+
*/
|
|
3622
|
+
setActiveSpan(span: IReadableSpan): ISpanScope;
|
|
3623
|
+
/**
|
|
3624
|
+
* Get the current trace provider.
|
|
3625
|
+
*
|
|
3626
|
+
* @returns The current trace provider, or null if none is set
|
|
3627
|
+
* @since 3.4.0
|
|
3628
|
+
*/
|
|
3629
|
+
getTraceProvider(): ITraceProvider | null;
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
/**
|
|
3633
|
+
* A trace provider interface that enables different SKUs to provide their own
|
|
3634
|
+
* span implementations while being managed by the core SDK.
|
|
3635
|
+
*
|
|
3636
|
+
* This follows the OpenTelemetry TraceProvider pattern, allowing the core to
|
|
3637
|
+
* delegate span creation to the appropriate implementation based on the SDK variant.
|
|
3638
|
+
*
|
|
3639
|
+
* @since 3.4.0
|
|
3640
|
+
*/
|
|
3641
|
+
interface ITraceProvider {
|
|
3642
|
+
/**
|
|
3643
|
+
* The OpenTelemetry API instance associated with this trace provider.
|
|
3644
|
+
* This provides access to the tracer provider and other OpenTelemetry functionality.
|
|
3645
|
+
* @since 3.4.0
|
|
3646
|
+
*/
|
|
3647
|
+
readonly api: IOTelApi;
|
|
3648
|
+
/**
|
|
3649
|
+
* Creates a new span with the given name and options.
|
|
3650
|
+
*
|
|
3651
|
+
* @param name - The name of the span
|
|
3652
|
+
* @param options - Options for creating the span (kind, attributes, startTime)
|
|
3653
|
+
* @param parent - Optional parent context. If not provided, uses the current active trace context
|
|
3654
|
+
* @returns A new span instance specific to this provider's implementation
|
|
3655
|
+
* @since 3.4.0
|
|
3656
|
+
*/
|
|
3657
|
+
createSpan(name: string, options?: IOTelSpanOptions, parent?: IDistributedTraceContext): IReadableSpan;
|
|
3658
|
+
/**
|
|
3659
|
+
* Gets the provider identifier for debugging and logging purposes.
|
|
3660
|
+
* @returns A string identifying this trace provider implementation
|
|
3661
|
+
* @since 3.4.0
|
|
3662
|
+
*/
|
|
3663
|
+
getProviderId(): string;
|
|
3664
|
+
/**
|
|
3665
|
+
* Determines if this provider is available and ready to create spans.
|
|
3666
|
+
* @returns true if the provider can create spans, false otherwise
|
|
3667
|
+
* @since 3.4.0
|
|
3668
|
+
*/
|
|
3669
|
+
isAvailable(): boolean;
|
|
3670
|
+
}
|
|
3671
|
+
|
|
2143
3672
|
/**
|
|
2144
3673
|
* An interface which provides automatic removal during unloading of the component
|
|
2145
3674
|
*/
|
|
@@ -2267,6 +3796,74 @@ declare namespace ApplicationInsights {
|
|
|
2267
3796
|
|
|
2268
3797
|
type LoggingSeverity = number | eLoggingSeverity;
|
|
2269
3798
|
|
|
3799
|
+
/**
|
|
3800
|
+
* Attribute values may be any non-nullish primitive value except an object.
|
|
3801
|
+
*
|
|
3802
|
+
* null or undefined attribute values are invalid and will result in undefined behavior.
|
|
3803
|
+
*
|
|
3804
|
+
* @since 3.4.0
|
|
3805
|
+
*/
|
|
3806
|
+
type OTelAttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
|
|
3807
|
+
|
|
3808
|
+
/**
|
|
3809
|
+
* Defines Exception.
|
|
3810
|
+
*
|
|
3811
|
+
* string or an object with one of (message or name or code) and optional stack
|
|
3812
|
+
*
|
|
3813
|
+
* @since 3.4.0
|
|
3814
|
+
*/
|
|
3815
|
+
type OTelException = IOTelExceptionWithCode | IOTelExceptionWithMessage | IOTelExceptionWithName | string;
|
|
3816
|
+
|
|
3817
|
+
/**
|
|
3818
|
+
* High-resolution time represented as a tuple of [seconds, nanoseconds].
|
|
3819
|
+
* This is the base type for all OpenTelemetry high-resolution time values.
|
|
3820
|
+
*
|
|
3821
|
+
* @remarks
|
|
3822
|
+
* The first element represents seconds since Unix epoch, and the second element
|
|
3823
|
+
* represents nanoseconds (0-999,999,999) within that second.
|
|
3824
|
+
*
|
|
3825
|
+
* @example
|
|
3826
|
+
* ```typescript
|
|
3827
|
+
* const hrTime: OTelHrTimeBase = [1609459200, 500000000]; // 2021-01-01 00:00:00.5 UTC
|
|
3828
|
+
* ```
|
|
3829
|
+
*
|
|
3830
|
+
* @since 3.4.0
|
|
3831
|
+
*/
|
|
3832
|
+
type OTelHrTimeBase = [number, number];
|
|
3833
|
+
|
|
3834
|
+
/**
|
|
3835
|
+
* Creates an enum style object for the OTelSpanKind enum, providing the enum
|
|
3836
|
+
* values as properties of the object as both string and number types.
|
|
3837
|
+
* This allows for easy access to the enum values in a more readable format.
|
|
3838
|
+
*/
|
|
3839
|
+
const OTelSpanKind: EnumValue<typeof eOTelSpanKind>;
|
|
3840
|
+
|
|
3841
|
+
type OTelSpanKind = number | eOTelSpanKind;
|
|
3842
|
+
|
|
3843
|
+
/**
|
|
3844
|
+
* Union type representing all valid time input formats accepted by OpenTelemetry APIs.
|
|
3845
|
+
*
|
|
3846
|
+
* @remarks
|
|
3847
|
+
* - `IOTelHrTime`: High-resolution time with nanosecond precision
|
|
3848
|
+
* - `number`: Milliseconds since Unix epoch (JavaScript Date.now() format)
|
|
3849
|
+
* - `Date`: JavaScript Date object
|
|
3850
|
+
*
|
|
3851
|
+
* @example
|
|
3852
|
+
* ```typescript
|
|
3853
|
+
* // All of these are valid time inputs:
|
|
3854
|
+
* const hrTime: OTelTimeInput = [1609459200, 500000000];
|
|
3855
|
+
* const msTime: OTelTimeInput = Date.now();
|
|
3856
|
+
* const dateTime: OTelTimeInput = new Date();
|
|
3857
|
+
*
|
|
3858
|
+
* span.addEvent("event", {}, hrTime);
|
|
3859
|
+
* span.addEvent("event", {}, msTime);
|
|
3860
|
+
* span.addEvent("event", {}, dateTime);
|
|
3861
|
+
* ```
|
|
3862
|
+
*
|
|
3863
|
+
* @since 3.4.0
|
|
3864
|
+
*/
|
|
3865
|
+
type OTelTimeInput = IOTelHrTime | number | Date;
|
|
3866
|
+
|
|
2270
3867
|
/**
|
|
2271
3868
|
* This defines the handler function for when a promise is rejected.
|
|
2272
3869
|
* @param value - This is the value passed as part of resolving the Promise
|