-
Notifications
You must be signed in to change notification settings - Fork 576
feat(telemetry-utils): deprecate LogLevel.default/error and tag unspecified events as essential #27207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(telemetry-utils): deprecate LogLevel.default/error and tag unspecified events as essential #27207
Changes from 23 commits
09cc182
3525674
f3c37bf
07925f4
67614c8
a568d12
9a81682
da948a1
c0d9396
f3a92b6
0ba1037
eab130c
5f1205d
ba39358
bad5774
71c1f07
2c13181
3b3f5fe
fbd560a
5d5fcb1
beeac4c
bee89e1
1131b62
1205a20
c033d8a
03adcc4
389760d
ece6302
24984f4
4731ce5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| "@fluidframework/core-interfaces": minor | ||
| "__section": deprecation | ||
| --- | ||
|
|
||
| Deprecated LogLevel.default and LogLevel.error | ||
|
|
||
| `LogLevel.default` and `LogLevel.error` in `@fluidframework/core-interfaces` are deprecated in favor of the semantically clearer `LogLevel.info` and `LogLevel.essential` respectively. | ||
|
|
||
| #### Migration | ||
|
|
||
| - `LogLevel.default` (= `20`) → use `LogLevel.info` | ||
|
jason-ha marked this conversation as resolved.
Outdated
|
||
| - `LogLevel.error` (= `30`) → use `LogLevel.essential` | ||
|
|
||
| Removal is tracked in [issue #26969](https://github.com/microsoft/FluidFramework/issues/26969) and is planned for the v3.0 major release. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -230,12 +230,12 @@ export abstract class TelemetryLogger implements TelemetryLoggerExt { | |
| public sendTelemetryEvent( | ||
| event: ITelemetryGenericEventExt, | ||
| error?: unknown, | ||
| logLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): void { | ||
| this.sendTelemetryEventCore( | ||
| { ...event, category: event.category ?? "generic" }, | ||
| error, | ||
| event.category === "error" ? LogLevel.error : logLevel, | ||
| event.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential), | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -244,12 +244,12 @@ export abstract class TelemetryLogger implements TelemetryLoggerExt { | |
| * | ||
| * @param event - the event to send | ||
| * @param error - optional error object to log | ||
| * @param logLevel - optional level of the log. | ||
| * @param logLevel - level of the log. | ||
| */ | ||
| protected sendTelemetryEventCore( | ||
| private sendTelemetryEventCore( | ||
| event: ITelemetryGenericEventExt & { category: TelemetryEventCategory }, | ||
| error?: unknown, | ||
| logLevel?: LogLevel, | ||
| error: unknown, | ||
| logLevel: LogLevel, | ||
| ): void { | ||
| const newEvent = convertToBaseEvent(event); | ||
| if (error !== undefined) { | ||
|
|
@@ -280,7 +280,7 @@ export abstract class TelemetryLogger implements TelemetryLoggerExt { | |
| category: "error", | ||
| }, | ||
| error, | ||
| LogLevel.error, | ||
| LogLevel.essential, | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -295,7 +295,7 @@ export abstract class TelemetryLogger implements TelemetryLoggerExt { | |
| public sendPerformanceEvent( | ||
| event: ITelemetryPerformanceEventExt, | ||
| error?: unknown, | ||
| logLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): void { | ||
| const perfEvent = { | ||
| ...event, | ||
|
|
@@ -305,7 +305,7 @@ export abstract class TelemetryLogger implements TelemetryLoggerExt { | |
| this.sendTelemetryEventCore( | ||
| perfEvent, | ||
| error, | ||
| perfEvent.category === "error" ? LogLevel.error : logLevel, | ||
| perfEvent.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential), | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -518,8 +518,8 @@ export class ChildLogger extends TelemetryLogger { | |
| } | ||
|
|
||
| private shouldFilterOutEvent(event: ITelemetryBaseEvent, logLevel?: LogLevel): boolean { | ||
| const eventLogLevel = logLevel ?? LogLevel.default; | ||
| const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.default; | ||
| const eventLogLevel = logLevel ?? LogLevel.essential; | ||
| const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.info; | ||
| // Filter out in case event log level is below what is wanted in config. | ||
| return eventLogLevel < configLogLevel; | ||
| } | ||
|
|
@@ -533,7 +533,7 @@ export class ChildLogger extends TelemetryLogger { | |
| if (this.shouldFilterOutEvent(event, logLevel)) { | ||
| return; | ||
| } | ||
| this.baseLogger.send(this.prepareEvent(event), logLevel); | ||
| this.baseLogger.send(this.prepareEvent(event), logLevel ?? LogLevel.essential); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happened to making logLevel required on send for the sub-classes? Now we have two places in the same flow filling in defaults
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It couldn't be made there might still be chances that ChildLogger and Multisink receive undefined from old containerRuntime (At least that's what I understood). @jason-ha to confirm |
||
| } | ||
|
MarioJGMsoft marked this conversation as resolved.
|
||
| } | ||
|
|
||
|
|
@@ -618,7 +618,7 @@ export class MultiSinkLogger extends TelemetryLogger { | |
|
|
||
| super(namespace, realProperties); | ||
| this.loggers = loggers; | ||
| this._minLogLevelOfAllLoggers = LogLevel.default; | ||
| this._minLogLevelOfAllLoggers = LogLevel.info; | ||
| this.calculateMinLogLevel(); | ||
| } | ||
|
|
||
|
|
@@ -630,7 +630,7 @@ export class MultiSinkLogger extends TelemetryLogger { | |
| if (this.loggers.length > 0) { | ||
| const logLevels: LogLevel[] = []; | ||
| for (const logger of this.loggers) { | ||
| logLevels.push(logger.minLogLevel ?? LogLevel.default); | ||
| logLevels.push(logger.minLogLevel ?? LogLevel.info); | ||
| } | ||
| this._minLogLevelOfAllLoggers = Math.min(...logLevels) as LogLevel; | ||
| } | ||
|
|
@@ -653,10 +653,10 @@ export class MultiSinkLogger extends TelemetryLogger { | |
| * | ||
| * @param event - the event to send to all the registered logger | ||
| */ | ||
| public send(event: ITelemetryBaseEvent): void { | ||
| public send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void { | ||
| const newEvent = this.prepareEvent(event); | ||
| for (const logger of this.loggers) { | ||
| logger.send(newEvent); | ||
| logger.send(newEvent, logLevel ?? LogLevel.essential); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -693,14 +693,15 @@ export class PerformanceEvent { | |
| * @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger, | ||
| * but measurements will still be performed and any specified markers will be generated. | ||
| * @param logLevel - optional {@link LogLevel} for events emitted by this performance event. | ||
| * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used. | ||
| * @returns An instance of {@link PerformanceEvent} | ||
|
MarioJGMsoft marked this conversation as resolved.
|
||
| */ | ||
| public static start( | ||
| logger: TelemetryLoggerExt | ITelemetryLoggerExt, | ||
| event: ITelemetryGenericEventExt, | ||
| markers?: IPerformanceEventMarkers, | ||
| emitLogs: boolean = true, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): PerformanceEvent { | ||
| return new PerformanceEvent( | ||
| extractTelemetryLoggerExt(logger), | ||
|
|
@@ -720,6 +721,7 @@ export class PerformanceEvent { | |
| * @param sampleThreshold - events with the same name and category will be sent to the logger | ||
| * only when we hit this many executions of the task. If unspecified, all events will be sent. | ||
| * @param logLevel - optional {@link LogLevel} for events emitted by this performance event. | ||
| * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used. | ||
| * @returns The results of the executed task | ||
|
MarioJGMsoft marked this conversation as resolved.
|
||
| * | ||
| * @remarks Note that if the "same" event (category + eventName) would be emitted by different | ||
|
|
@@ -733,7 +735,7 @@ export class PerformanceEvent { | |
| callback: (event: PerformanceEvent) => T, | ||
| markers?: IPerformanceEventMarkers, | ||
| sampleThreshold: number = 1, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): T { | ||
| const perfEvent = PerformanceEvent.start( | ||
| logger, | ||
|
|
@@ -762,6 +764,7 @@ export class PerformanceEvent { | |
| * @param sampleThreshold - events with the same name and category will be sent to the logger | ||
| * only when we hit this many executions of the task. If unspecified, all events will be sent. | ||
| * @param logLevel - optional {@link LogLevel} for events emitted by this performance event. | ||
| * If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used. | ||
| * @returns The results of the executed task | ||
| * | ||
| * @remarks Note that if the "same" event (category + eventName) would be emitted by different | ||
|
|
@@ -775,7 +778,7 @@ export class PerformanceEvent { | |
| callback: (event: PerformanceEvent) => Promise<T>, | ||
| markers?: IPerformanceEventMarkers, | ||
| sampleThreshold: number = 1, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): Promise<T> { | ||
| const perfEvent = PerformanceEvent.start( | ||
| logger, | ||
|
|
@@ -807,7 +810,7 @@ export class PerformanceEvent { | |
| event: ITelemetryGenericEventExt, | ||
| private readonly markers: IPerformanceEventMarkers = { end: true, cancel: "generic" }, | ||
| private readonly emitLogs: boolean = true, | ||
| private readonly logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| private readonly logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
|
jason-ha marked this conversation as resolved.
Outdated
|
||
| ) { | ||
| this.event = { ...event }; | ||
| if (this.markers.start) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,14 +136,14 @@ export interface ITelemetryLoggerExt extends ITelemetryBaseLogger { | |
| * Send an information telemetry event. | ||
| * @param event - Event to send. | ||
| * @param error - Optional error object to log. | ||
| * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}. | ||
| * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}. | ||
| * @deprecated This method is being removed without a replacement. | ||
| * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details. | ||
| */ | ||
| sendTelemetryEvent( | ||
| event: ITelemetryGenericEventExt, | ||
| error?: unknown, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): void; | ||
|
|
||
| /** | ||
|
|
@@ -159,14 +159,14 @@ export interface ITelemetryLoggerExt extends ITelemetryBaseLogger { | |
| * Send a performance telemetry event. | ||
| * @param event - Event to send | ||
| * @param error - Optional error object to log. | ||
| * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.essential}. | ||
| * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}. | ||
| * @deprecated This method is being removed without a replacement. | ||
| * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details. | ||
| */ | ||
| sendPerformanceEvent( | ||
| event: ITelemetryPerformanceEventExt, | ||
| error?: unknown, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): void; | ||
| } | ||
|
|
||
|
|
@@ -183,12 +183,12 @@ export interface TelemetryLoggerExt extends ITelemetryBaseLogger { | |
| * Send an information telemetry event. | ||
| * @param event - Event to send. | ||
| * @param error - Optional error object to log. | ||
| * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}. | ||
| * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}. | ||
|
jason-ha marked this conversation as resolved.
Outdated
|
||
| */ | ||
| sendTelemetryEvent( | ||
| event: ITelemetryGenericEventExt, | ||
| error?: unknown, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): void; | ||
|
MarioJGMsoft marked this conversation as resolved.
|
||
|
|
||
| /** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a note here that it's going to use logLevel essential?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're referring to |
||
|
|
@@ -202,11 +202,11 @@ export interface TelemetryLoggerExt extends ITelemetryBaseLogger { | |
| * Send a performance telemetry event. | ||
| * @param event - Event to send | ||
| * @param error - Optional error object to log. | ||
| * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevelConst.default | LogLevel.default}. | ||
| * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}. | ||
| */ | ||
| sendPerformanceEvent( | ||
| event: ITelemetryPerformanceEventExt, | ||
| error?: unknown, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.default, | ||
| logLevel?: typeof LogLevel.verbose | typeof LogLevel.info, | ||
| ): void; | ||
|
MarioJGMsoft marked this conversation as resolved.
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied change