@fluidframework/telemetry-utils 2.0.0-dev.7.4.0.215930 → 2.0.0-dev.7.4.0.217212

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.
Files changed (125) hide show
  1. package/api-extractor-lint.json +13 -0
  2. package/api-extractor.json +0 -4
  3. package/api-report/telemetry-utils.api.md +61 -57
  4. package/dist/config.d.ts +37 -10
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +30 -0
  7. package/dist/config.js.map +1 -1
  8. package/dist/error.d.ts +2 -0
  9. package/dist/error.d.ts.map +1 -1
  10. package/dist/error.js +2 -0
  11. package/dist/error.js.map +1 -1
  12. package/dist/errorLogging.d.ts +7 -2
  13. package/dist/errorLogging.d.ts.map +1 -1
  14. package/dist/errorLogging.js +7 -2
  15. package/dist/errorLogging.js.map +1 -1
  16. package/dist/eventEmitterWithErrorHandling.d.ts +8 -0
  17. package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
  18. package/dist/eventEmitterWithErrorHandling.js +8 -0
  19. package/dist/eventEmitterWithErrorHandling.js.map +1 -1
  20. package/dist/events.d.ts +15 -0
  21. package/dist/events.d.ts.map +1 -1
  22. package/dist/events.js +16 -0
  23. package/dist/events.js.map +1 -1
  24. package/dist/fluidErrorBase.d.ts +8 -0
  25. package/dist/fluidErrorBase.d.ts.map +1 -1
  26. package/dist/fluidErrorBase.js +6 -0
  27. package/dist/fluidErrorBase.js.map +1 -1
  28. package/dist/index.d.ts +19 -2
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/logger.d.ts +117 -17
  32. package/dist/logger.d.ts.map +1 -1
  33. package/dist/logger.js +82 -12
  34. package/dist/logger.js.map +1 -1
  35. package/dist/mockLogger.d.ts +2 -0
  36. package/dist/mockLogger.d.ts.map +1 -1
  37. package/dist/mockLogger.js +2 -0
  38. package/dist/mockLogger.js.map +1 -1
  39. package/dist/sampledTelemetryHelper.d.ts +7 -3
  40. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  41. package/dist/sampledTelemetryHelper.js +7 -3
  42. package/dist/sampledTelemetryHelper.js.map +1 -1
  43. package/dist/telemetry-utils-alpha.d.ts +105 -601
  44. package/dist/telemetry-utils-beta.d.ts +123 -610
  45. package/dist/telemetry-utils-public.d.ts +123 -610
  46. package/dist/telemetry-utils-untrimmed.d.ts +249 -41
  47. package/dist/telemetryTypes.d.ts +32 -8
  48. package/dist/telemetryTypes.d.ts.map +1 -1
  49. package/dist/telemetryTypes.js.map +1 -1
  50. package/dist/thresholdCounter.d.ts +3 -2
  51. package/dist/thresholdCounter.d.ts.map +1 -1
  52. package/dist/thresholdCounter.js +3 -2
  53. package/dist/thresholdCounter.js.map +1 -1
  54. package/dist/utils.d.ts +6 -0
  55. package/dist/utils.d.ts.map +1 -1
  56. package/dist/utils.js +6 -0
  57. package/dist/utils.js.map +1 -1
  58. package/lib/config.d.ts +37 -10
  59. package/lib/config.d.ts.map +1 -1
  60. package/lib/config.js +30 -0
  61. package/lib/config.js.map +1 -1
  62. package/lib/error.d.ts +2 -0
  63. package/lib/error.d.ts.map +1 -1
  64. package/lib/error.js +2 -0
  65. package/lib/error.js.map +1 -1
  66. package/lib/errorLogging.d.ts +7 -2
  67. package/lib/errorLogging.d.ts.map +1 -1
  68. package/lib/errorLogging.js +7 -2
  69. package/lib/errorLogging.js.map +1 -1
  70. package/lib/eventEmitterWithErrorHandling.d.ts +8 -0
  71. package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
  72. package/lib/eventEmitterWithErrorHandling.js +8 -0
  73. package/lib/eventEmitterWithErrorHandling.js.map +1 -1
  74. package/lib/events.d.ts +15 -0
  75. package/lib/events.d.ts.map +1 -1
  76. package/lib/events.js +16 -0
  77. package/lib/events.js.map +1 -1
  78. package/lib/fluidErrorBase.d.ts +8 -0
  79. package/lib/fluidErrorBase.d.ts.map +1 -1
  80. package/lib/fluidErrorBase.js +6 -0
  81. package/lib/fluidErrorBase.js.map +1 -1
  82. package/lib/index.d.ts +19 -2
  83. package/lib/index.d.ts.map +1 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/logger.d.ts +117 -17
  86. package/lib/logger.d.ts.map +1 -1
  87. package/lib/logger.js +82 -12
  88. package/lib/logger.js.map +1 -1
  89. package/lib/mockLogger.d.ts +2 -0
  90. package/lib/mockLogger.d.ts.map +1 -1
  91. package/lib/mockLogger.js +2 -0
  92. package/lib/mockLogger.js.map +1 -1
  93. package/lib/sampledTelemetryHelper.d.ts +7 -3
  94. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  95. package/lib/sampledTelemetryHelper.js +7 -3
  96. package/lib/sampledTelemetryHelper.js.map +1 -1
  97. package/lib/telemetry-utils-alpha.d.ts +105 -601
  98. package/lib/telemetry-utils-beta.d.ts +123 -610
  99. package/lib/telemetry-utils-public.d.ts +123 -610
  100. package/lib/telemetry-utils-untrimmed.d.ts +249 -41
  101. package/lib/telemetryTypes.d.ts +32 -8
  102. package/lib/telemetryTypes.d.ts.map +1 -1
  103. package/lib/telemetryTypes.js.map +1 -1
  104. package/lib/thresholdCounter.d.ts +3 -2
  105. package/lib/thresholdCounter.d.ts.map +1 -1
  106. package/lib/thresholdCounter.js +3 -2
  107. package/lib/thresholdCounter.js.map +1 -1
  108. package/lib/utils.d.ts +6 -0
  109. package/lib/utils.d.ts.map +1 -1
  110. package/lib/utils.js +6 -0
  111. package/lib/utils.js.map +1 -1
  112. package/package.json +7 -6
  113. package/src/config.ts +41 -12
  114. package/src/error.ts +2 -0
  115. package/src/errorLogging.ts +7 -2
  116. package/src/eventEmitterWithErrorHandling.ts +8 -0
  117. package/src/events.ts +18 -0
  118. package/src/fluidErrorBase.ts +8 -0
  119. package/src/index.ts +20 -2
  120. package/src/logger.ts +125 -17
  121. package/src/mockLogger.ts +2 -0
  122. package/src/sampledTelemetryHelper.ts +7 -3
  123. package/src/telemetryTypes.ts +32 -8
  124. package/src/thresholdCounter.ts +3 -2
  125. package/src/utils.ts +6 -0
