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