@fluidframework/telemetry-utils 2.93.0 → 2.101.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 +26 -0
- package/DEV.md +33 -0
- package/api-extractor/api-extractor-lint-api-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +1 -1
- package/api-extractor.json +2 -1
- package/api-report/telemetry-utils.legacy.beta.api.md +10 -7
- package/dist/api.d.ts +26 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +40 -0
- package/dist/api.js.map +1 -0
- package/dist/config.d.ts +6 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -1
- package/dist/errorLogging.d.ts +2 -2
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js.map +1 -1
- package/dist/events.d.ts +3 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/{index.d.ts → internal.d.ts} +16 -4
- package/dist/internal.d.ts.map +1 -0
- package/dist/{index.js → internal.js} +22 -5
- package/dist/internal.js.map +1 -0
- package/dist/legacy.d.ts +2 -2
- package/dist/logger.d.ts +61 -21
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +74 -29
- package/dist/logger.js.map +1 -1
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +13 -0
- package/dist/main.js.map +1 -0
- package/dist/mockLogger.d.ts +5 -4
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +2 -2
- package/dist/mockLogger.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/sampledTelemetryHelper.d.ts +5 -2
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js +6 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetryEventBatcher.d.ts +2 -2
- package/dist/telemetryEventBatcher.d.ts.map +1 -1
- package/dist/telemetryEventBatcher.js.map +1 -1
- package/dist/telemetryTypes.d.ts +65 -6
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/telemetryTypes.js.map +1 -1
- package/dist/telemetryTypesUndeprecated.d.ts +36 -0
- package/dist/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/dist/telemetryTypesUndeprecated.js +7 -0
- package/dist/telemetryTypesUndeprecated.js.map +1 -0
- package/dist/thresholdCounter.d.ts +2 -2
- package/dist/thresholdCounter.d.ts.map +1 -1
- package/dist/thresholdCounter.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -9
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +2 -2
- package/legacy.d.ts +1 -1
- package/lib/api.d.ts +26 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +22 -0
- package/lib/api.js.map +1 -0
- package/lib/config.d.ts +6 -6
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +4 -1
- package/lib/config.js.map +1 -1
- package/lib/errorLogging.d.ts +2 -2
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js.map +1 -1
- package/lib/events.d.ts +3 -3
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js.map +1 -1
- package/lib/{index.d.ts → internal.d.ts} +16 -4
- package/lib/internal.d.ts.map +1 -0
- package/lib/{index.js → internal.js} +5 -3
- package/lib/internal.js.map +1 -0
- package/lib/legacy.d.ts +2 -2
- package/lib/logger.d.ts +61 -21
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +71 -28
- package/lib/logger.js.map +1 -1
- package/lib/main.d.ts +8 -0
- package/lib/main.d.ts.map +1 -0
- package/lib/main.js +9 -0
- package/lib/main.js.map +1 -0
- package/lib/mockLogger.d.ts +5 -4
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +2 -2
- package/lib/mockLogger.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/sampledTelemetryHelper.d.ts +5 -2
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js +6 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetryEventBatcher.d.ts +2 -2
- package/lib/telemetryEventBatcher.d.ts.map +1 -1
- package/lib/telemetryEventBatcher.js.map +1 -1
- package/lib/telemetryTypes.d.ts +65 -6
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/telemetryTypes.js.map +1 -1
- package/lib/telemetryTypesUndeprecated.d.ts +36 -0
- package/lib/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/lib/telemetryTypesUndeprecated.js +6 -0
- package/lib/telemetryTypesUndeprecated.js.map +1 -0
- package/lib/thresholdCounter.d.ts +2 -2
- package/lib/thresholdCounter.d.ts.map +1 -1
- package/lib/thresholdCounter.js.map +1 -1
- package/lib/utils.d.ts +4 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +9 -9
- package/lib/utils.js.map +1 -1
- package/package.json +21 -19
- package/src/api.ts +44 -0
- package/src/config.ts +29 -19
- package/src/errorLogging.ts +2 -2
- package/src/events.ts +3 -3
- package/src/{index.ts → internal.ts} +23 -8
- package/src/logger.ts +114 -37
- package/src/main.ts +19 -0
- package/src/mockLogger.ts +6 -6
- package/src/sampledTelemetryHelper.ts +12 -4
- package/src/telemetryEventBatcher.ts +3 -3
- package/src/telemetryTypes.ts +76 -6
- package/src/telemetryTypesUndeprecated.ts +51 -0
- package/src/thresholdCounter.ts +2 -2
- package/src/utils.ts +24 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/logger.d.ts
CHANGED
|
@@ -3,7 +3,31 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type ITelemetryBaseEvent, type ITelemetryBaseLogger, LogLevel, type Tagged, type TelemetryBaseEventPropertyType } from "@fluidframework/core-interfaces";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ITelemetryLoggerExt, ITelemetryPropertiesExt, TelemetryLoggerExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes.js";
|
|
7
|
+
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt } from "./telemetryTypesUndeprecated.js";
|
|
8
|
+
/**
|
|
9
|
+
* Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function toITelemetryLoggerExt(logger: TelemetryLoggerExt): ITelemetryLoggerExt;
|
|
13
|
+
/**
|
|
14
|
+
* Un-type-erase the {@link ITelemetryLoggerExt}.
|
|
15
|
+
* @remarks
|
|
16
|
+
* This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam options - options for the extraction, currently only supports making
|
|
19
|
+
* the output possibly undefined (when `PossiblyUndefined: true`), which is useful
|
|
20
|
+
* for cases where we want to allow passing `undefined` through.
|
|
21
|
+
*
|
|
22
|
+
* @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will
|
|
23
|
+
* be when the breaking change is made. At that time, use of this helper will be
|
|
24
|
+
* required.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractTelemetryLoggerExt<options extends {
|
|
29
|
+
PossiblyUndefined?: true;
|
|
30
|
+
} = {}>(input: ITelemetryLoggerExt | TelemetryLoggerExt | (options["PossiblyUndefined"] extends true ? undefined : never)): TelemetryLoggerExt | (options["PossiblyUndefined"] extends true ? undefined : never);
|
|
7
31
|
/**
|
|
8
32
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
9
33
|
*
|
|
@@ -34,6 +58,9 @@ export type ITelemetryLoggerPropertyBag = Record<string, TelemetryEventPropertyT
|
|
|
34
58
|
/**
|
|
35
59
|
* @legacy
|
|
36
60
|
* @beta
|
|
61
|
+
*
|
|
62
|
+
* @privateRemarks
|
|
63
|
+
* This is exposed to support {@link createChildLogger} properties parameter.
|
|
37
64
|
*/
|
|
38
65
|
export interface ITelemetryLoggerPropertyBags {
|
|
39
66
|
all?: ITelemetryLoggerPropertyBag;
|
|
@@ -64,7 +91,7 @@ export declare const eventNamespaceSeparator = ":";
|
|
|
64
91
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
65
92
|
* Creates sub-logger that appends properties to all events
|
|
66
93
|
*/
|
|
67
|
-
export declare abstract class TelemetryLogger implements
|
|
94
|
+
export declare abstract class TelemetryLogger implements TelemetryLoggerExt {
|
|
68
95
|
protected readonly namespace?: string | undefined;
|
|
69
96
|
protected readonly properties?: ITelemetryLoggerPropertyBags | undefined;
|
|
70
97
|
/**
|
|
@@ -92,20 +119,18 @@ export declare abstract class TelemetryLogger implements ITelemetryLoggerExt {
|
|
|
92
119
|
*
|
|
93
120
|
* @param event - the event to send
|
|
94
121
|
* @param error - optional error object to log
|
|
95
|
-
* @param logLevel - optional level of the log.
|
|
96
|
-
*
|
|
122
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
123
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
97
124
|
*/
|
|
98
|
-
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.
|
|
125
|
+
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
|
|
99
126
|
/**
|
|
100
127
|
* Send a telemetry event with the logger
|
|
101
128
|
*
|
|
102
129
|
* @param event - the event to send
|
|
103
130
|
* @param error - optional error object to log
|
|
104
|
-
* @param logLevel -
|
|
131
|
+
* @param logLevel - level of the log.
|
|
105
132
|
*/
|
|
106
|
-
|
|
107
|
-
category: TelemetryEventCategory;
|
|
108
|
-
}, error?: unknown, logLevel?: LogLevel): void;
|
|
133
|
+
private sendTelemetryEventCore;
|
|
109
134
|
/**
|
|
110
135
|
* Send an error telemetry event with the logger
|
|
111
136
|
*
|
|
@@ -118,10 +143,10 @@ export declare abstract class TelemetryLogger implements ITelemetryLoggerExt {
|
|
|
118
143
|
*
|
|
119
144
|
* @param event - Event to send
|
|
120
145
|
* @param error - optional error object to log
|
|
121
|
-
* @param logLevel - optional level of the log.
|
|
122
|
-
*
|
|
146
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
147
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
123
148
|
*/
|
|
124
|
-
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.
|
|
149
|
+
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
|
|
125
150
|
protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent;
|
|
126
151
|
private extendProperties;
|
|
127
152
|
}
|
|
@@ -148,14 +173,22 @@ export declare class TaggedLoggerAdapter implements ITelemetryBaseLogger {
|
|
|
148
173
|
*
|
|
149
174
|
* @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.
|
|
150
175
|
*
|
|
151
|
-
* @
|
|
152
|
-
*
|
|
176
|
+
* @internal
|
|
177
|
+
*
|
|
178
|
+
* @privateRemarks
|
|
179
|
+
* Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for
|
|
180
|
+
* easier internal usage without needing to type erase or un-type-erase the
|
|
181
|
+
* logger.
|
|
182
|
+
*
|
|
183
|
+
* If always creating a child logger for direct external exposure, consider
|
|
184
|
+
* using {@link createChildLogger} from /legacy API instead, which returns
|
|
185
|
+
* exactly an {@link ITelemetryLoggerExt}.
|
|
153
186
|
*/
|
|
154
187
|
export declare function createChildLogger(props?: {
|
|
155
188
|
logger?: ITelemetryBaseLogger;
|
|
156
189
|
namespace?: string;
|
|
157
190
|
properties?: ITelemetryLoggerPropertyBags;
|
|
158
|
-
}): ITelemetryLoggerExt;
|
|
191
|
+
}): TelemetryLoggerExt & ITelemetryLoggerExt;
|
|
159
192
|
/**
|
|
160
193
|
* ChildLogger class contains various helper telemetry methods,
|
|
161
194
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
@@ -209,7 +242,7 @@ export interface MultiSinkLoggerProperties {
|
|
|
209
242
|
*
|
|
210
243
|
* @internal
|
|
211
244
|
*/
|
|
212
|
-
export declare function createMultiSinkLogger(props: MultiSinkLoggerProperties):
|
|
245
|
+
export declare function createMultiSinkLogger(props: MultiSinkLoggerProperties): TelemetryLoggerExt;
|
|
213
246
|
/**
|
|
214
247
|
* Multi-sink logger
|
|
215
248
|
* Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink
|
|
@@ -237,7 +270,7 @@ export declare class MultiSinkLogger extends TelemetryLogger {
|
|
|
237
270
|
*
|
|
238
271
|
* @param event - the event to send to all the registered logger
|
|
239
272
|
*/
|
|
240
|
-
send(event: ITelemetryBaseEvent): void;
|
|
273
|
+
send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;
|
|
241
274
|
}
|
|
242
275
|
/**
|
|
243
276
|
* Describes what events {@link PerformanceEvent} should log.
|
|
@@ -264,6 +297,7 @@ export declare class PerformanceEvent {
|
|
|
264
297
|
private readonly logger;
|
|
265
298
|
private readonly markers;
|
|
266
299
|
private readonly emitLogs;
|
|
300
|
+
private readonly logLevel;
|
|
267
301
|
/**
|
|
268
302
|
* Creates an instance of {@link PerformanceEvent} and starts measurements
|
|
269
303
|
* @param logger - the logger to be used for publishing events
|
|
@@ -272,9 +306,11 @@ export declare class PerformanceEvent {
|
|
|
272
306
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
273
307
|
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
274
308
|
* but measurements will still be performed and any specified markers will be generated.
|
|
309
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
310
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
275
311
|
* @returns An instance of {@link PerformanceEvent}
|
|
276
312
|
*/
|
|
277
|
-
static start(logger: ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean): PerformanceEvent;
|
|
313
|
+
static start(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): PerformanceEvent;
|
|
278
314
|
/**
|
|
279
315
|
* Measure a synchronous task
|
|
280
316
|
* @param logger - the logger to be used for publishing events
|
|
@@ -283,6 +319,8 @@ export declare class PerformanceEvent {
|
|
|
283
319
|
* @param markers - See {@link IPerformanceEventMarkers}
|
|
284
320
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
285
321
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
322
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
323
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
286
324
|
* @returns The results of the executed task
|
|
287
325
|
*
|
|
288
326
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -290,7 +328,7 @@ export declare class PerformanceEvent {
|
|
|
290
328
|
* so executing either of the tasks will increase the internal counter and they
|
|
291
329
|
* effectively "share" the sampling rate for the event.
|
|
292
330
|
*/
|
|
293
|
-
static timedExec<T>(logger:
|
|
331
|
+
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): T;
|
|
294
332
|
/**
|
|
295
333
|
* Measure an asynchronous task
|
|
296
334
|
* @param logger - the logger to be used for publishing events
|
|
@@ -300,6 +338,8 @@ export declare class PerformanceEvent {
|
|
|
300
338
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
301
339
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
302
340
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
341
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
342
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
303
343
|
* @returns The results of the executed task
|
|
304
344
|
*
|
|
305
345
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -307,12 +347,12 @@ export declare class PerformanceEvent {
|
|
|
307
347
|
* so executing either of the tasks will increase the internal counter and they
|
|
308
348
|
* effectively "share" the sampling rate for the event.
|
|
309
349
|
*/
|
|
310
|
-
static timedExecAsync<T>(logger: ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number): Promise<T>;
|
|
350
|
+
static timedExecAsync<T>(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): Promise<T>;
|
|
311
351
|
get duration(): number;
|
|
312
352
|
private event?;
|
|
313
353
|
private readonly startTime;
|
|
314
354
|
private startMark?;
|
|
315
|
-
|
|
355
|
+
private constructor();
|
|
316
356
|
reportProgress(props?: ITelemetryPropertiesExt, eventNameSuffix?: string): void;
|
|
317
357
|
private autoEnd;
|
|
318
358
|
end(props?: ITelemetryPropertiesExt): void;
|
package/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,QAAQ,EACR,KAAK,MAAM,EACX,KAAK,8BAA8B,EACnC,MAAM,iCAAiC,CAAC;AAazC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,QAAQ,EACR,KAAK,MAAM,EACX,KAAK,8BAA8B,EACnC,MAAM,iCAAiC,CAAC;AAazC,OAAO,KAAK,EAEX,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,mBAAmB,CAErF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,SAAS;IACf,iBAAiB,CAAC,EAAE,IAAI,CAAC;CACzB,GACD,EAAE,EAEF,KAAK,EACF,mBAAmB,GACnB,kBAAkB,GAClB,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,GAChE,kBAAkB,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,CAEtF;AAED;;;;;;GAMG;AACH,oBAAY,gBAAgB;IAC3B;;OAEG;IACH,YAAY,iBAAiB;IAC7B;;OAEG;IACH,QAAQ,aAAa;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAE1E;;;GAGG;A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I;IAIP,OAAO,CAAC,OAAO;IAWR,GAAG,CAAC,KAAK,CAAC,EAAE,uBAAuB,GAAG,IAAI;IAQjD,OAAO,CAAC,kBAAkB;IASnB,MAAM,CAAC,KAAK,CAAC,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IASrE;;OAEG;IACI,WAAW,CACjB,eAAe,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE,uBAAuB,EAC/B,KAAK,CAAC,EAAE,OAAO,GACb,IAAI;IAoBP,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAA6B;IAC9D,OAAO,CAAC,MAAM,CAAC,YAAY;CAS3B;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,GACtE,8BAA8B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAOzE;AA0BD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,OAAO,gGAIsB,8BAA8B,SAGlE,CAAC,UACE,CAAC,2CAGc,8BAA8B;;SAG3C,CAAC;;;SAID,CAAC;oDAoB0B,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,gBAAgB,oEAGa,8BAA8B,YAG/D,CAAC,2CAGc,8BAA8B;;SAG3C,iBAAiB,YAAY;;;SAI7B,iBAAiB,YAAY;oDAG6C,CAAC"}
|
package/lib/logger.js
CHANGED
|
@@ -6,6 +6,31 @@ import { performanceNow } from "@fluid-internal/client-utils";
|
|
|
6
6
|
import { LogLevel, } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext, } from "./config.js";
|
|
8
8
|
import { extractLogSafeErrorProperties, generateStack, isILoggingError, isTaggedTelemetryPropertyValue, } from "./errorLogging.js";
|
|
9
|
+
/**
|
|
10
|
+
* Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export function toITelemetryLoggerExt(logger) {
|
|
14
|
+
return logger;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Un-type-erase the {@link ITelemetryLoggerExt}.
|
|
18
|
+
* @remarks
|
|
19
|
+
* This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam options - options for the extraction, currently only supports making
|
|
22
|
+
* the output possibly undefined (when `PossiblyUndefined: true`), which is useful
|
|
23
|
+
* for cases where we want to allow passing `undefined` through.
|
|
24
|
+
*
|
|
25
|
+
* @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will
|
|
26
|
+
* be when the breaking change is made. At that time, use of this helper will be
|
|
27
|
+
* required.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export function extractTelemetryLoggerExt(input) {
|
|
32
|
+
return input;
|
|
33
|
+
}
|
|
9
34
|
/**
|
|
10
35
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
11
36
|
*
|
|
@@ -102,18 +127,18 @@ export class TelemetryLogger {
|
|
|
102
127
|
*
|
|
103
128
|
* @param event - the event to send
|
|
104
129
|
* @param error - optional error object to log
|
|
105
|
-
* @param logLevel - optional level of the log.
|
|
106
|
-
*
|
|
130
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
131
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
107
132
|
*/
|
|
108
|
-
sendTelemetryEvent(event, error, logLevel
|
|
109
|
-
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? LogLevel.
|
|
133
|
+
sendTelemetryEvent(event, error, logLevel) {
|
|
134
|
+
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential));
|
|
110
135
|
}
|
|
111
136
|
/**
|
|
112
137
|
* Send a telemetry event with the logger
|
|
113
138
|
*
|
|
114
139
|
* @param event - the event to send
|
|
115
140
|
* @param error - optional error object to log
|
|
116
|
-
* @param logLevel -
|
|
141
|
+
* @param logLevel - level of the log.
|
|
117
142
|
*/
|
|
118
143
|
sendTelemetryEventCore(event, error, logLevel) {
|
|
119
144
|
const newEvent = convertToBaseEvent(event);
|
|
@@ -139,22 +164,22 @@ export class TelemetryLogger {
|
|
|
139
164
|
error: event.eventName,
|
|
140
165
|
...event,
|
|
141
166
|
category: "error",
|
|
142
|
-
}, error, LogLevel.
|
|
167
|
+
}, error, LogLevel.essential);
|
|
143
168
|
}
|
|
144
169
|
/**
|
|
145
170
|
* Send a performance telemetry event with the logger
|
|
146
171
|
*
|
|
147
172
|
* @param event - Event to send
|
|
148
173
|
* @param error - optional error object to log
|
|
149
|
-
* @param logLevel - optional level of the log.
|
|
150
|
-
*
|
|
174
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
175
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
151
176
|
*/
|
|
152
|
-
sendPerformanceEvent(event, error, logLevel
|
|
177
|
+
sendPerformanceEvent(event, error, logLevel) {
|
|
153
178
|
const perfEvent = {
|
|
154
179
|
...event,
|
|
155
180
|
category: event.category ?? "performance",
|
|
156
181
|
};
|
|
157
|
-
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? LogLevel.
|
|
182
|
+
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential));
|
|
158
183
|
}
|
|
159
184
|
prepareEvent(event) {
|
|
160
185
|
const includeErrorProps = event.category === "error" || event.error !== undefined;
|
|
@@ -249,6 +274,9 @@ export class TaggedLoggerAdapter {
|
|
|
249
274
|
this.logger.send(newEvent);
|
|
250
275
|
}
|
|
251
276
|
}
|
|
277
|
+
function toEitherTelemetryLoggerExt(logger) {
|
|
278
|
+
return logger;
|
|
279
|
+
}
|
|
252
280
|
/**
|
|
253
281
|
* Create a child logger based on the provided props object.
|
|
254
282
|
*
|
|
@@ -257,11 +285,19 @@ export class TaggedLoggerAdapter {
|
|
|
257
285
|
*
|
|
258
286
|
* @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.
|
|
259
287
|
*
|
|
260
|
-
* @
|
|
261
|
-
*
|
|
288
|
+
* @internal
|
|
289
|
+
*
|
|
290
|
+
* @privateRemarks
|
|
291
|
+
* Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for
|
|
292
|
+
* easier internal usage without needing to type erase or un-type-erase the
|
|
293
|
+
* logger.
|
|
294
|
+
*
|
|
295
|
+
* If always creating a child logger for direct external exposure, consider
|
|
296
|
+
* using {@link createChildLogger} from /legacy API instead, which returns
|
|
297
|
+
* exactly an {@link ITelemetryLoggerExt}.
|
|
262
298
|
*/
|
|
263
299
|
export function createChildLogger(props) {
|
|
264
|
-
return ChildLogger.create(props?.logger, props?.namespace, props?.properties);
|
|
300
|
+
return toEitherTelemetryLoggerExt(ChildLogger.create(props?.logger, props?.namespace, props?.properties));
|
|
265
301
|
}
|
|
266
302
|
/**
|
|
267
303
|
* ChildLogger class contains various helper telemetry methods,
|
|
@@ -322,8 +358,8 @@ export class ChildLogger extends TelemetryLogger {
|
|
|
322
358
|
return this.baseLogger.minLogLevel;
|
|
323
359
|
}
|
|
324
360
|
shouldFilterOutEvent(event, logLevel) {
|
|
325
|
-
const eventLogLevel = logLevel ?? LogLevel.
|
|
326
|
-
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.
|
|
361
|
+
const eventLogLevel = logLevel ?? LogLevel.essential;
|
|
362
|
+
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.info;
|
|
327
363
|
// Filter out in case event log level is below what is wanted in config.
|
|
328
364
|
return eventLogLevel < configLogLevel;
|
|
329
365
|
}
|
|
@@ -336,7 +372,7 @@ export class ChildLogger extends TelemetryLogger {
|
|
|
336
372
|
if (this.shouldFilterOutEvent(event, logLevel)) {
|
|
337
373
|
return;
|
|
338
374
|
}
|
|
339
|
-
this.baseLogger.send(this.prepareEvent(event), logLevel);
|
|
375
|
+
this.baseLogger.send(this.prepareEvent(event), logLevel ?? LogLevel.essential);
|
|
340
376
|
}
|
|
341
377
|
}
|
|
342
378
|
/**
|
|
@@ -377,7 +413,7 @@ export class MultiSinkLogger extends TelemetryLogger {
|
|
|
377
413
|
}
|
|
378
414
|
super(namespace, realProperties);
|
|
379
415
|
this.loggers = loggers;
|
|
380
|
-
this._minLogLevelOfAllLoggers = LogLevel.
|
|
416
|
+
this._minLogLevelOfAllLoggers = LogLevel.info;
|
|
381
417
|
this.calculateMinLogLevel();
|
|
382
418
|
}
|
|
383
419
|
get minLogLevel() {
|
|
@@ -387,7 +423,7 @@ export class MultiSinkLogger extends TelemetryLogger {
|
|
|
387
423
|
if (this.loggers.length > 0) {
|
|
388
424
|
const logLevels = [];
|
|
389
425
|
for (const logger of this.loggers) {
|
|
390
|
-
logLevels.push(logger.minLogLevel ?? LogLevel.
|
|
426
|
+
logLevels.push(logger.minLogLevel ?? LogLevel.info);
|
|
391
427
|
}
|
|
392
428
|
this._minLogLevelOfAllLoggers = Math.min(...logLevels);
|
|
393
429
|
}
|
|
@@ -408,10 +444,10 @@ export class MultiSinkLogger extends TelemetryLogger {
|
|
|
408
444
|
*
|
|
409
445
|
* @param event - the event to send to all the registered logger
|
|
410
446
|
*/
|
|
411
|
-
send(event) {
|
|
447
|
+
send(event, logLevel) {
|
|
412
448
|
const newEvent = this.prepareEvent(event);
|
|
413
449
|
for (const logger of this.loggers) {
|
|
414
|
-
logger.send(newEvent);
|
|
450
|
+
logger.send(newEvent, logLevel ?? LogLevel.essential);
|
|
415
451
|
}
|
|
416
452
|
}
|
|
417
453
|
}
|
|
@@ -429,10 +465,12 @@ export class PerformanceEvent {
|
|
|
429
465
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
430
466
|
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
431
467
|
* but measurements will still be performed and any specified markers will be generated.
|
|
468
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
469
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
432
470
|
* @returns An instance of {@link PerformanceEvent}
|
|
433
471
|
*/
|
|
434
|
-
static start(logger, event, markers, emitLogs = true) {
|
|
435
|
-
return new PerformanceEvent(logger, event, markers, emitLogs);
|
|
472
|
+
static start(logger, event, markers, emitLogs = true, logLevel) {
|
|
473
|
+
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs, logLevel);
|
|
436
474
|
}
|
|
437
475
|
/**
|
|
438
476
|
* Measure a synchronous task
|
|
@@ -442,6 +480,8 @@ export class PerformanceEvent {
|
|
|
442
480
|
* @param markers - See {@link IPerformanceEventMarkers}
|
|
443
481
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
444
482
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
483
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
484
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
445
485
|
* @returns The results of the executed task
|
|
446
486
|
*
|
|
447
487
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -449,8 +489,8 @@ export class PerformanceEvent {
|
|
|
449
489
|
* so executing either of the tasks will increase the internal counter and they
|
|
450
490
|
* effectively "share" the sampling rate for the event.
|
|
451
491
|
*/
|
|
452
|
-
static timedExec(logger, event, callback, markers, sampleThreshold = 1) {
|
|
453
|
-
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
|
|
492
|
+
static timedExec(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
|
|
493
|
+
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
|
|
454
494
|
try {
|
|
455
495
|
const ret = callback(perfEvent);
|
|
456
496
|
perfEvent.autoEnd();
|
|
@@ -470,6 +510,8 @@ export class PerformanceEvent {
|
|
|
470
510
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
471
511
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
472
512
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
513
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
514
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
473
515
|
* @returns The results of the executed task
|
|
474
516
|
*
|
|
475
517
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -477,8 +519,8 @@ export class PerformanceEvent {
|
|
|
477
519
|
* so executing either of the tasks will increase the internal counter and they
|
|
478
520
|
* effectively "share" the sampling rate for the event.
|
|
479
521
|
*/
|
|
480
|
-
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1) {
|
|
481
|
-
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
|
|
522
|
+
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
|
|
523
|
+
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
|
|
482
524
|
try {
|
|
483
525
|
const ret = await callback(perfEvent);
|
|
484
526
|
perfEvent.autoEnd();
|
|
@@ -492,10 +534,11 @@ export class PerformanceEvent {
|
|
|
492
534
|
get duration() {
|
|
493
535
|
return performanceNow() - this.startTime;
|
|
494
536
|
}
|
|
495
|
-
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true) {
|
|
537
|
+
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true, logLevel) {
|
|
496
538
|
this.logger = logger;
|
|
497
539
|
this.markers = markers;
|
|
498
540
|
this.emitLogs = emitLogs;
|
|
541
|
+
this.logLevel = logLevel;
|
|
499
542
|
this.startTime = performanceNow();
|
|
500
543
|
this.event = { ...event };
|
|
501
544
|
if (this.markers.start) {
|
|
@@ -558,7 +601,7 @@ export class PerformanceEvent {
|
|
|
558
601
|
if (eventNameSuffix !== "start") {
|
|
559
602
|
event.duration = this.duration;
|
|
560
603
|
}
|
|
561
|
-
this.logger.sendPerformanceEvent(event, error);
|
|
604
|
+
this.logger.sendPerformanceEvent(event, error, this.logLevel);
|
|
562
605
|
}
|
|
563
606
|
static shouldReport(event, sampleThreshold) {
|
|
564
607
|
const eventKey = `.${event.category}.${event.eventName}`;
|