@@ -4,53 +4,24 @@ import { EventEmitter } from 'events';
4
4
  import { IDisposable } from '@fluidframework/core-interfaces';
5
5
  import { IErrorBase } from '@fluidframework/core-interfaces';
6
6
  import { IEvent } from '@fluidframework/core-interfaces';
7
- import { IGenericError } from '@fluidframework/core-interfaces';
8
- import { ILoggingError } from '@fluidframework/core-interfaces';
9
7
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
10
8
  import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
11
9
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
12
10
  import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
13
- import { ITelemetryErrorEvent } from '@fluidframework/core-interfaces';
14
- import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
15
- import { ITelemetryPerformanceEvent } from '@fluidframework/core-interfaces';
16
11
  import { ITelemetryProperties } from '@fluidframework/core-interfaces';
17
- import { IUsageError } from '@fluidframework/core-interfaces';
18
- import { Lazy } from '@fluidframework/core-utils';
19
12
  import { LogLevel } from '@fluidframework/core-interfaces';
20
13
  import { Tagged } from '@fluidframework/core-interfaces';
21
- import { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
22
14
  import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
23
15
 
24
- export declare type ConfigTypes = string | number | boolean | number[] | string[] | boolean[] | undefined;
25
-
26
- export declare const connectedEventName = "connected";
27
-
28
- /**
29
- * Create a child logger based on the provided props object
30
- * @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.
31
- *
32
- * @remarks
33
- * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.
34
- */
35
- export declare function createChildLogger(props?: {
36
- logger?: ITelemetryBaseLogger;
37
- namespace?: string;
38
- properties?: ITelemetryLoggerPropertyBags;
39
- }): ITelemetryLoggerExt;
40
-
41
- export declare function createChildMonitoringContext(props: Parameters<typeof createChildLogger>[0]): MonitoringContext;
42
-
43
- /**
44
- * Create a logger which logs to multiple other loggers based on the provided props object
45
- * @param props - loggers are the base loggers that will logged to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.
46
- * tryInheritProperties will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package
47
- */
48
- export declare function createMultiSinkLogger(props: {
49
- namespace?: string;
50
- properties?: ITelemetryLoggerPropertyBags;
51
- loggers?: (ITelemetryBaseLogger | undefined)[];
52
- tryInheritProperties?: true;
53
- }): ITelemetryLoggerExt;
16
+ /* Excluded from this release type: ConfigTypes */
17
+
18
+ /* Excluded from this release type: connectedEventName */
19
+
20
+ /* Excluded from this release type: createChildLogger */
21
+
22
+ /* Excluded from this release type: createChildMonitoringContext */
23
+
24
+ /* Excluded from this release type: createMultiSinkLogger */
54
25
 
55
26
  /* Excluded from this release type: createSampledLogger */
56
27
 
@@ -58,40 +29,19 @@ export declare function createMultiSinkLogger(props: {
58
29
 
59
30
  /* Excluded from this release type: DataProcessingError */
60
31
 
61
- export declare const disconnectedEventName = "disconnected";
32
+ /* Excluded from this release type: disconnectedEventName */
62
33
 
63
34
  /* Excluded from this release type: EventEmitterEventType */
64
35
 
65
- /**
66
- * Event Emitter helper class
67
- * Any exceptions thrown by listeners will be caught and raised through "error" event.
68
- * Any exception thrown by "error" listeners will propagate to the caller.
69
- */
70
- export declare class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
71
- private readonly errorHandler;
72
- constructor(errorHandler: (eventName: EventEmitterEventType, error: any) => void);
73
- emit(event: EventEmitterEventType, ...args: unknown[]): boolean;
74
- }
36
+ /* Excluded from this release type: EventEmitterWithErrorHandling */
75
37
 
76
- export declare const eventNamespaceSeparator: ":";
38
+ /* Excluded from this release type: eventNamespaceSeparator */
77
39
 
78
40
  /* Excluded from this release type: extractLogSafeErrorProperties */
79
41
 
80
- /**
81
- * Extracts specific properties from the provided message that we know are safe to log.
82
- *
83
- * @param messageLike - Message to include info about via telemetry props.
84
- */
85
- export declare const extractSafePropertiesFromMessage: (messageLike: Partial<Pick<ISequencedDocumentMessage, "clientId" | "sequenceNumber" | "clientSequenceNumber" | "referenceSequenceNumber" | "minimumSequenceNumber" | "timestamp">>) => {
86
- messageClientId: string | undefined;
87
- messageSequenceNumber: number | undefined;
88
- messageClientSequenceNumber: number | undefined;
89
- messageReferenceSequenceNumber: number | undefined;
90
- messageMinimumSequenceNumber: number | undefined;
91
- messageTimestamp: number | undefined;
92
- };
93
-
94
- export declare function formatTick(tick: number): number;
42
+ /* Excluded from this release type: extractSafePropertiesFromMessage */
43
+
44
+ /* Excluded from this release type: formatTick */
95
45
 
96
46
  /* Excluded from this release type: generateErrorWithStack */
97
47
 
@@ -101,563 +51,117 @@ export declare function formatTick(tick: number): number;
101
51
 
102
52
  /* Excluded from this release type: getCircularReplacer */
103
53
 
104
- /**
105
- * Type guard for error data containing the {@link IFluidErrorBase.errorInstanceId} property.
106
- */
107
- export declare const hasErrorInstanceId: (x: unknown) => x is {
108
- errorInstanceId: string;
109
- };
110
-
111
- /**
112
- * Explicitly typed interface for reading configurations
113
- */
114
- export declare interface IConfigProvider extends IConfigProviderBase {
115
- getBoolean(name: string): boolean | undefined;
116
- getNumber(name: string): number | undefined;
117
- getString(name: string): string | undefined;
118
- getBooleanArray(name: string): boolean[] | undefined;
119
- getNumberArray(name: string): number[] | undefined;
120
- getStringArray(name: string): string[] | undefined;
121
- }
122
-
123
- /**
124
- * Base interface for providing configurations to enable/disable/control features
125
- */
126
- export declare interface IConfigProviderBase {
127
- getRawConfig(name: string): ConfigTypes;
128
- }
54
+ /* Excluded from this release type: hasErrorInstanceId */
55
+
56
+ /* Excluded from this release type: IConfigProvider */
57
+
58
+ /* Excluded from this release type: IConfigProviderBase */
59
+
60
+ /* Excluded from this release type: IConfigProviderBase_2 */
129
61
 
130
62
  /* Excluded from this release type: IEventSampler */
131
63
 
132
64
  /* Excluded from this release type: IFluidErrorAnnotations */
133
65
 
134
- /**
135
- * An error emitted by the Fluid Framework.
136
- *
137
- * @remarks
138
- *
139
- * All normalized errors flowing through the Fluid Framework adhere to this readonly interface.
140
- *
141
- * It features the members of {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error}
142
- * made readonly, as well as {@link IFluidErrorBase.errorType} and {@link IFluidErrorBase.errorInstanceId}.
143
- * It also features getters and setters for telemetry props to be included when the error is logged.
144
- */
145
- export declare interface IFluidErrorBase extends Error {
146
- /**
147
- * Classification of what type of error this is.
148
- *
149
- * @remarks Used programmatically by consumers to interpret the error.
150
- */
151
- readonly errorType: string;
152
- /**
153
- * Error's message property, made readonly.
154
- *
155
- * @remarks
156
- *
157
- * Recommendations:
158
- *
159
- * Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry.
160
- * Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.
161
- */
162
- readonly message: string;
163
- /**
164
- * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack}.
165
- */
166
- readonly stack?: string;
167
- /**
168
- * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name}.
169
- */
170
- readonly name: string;
171
- /**
172
- * A Guid identifying this error instance.
173
- *
174
- * @remarks
175
- *
176
- * Useful in telemetry for deduplicating multiple logging events arising from the same error,
177
- * or correlating an error with an inner error that caused it, in case of error wrapping.
178
- */
179
- readonly errorInstanceId: string;
180
- /**
181
- * Get the telemetry properties stashed on this error for logging.
182
- */
183
- getTelemetryProperties(): ITelemetryProperties;
184
- /**
185
- * Add telemetry properties to this error which will be logged with the error
186
- */
187
- addTelemetryProperties: (props: ITelemetryProperties) => void;
188
- }
189
-
190
- /**
191
- * Describes what events PerformanceEvent should log
192
- * By default, all events are logged, but client can override this behavior
193
- * For example, there is rarely a need to record start event, as we really after
194
- * success / failure tracking, including duration (on success).
195
- */
196
- export declare interface IPerformanceEventMarkers {
197
- start?: true;
198
- end?: true;
199
- cancel?: "generic" | "error";
200
- }
66
+ /* Excluded from this release type: IFluidErrorBase */
67
+
68
+ /* Excluded from this release type: IGenericError */
69
+
70
+ /* Excluded from this release type: ILoggingError */
71
+
72
+ /* Excluded from this release type: IPerformanceEventMarkers */
201
73
 
202
74
  /* Excluded from this release type: ISampledTelemetryLogger */
203
75
 
204
76
  /* Excluded from this release type: isExternalError */
205
77
 
206
- /**
207
- * Type guard for {@link IFluidErrorBase}.
208
- */
209
- export declare function isFluidError(error: unknown): error is IFluidErrorBase;
210
-
211
- /**
212
- * type guard for ILoggingError interface
213
- */
214
- export declare const isILoggingError: (x: unknown) => x is ILoggingError;
215
-
216
- /**
217
- * Type guard to identify if a particular telemetry property appears to be a tagged telemetry property
218
- */
219
- export declare function isTaggedTelemetryPropertyValue(x: Tagged<TelemetryEventPropertyTypeExt> | TelemetryEventPropertyTypeExt): x is Tagged<TelemetryEventPropertyTypeExt>;
220
-
221
- /**
222
- * Type guard for old standard of valid/known errors.
223
- */
224
- export declare function isValidLegacyError(error: unknown): error is Omit<IFluidErrorBase, "errorInstanceId">;
225
-
226
- /**
227
- * A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used
228
- * to mark pieces of information that should be organized or handled differently by loggers in various first or third
229
- * party scenarios. For example, tags are used to mark personal information that should not be stored in logs.
230
- *
231
- * @deprecated Use Tagged<TelemetryEventPropertyTypeExt>
232
- */
233
- export declare interface ITaggedTelemetryPropertyTypeExt {
234
- value: TelemetryEventPropertyTypeExt;
235
- tag: string;
236
- }
237
-
238
- /**
239
- * Error telemetry event.
240
- * Maps to category = "error"
241
- */
242
- export declare interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
243
- eventName: string;
244
- }
245
-
246
- /**
247
- * Interface for logging telemetry statements.
248
- * Can contain any number of properties that get serialized as json payload.
249
- * @param category - category of the event, like "error", "performance", "generic", etc.
250
- * @param eventName - name of the event.
251
- */
252
- export declare interface ITelemetryEventExt extends ITelemetryPropertiesExt {
253
- category: string;
254
- eventName: string;
255
- }
256
-
257
- /**
258
- * Informational (non-error) telemetry event
259
- * Maps to category = "generic"
260
- */
261
- export declare interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
262
- eventName: string;
263
- category?: TelemetryEventCategory;
264
- }
265
-
266
- /**
267
- * An extended TelemetryLogger interface which allows for more lenient event types.
268
- * This interface is meant to be used internally within the Fluid Framework,
269
- * and ITelemetryBaseLogger should be used when loggers are passed between layers.
270
- */
271
- export declare interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
272
- /**
273
- * Send information telemetry event
274
- * @param event - Event to send
275
- * @param error - optional error object to log
276
- * @param logLevel - optional level of the log.
277
- */
278
- sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
279
- /**
280
- * Send error telemetry event
281
- * @param event - Event to send
282
- * @param error - optional error object to log
283
- */
284
- sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
285
- /**
286
- * Send performance telemetry event
287
- * @param event - Event to send
288
- * @param error - optional error object to log
289
- * @param logLevel - optional level of the log.
290
- */
291
- sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
292
- }
293
-
294
- export declare interface ITelemetryLoggerPropertyBag {
295
- [index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);
296
- }
297
-
298
- export declare interface ITelemetryLoggerPropertyBags {
299
- all?: ITelemetryLoggerPropertyBag;
300
- error?: ITelemetryLoggerPropertyBag;
301
- }
302
-
303
- /**
304
- * Performance telemetry event.
305
- * Maps to category = "performance"
306
- */
307
- export declare interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {
308
- duration?: number;
309
- }
310
-
311
- /**
312
- * JSON-serializable properties, which will be logged with telemetry.
313
- */
314
- export declare interface ITelemetryPropertiesExt {
315
- [index: string]: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>;
316
- }
317
-
318
- export declare function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(logger: L): MonitoringContext<L>;
78
+ /* Excluded from this release type: isFluidError */
79
+
80
+ /* Excluded from this release type: isILoggingError */
81
+
82
+ /* Excluded from this release type: isTaggedTelemetryPropertyValue */
83
+
84
+ /* Excluded from this release type: isValidLegacyError */
85
+
86
+ /* Excluded from this release type: ITaggedTelemetryPropertyTypeExt */
87
+
88
+ /* Excluded from this release type: ITelemetryErrorEvent */
89
+
90
+ /* Excluded from this release type: ITelemetryErrorEventExt */
91
+
92
+ /* Excluded from this release type: ITelemetryEventExt */
93
+
94
+ /* Excluded from this release type: ITelemetryGenericEvent */
95
+
96
+ /* Excluded from this release type: ITelemetryGenericEventExt */
97
+
98
+ /* Excluded from this release type: ITelemetryLoggerExt */
99
+
100
+ /* Excluded from this release type: ITelemetryLoggerPropertyBag */
101
+
102
+ /* Excluded from this release type: ITelemetryLoggerPropertyBags */
103
+
104
+ /* Excluded from this release type: ITelemetryPerformanceEvent */
105
+
106
+ /* Excluded from this release type: ITelemetryPerformanceEventExt */
107
+
108
+ /* Excluded from this release type: ITelemetryPropertiesExt */
109
+
110
+ /* Excluded from this release type: IUsageError */
111
+
112
+ /* Excluded from this release type: Lazy */
113
+
114
+ /* Excluded from this release type: loggerToMonitoringContext */
319
115
 
