Add logLevel property to telemetry events#26548
Add logLevel property to telemetry events#26548MarioJGMsoft wants to merge 11 commits intomicrosoft:mainfrom
Conversation
jason-ha
left a comment
There was a problem hiding this comment.
We're replacing LogLevel with string? Any string is okay?
How are we documenting to our customers what they should be checking?
| sequenceNumber: number, | ||
| forceSend: boolean = false, | ||
| reason?: string, | ||
| logLevel?: string, |
There was a problem hiding this comment.
not required?
If not specified, I think we'll emit undefined. Does undefined just get dropped?
There was a problem hiding this comment.
My idea was to have undefined be treated as the essential log level, this means that if there is no logLevel property the event shouldn't be dropped.
This is because there are a lot of events in our codebase and I think it's better to have it so that we have more information diagnosing rather than missing some that wasn't properly set to essential.
Originally I wanted to avoid the issue we had with the logLevel enum, so I decided to make it a simple string. But thinking more about it now, I could create an internal enum that can work as both documentation for what costumers should be checking and a way to always have a list of expected values. I was thinking of adding a section in one of the .md files in the docs folder, but I wasn's sure where. |
.changeset/tricky-zoos-see.md
Outdated
| "@fluidframework/shared-object-base": minor | ||
| "__section": feature | ||
| --- | ||
| Add logLevel property to events |
There was a problem hiding this comment.
| Add logLevel property to events | |
| Add logLevel property to logging events |
There was a problem hiding this comment.
Applied change
.changeset/tricky-zoos-see.md
Outdated
| There are currently three values that the property can have: | ||
| 1. 'verbose' | ||
| Chatty logs useful for debugging but likely not to be sent over the wire in production. | ||
| 2. 'info' | ||
| Information about the session. These logs could be ommitted in some sessions if needed. | ||
| 3. 'essential' | ||
| Essential information about the operation of Fluid that should always be transmitted for diagnostic purposes. |
There was a problem hiding this comment.
| There are currently three values that the property can have: | |
| 1. 'verbose' | |
| Chatty logs useful for debugging but likely not to be sent over the wire in production. | |
| 2. 'info' | |
| Information about the session. These logs could be ommitted in some sessions if needed. | |
| 3. 'essential' | |
| Essential information about the operation of Fluid that should always be transmitted for diagnostic purposes. | |
| There are currently three supported values: | |
| 1. 'verbose' | |
| Chatty logs useful for local debugging. They need not be collected in production. | |
| 2. 'info' | |
| Information about the session. These logs could be omitted in some sessions if needed (e.g. to reduce overall telemetry volume). If any are collected from a particular session, all should be. | |
| 3. 'essential' | |
| Essential information about the operation of Fluid. It's recommended that they should always be collected even in production, for diagnostic purposes. |
There was a problem hiding this comment.
Thanks for the feedback, I applied the changes
| this.mc !== undefined && this.logger !== undefined, | ||
| 0x349 /* this.mc and/or this.logger has not been set */, | ||
| ); | ||
| const opProcessingHelper = new SampledTelemetryHelper<void, ProcessTelemetryProperties>( |
There was a problem hiding this comment.
Let's make this class apply a default logLevel: "info" itself. (and don't bother setting below)
There was a problem hiding this comment.
Applied change
.changeset/tricky-zoos-see.md
Outdated
|
|
||
| Events now include an optional `logLevel` property that indicates their importance for diagnostics and enables consumers to make sampling or filtering decisions. | ||
|
|
||
| There are currently three values that the property can have: |
There was a problem hiding this comment.
Let's add some kind of helpers for this.
I wish would could do this, but it involves touching legacy-beta stuff (because ITelemetryLoggerExt is overexposed at the moment):
Update
ITelemetryGenericEventExtand related types to includelogLevel?: "verbose" | "info" | "essential"Then whenever you use our internal loggers, you'd have type safety on what you pass for
logLevel.
And other helpers like SampledTelemetryHelper would benefit as well
But let's not for now. Instead we can just add this to telemetry-utils logger.ts:
export const LogLevel = { verbose: "verbose", info: "info", essential: "essential" }
And then use that instead of the string literals everywhere.
| sequenceNumber: number, | ||
| forceSend: boolean = false, | ||
| reason?: string, | ||
| logLevel?: string, |
There was a problem hiding this comment.
Nit: for APIs not exposed to end users, I generally recommend making all arguments required (and allow undefined), rather than making them optional. This will help prevent usages from accidentally forgetting to provide a parameter it really wants to provide.
There was a problem hiding this comment.
(Feel free to disregard, especially since it would require updating existing parameters here).
There was a problem hiding this comment.
After thinking about it for a bit, from what I could see the sendPerformanceEvent() funciton is used only in this file, and the events related to the client elected performance events might all be ommitable? (@kian-thompson @markfields can confirm?)
So if that's the case then the parameter won't be needed at all and they can all default to being info
Description
Added a new optional logLevel property to telemetry events to indicate their importance for diagnostics. This enables consumers to make sampling or filtering decisions based on the event's importance level.
The property can have three values:
Events without a
logLevelvalue should be treated as essential.Reviewer Guidance
The goal is to eventually replace the existing LogLevel type with this new property. I'd appreciate feedback on the naming of the property and its values and whether the default behavior (treating missing logLevel as essential) makes sense.
The review process is outlined on this wiki page.