320
116
  /* Excluded from this release type: LoggingError */
321
117
 
322
- /**
323
- * Like assert, but logs only if the condition is false, rather than throwing
324
- * @param condition - The condition to attest too
325
- * @param logger - The logger to log with
326
- * @param event - The string or event to log
327
- * @returns The outcome of the condition
328
- */
329
- export declare function logIfFalse(condition: unknown, logger: ITelemetryBaseLogger, event: string | ITelemetryGenericEvent): condition is true;
330
-
331
- export declare function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(logger: L, ...configs: (IConfigProviderBase | undefined)[]): MonitoringContext<L>;
332
-
333
- /**
334
- * The MockLogger records events sent to it, and then can walk back over those events
335
- * searching for a set of expected events to match against the logged events.
336
- */
337
- export declare class MockLogger implements ITelemetryBaseLogger {
338
- readonly minLogLevel?: LogLevel | undefined;
339
- events: ITelemetryBaseEvent[];
340
- constructor(minLogLevel?: LogLevel | undefined);
341
- clear(): void;
342
- toTelemetryLogger(): ITelemetryLoggerExt;
343
- send(event: ITelemetryBaseEvent): void;
344
- /**
345
- * Search events logged since the last time matchEvents was called, looking for the given expected
346
- * events in order.
347
- * @param expectedEvents - events in order that are expected to appear in the recorded log.
348
- * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
349
- * These event objects may be subsets of the logged events.
350
- * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
351
- */
352
- matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
353
- /**
354
- * Asserts that matchEvents is true, and prints the actual/expected output if not.
355
- */
356
- assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
357
- /**
358
- * Search events logged since the last time matchEvents was called, looking for any of the given
359
- * expected events.
360
- * @param expectedEvents - events that are expected to appear in the recorded log.
361
- * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
362
- * These event objects may be subsets of the logged events.
363
- * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
364
- * @returns if any of the expected events is found.
365
- */
366
- matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
367
- /**
368
- * Asserts that matchAnyEvent is true, and prints the actual/expected output if not.
369
- */
370
- assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
371
- /**
372
- * Search events logged since the last time matchEvents was called, looking only for the given expected
373
- * events in order.
374
- * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
375
- * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
376
- * These event objects may be subsets of the logged events.
377
- * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
378
- */
379
- matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
380
- /**
381
- * Asserts that matchEvents is true, and prints the actual/expected output if not
382
- */
383
- assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
384
- /**
385
- * Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not
386
- */
387
- assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
388
- private getMatchedEventsCount;
389
- /**
390
- * Ensure the expected event is a strict subset of the actual event
391
- */
392
- private static eventsMatch;
393
- }
394
-
395
- /**
396
- * A type containing both a telemetry logger and a configuration provider
397
- */
398
- export declare interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {
399
- config: IConfigProvider;
400
- logger: L;
401
- }
118
+ /* Excluded from this release type: logIfFalse */
119
+
120
+ /* Excluded from this release type: mixinMonitoringContext */
121
+
122
+ /* Excluded from this release type: MockLogger */
123
+
124
+ /* Excluded from this release type: MonitoringContext */
125
+
126
+ /* Excluded from this release type: MultiSinkLoggerProperties */
402
127
 
403
128
  /* Excluded from this release type: NORMALIZED_ERROR_TYPE */
404
129
 
405
130
  /* Excluded from this release type: normalizeError */
406
131
 
407
- /**
408
- * Attempts to parse number from string.
409
- * If fails,returns original string.
410
- * Used to make telemetry data typed (and support math operations, like comparison),
411
- * in places where we do expect numbers (like contentsize/duration property in http header)
412
- */
413
- export declare function numberFromString(str: string | null | undefined): string | number | undefined;
132
+ /* Excluded from this release type: numberFromString */
414
133
 
415
134
  /* Excluded from this release type: overwriteStack */
416
135
 
417
- /**
418
- * Helper class to log performance events
419
- */
420
- export declare class PerformanceEvent {
421
- private readonly logger;
422
- private readonly markers;
423
- private readonly recordHeapSize;
424
- private readonly emitLogs;
425
- /**
426
- * Creates an instance of {@link PerformanceEvent} and starts measurements
427
- * @param logger - the logger to be used for publishing events
428
- * @param event - the logging event details which will be published with the performance measurements
429
- * @param markers - See {@link IPerformanceEventMarkers}
430
- * @param recordHeapSize - whether or not to also record memory performance
431
- * @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
432
- * but measurements will still be performed and any specified markers will be generated.
433
- * @returns An instance of {@link PerformanceEvent}
434
- */
435
- static start(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, emitLogs?: boolean): PerformanceEvent;
436
- /**
437
- * Measure a synchronous task
438
- * @param logger - the logger to be used for publishing events
439
- * @param event - the logging event details which will be published with the performance measurements
440
- * @param callback - the task to be executed and measured
441
- * @param markers - See {@link IPerformanceEventMarkers}
442
- * @param sampleThreshold - events with the same name and category will be sent to the logger
443
- * only when we hit this many executions of the task. If unspecified, all events will be sent.
444
- * @returns The results of the executed task
445
- *
446
- * @remarks Note that if the "same" event (category + eventName) would be emitted by different
447
- * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,
448
- * so executing either of the tasks will increase the internal counter and they
449
- * effectively "share" the sampling rate for the event.
450
- */
451
- static timedExec<T>(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number): T;
452
- /**
453
- * Measure an asynchronous task
454
- * @param logger - the logger to be used for publishing events
455
- * @param event - the logging event details which will be published with the performance measurements
456
- * @param callback - the task to be executed and measured
457
- * @param markers - See {@link IPerformanceEventMarkers}
458
- * @param recordHeapSize - whether or not to also record memory performance
459
- * @param sampleThreshold - events with the same name and category will be sent to the logger
460
- * only when we hit this many executions of the task. If unspecified, all events will be sent.
461
- * @returns The results of the executed task
462
- *
463
- * @remarks Note that if the "same" event (category + eventName) would be emitted by different
464
- * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,
465
- * so executing either of the tasks will increase the internal counter and they
466
- * effectively "share" the sampling rate for the event.
467
- */
468
- static timedExecAsync<T>(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, sampleThreshold?: number): Promise<T>;
469
- get duration(): number;
470
- private event?;
471
- private readonly startTime;
472
- private startMark?;
473
- private startMemoryCollection;
474
- protected constructor(logger: ITelemetryLoggerExt, event: ITelemetryGenericEvent, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, emitLogs?: boolean);
475
- reportProgress(props?: ITelemetryProperties, eventNameSuffix?: string): void;
476
- private autoEnd;
477
- end(props?: ITelemetryProperties): void;
478
- private performanceEndMark;
479
- cancel(props?: ITelemetryProperties, error?: unknown): void;
480
- /**
481
- * Report the event, if it hasn't already been reported.
482
- */
483
- reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: unknown): void;
484
- private static readonly eventHits;
485
- private static shouldReport;
486
- }
487
-
488
- /**
489
- * Raises events pertaining to the connection
490
- * @param logger - The logger to log telemetry
491
- * @param emitter - The event emitter instance
492
- * @param connected - A boolean tracking whether the connection was in a connected state or not
493
- * @param clientId - The connected/disconnected clientId
494
- * @param disconnectedReason - The reason for the connection to be disconnected (Used for telemetry purposes only)
495
- */
496
- export declare function raiseConnectedEvent(logger: ITelemetryLoggerExt, emitter: EventEmitter, connected: boolean, clientId?: string, disconnectedReason?: string): void;
497
-
498
- export declare function safeRaiseEvent(emitter: EventEmitter, logger: ITelemetryLoggerExt, event: string, ...args: unknown[]): void;
499
-
500
- /**
501
- * Helper class that executes a specified code block and writes an
502
- * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified
503
- * number of executions is reached (or when the class is disposed). The `duration` field in the telemetry event is
504
- * the duration of the latest execution (sample) of the specified function. See the documentation of the
505
- * `includeAggregateMetrics` parameter for additional details that can be included.
506
- */
507
- export declare class SampledTelemetryHelper implements IDisposable {
508
- private readonly eventBase;
509
- private readonly logger;
510
- private readonly sampleThreshold;
511
- private readonly includeAggregateMetrics;
512
- private readonly perBucketProperties;
513
- disposed: boolean;
514
- private readonly measurementsMap;
515
- /**
516
- * @param eventBase -
517
- * Custom properties to include in the telemetry performance event when it is written.
518
- * @param logger -
519
- * The logger to use to write the telemetry performance event.
520
- * @param sampleThreshold -
521
- * Telemetry performance events will be generated every time we hit this many executions of the code block.
522
- * @param includeAggregateMetrics -
523
- * If set to `true`, the telemetry performance event will include aggregated metrics (total duration, min duration,
524
- * max duration) for all the executions in between generated events.
525
- * @param perBucketProperties -
526
- * Map of strings that represent different buckets (which can be specified when calling the 'measure' method), to
527
- * properties which should be added to the telemetry event for that bucket. If a bucket being measured does not
528
- * have an entry in this map, no additional properties will be added to its telemetry events. The following keys are
529
- * reserved for use by this class: "duration", "count", "totalDuration", "minDuration", "maxDuration". If any of
530
- * them is specified as a key in one of the ITelemetryProperties objects in this map, that key-value pair will be
531
- * ignored.
532
- */
533
- constructor(eventBase: ITelemetryGenericEvent, logger: ITelemetryLoggerExt, sampleThreshold: number, includeAggregateMetrics?: boolean, perBucketProperties?: Map<string, ITelemetryProperties>);
534
- /**
535
- * Executes the specified code and keeps track of execution time statistics.
536
- * If it's been called enough times (the sampleThreshold for the class) then it generates a log message with the necessary information.
537
- *
538
- * @param codeToMeasure - The code to be executed and measured.
539
- * @param bucket - A key to track executions of the code block separately.
540
- * Each different value of this parameter has a separate set of executions and metrics tracked by the class.
541
- * If no such distinction needs to be made, do not provide a value.
542
- * @returns Whatever the passed-in code block returns.
543
- */
544
- measure<T>(codeToMeasure: () => T, bucket?: string): T;
545
- private flushBucket;
546
- dispose(error?: Error | undefined): void;
547
- }
548
-
549
- /**
550
- * Creates a base configuration provider based on `sessionStorage`
551
- *
552
- * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store
553
- */
554
- export declare const sessionStorageConfigProvider: Lazy<IConfigProviderBase>;
555
-
556
- /**
557
- * Helper function to tag telemetry properties as CodeArtifacts. It supports properties of type
558
- * TelemetryBaseEventPropertyType as well as getters that return TelemetryBaseEventPropertyType.
559
- */
560
- export declare const tagCodeArtifacts: <T extends Record<string, TelemetryEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(values: T) => { [P in keyof T]: (T[P] extends () => TelemetryBaseEventPropertyType ? () => {
561
- value: ReturnType<T[P]>;
562
- tag: TelemetryDataTag.CodeArtifact;
563
- } : {
564
- value: Exclude<T[P], undefined>;
565
- tag: TelemetryDataTag.CodeArtifact;
566
- }) | (T[P] extends undefined ? undefined : never); };
567
-
568
- export declare const tagData: <T extends TelemetryDataTag, V extends Record<string, TelemetryEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(tag: T, values: V) => { [P in keyof V]: (V[P] extends () => TelemetryBaseEventPropertyType ? () => {
569
- value: ReturnType<V[P]>;
570
- tag: T;
571
- } : {
572
- value: Exclude<V[P], undefined>;
573
- tag: T;
574
- }) | (V[P] extends undefined ? undefined : never); };
575
-
576
- /**
577
- * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from
578
- * container-runtime. Issue: #8191
579
- * TaggedLoggerAdapter class can add tag handling to your logger.
580
- */
581
- export declare class TaggedLoggerAdapter implements ITelemetryBaseLogger {
582
- private readonly logger;
583
- constructor(logger: ITelemetryBaseLogger);
584
- /**
585
- * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}
586
- */
587
- send(eventWithTagsMaybe: ITelemetryBaseEvent): void;
588
- }
589
-
590
- /**
591
- * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
592
- * Please do not modify existing entries for backwards compatibility.
593
- */
594
- export declare enum TelemetryDataTag {
595
- /**
596
- * Data containing terms or IDs from code packages that may have been dynamically loaded
597
- */
598
- CodeArtifact = "CodeArtifact",
599
- /**
600
- * Personal data of a variety of classifications that pertains to the user
601
- */
602
- UserData = "UserData"
603
- }
604
-
605
- /**
606
- * The categories FF uses when instrumenting the code.
607
- *
608
- * generic - Informational log event
609
- * error - Error log event, ideally 0 of these are logged during a session
610
- * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking
611
- */
612
- export declare type TelemetryEventCategory = "generic" | "error" | "performance";
613
-
614
- /**
615
- * Property types that can be logged.
616
- * Includes extra types beyond TelemetryBaseEventPropertyType, which must be converted before sending to a base logger
617
- */
618
- export declare type TelemetryEventPropertyTypeExt = string | number | boolean | undefined | (string | number | boolean)[] | {
619
- [key: string]: // Flat objects can have the same properties as the event itself
620
- string | number | boolean | undefined | (string | number | boolean)[];
621
- };
622
-
623
- export declare type TelemetryEventPropertyTypes = ITelemetryBaseProperties[string];
624
-
625
- /**
626
- * Null logger that no-ops for all telemetry events passed to it.
627
- * @deprecated This will be removed in a future release.
628
- * For internal use within the FluidFramework codebase, use {@link createChildLogger} with no arguments instead.
629
- * For external consumers we recommend writing a trivial implementation of {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}
630
- * where the send() method does nothing and using that.
631
- */
632
- export declare class TelemetryNullLogger implements ITelemetryLoggerExt {
633
- send(event: ITelemetryBaseEvent): void;
634
- sendTelemetryEvent(event: ITelemetryGenericEvent, error?: unknown): void;
635
- sendErrorEvent(event: ITelemetryErrorEvent, error?: unknown): void;
636
- sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: unknown): void;
637
- }
638
-
639
- /**
640
- * Utility counter which will send event only if the provided value
641
- * is above a configured threshold
642
- */
643
- export declare class ThresholdCounter {
644
- private readonly threshold;
645
- private readonly logger;
646
- private thresholdMultiple;
647
- constructor(threshold: number, logger: ITelemetryLoggerExt, thresholdMultiple?: number);
648
- /**
649
- * Sends the value if it's above the treshold.
650
- */
651
- send(eventName: string, value: number): void;
652
- /**
653
- * Sends the value if it's above the threshold
654
- * and a multiple of the threshold.
655
- *
656
- * To be used in scenarios where we'd like to record a
657
- * threshold violation while reducing telemetry noise.
658
- */
659
- sendIfMultiple(eventName: string, value: number): void;
660
- }
136
+ /* Excluded from this release type: PerformanceEvent */
137
+
138
+ /* Excluded from this release type: raiseConnectedEvent */
139
+
140
+ /* Excluded from this release type: safeRaiseEvent */
141
+
142
+ /* Excluded from this release type: SampledTelemetryHelper */
143
+
144
+ /* Excluded from this release type: sessionStorageConfigProvider */
145
+
146
+ /* Excluded from this release type: tagCodeArtifacts */
147
+
148
+ /* Excluded from this release type: tagData */
149
+
150
+ /* Excluded from this release type: TaggedLoggerAdapter */
151
+
152
+ /* Excluded from this release type: TelemetryBaseEventPropertyType */
153
+
154
+ /* Excluded from this release type: TelemetryDataTag */
155
+
156
+ /* Excluded from this release type: TelemetryEventCategory */
157
+
158
+ /* Excluded from this release type: TelemetryEventPropertyTypeExt */
159
+
160
+ /* Excluded from this release type: TelemetryEventPropertyTypes */
161
+
162
+ /* Excluded from this release type: TelemetryNullLogger */
163
+
164
+ /* Excluded from this release type: ThresholdCounter */
661
165
 
662
166
  /* Excluded from this release type: TypedEventEmitter */
663
167