Skip to content

Add logLevel property to telemetry events#26548

Draft
MarioJGMsoft wants to merge 11 commits intomicrosoft:mainfrom
MarioJGMsoft:marioja/sampleProperty
Draft

Add logLevel property to telemetry events#26548
MarioJGMsoft wants to merge 11 commits intomicrosoft:mainfrom
MarioJGMsoft:marioja/sampleProperty

Conversation

@MarioJGMsoft
Copy link
Contributor

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:

  • verbose — Chatty logs useful for debugging but likely not needed in production.
  • info — Session information that could be omitted in some sessions if needed.
  • essential— Critical diagnostic information that should always be transmitted.

Events without a logLevel value 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.

@MarioJGMsoft MarioJGMsoft changed the title Marioja/sample property Add logLevel property to telemetry events Feb 25, 2026
Copy link
Contributor

@jason-ha jason-ha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required?
If not specified, I think we'll emit undefined. Does undefined just get dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MarioJGMsoft
Copy link
Contributor Author

MarioJGMsoft commented Feb 26, 2026

We're replacing LogLevel with string? Any string is okay? How are we documenting to our customers what they should be checking?

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.

"@fluidframework/shared-object-base": minor
"__section": feature
---
Add logLevel property to events
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add logLevel property to events
Add logLevel property to logging events

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied change

Comment on lines 10 to 16
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this class apply a default logLevel: "info" itself. (and don't bother setting below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied change


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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ITelemetryGenericEventExt and related types to include logLevel?: "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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Feel free to disregard, especially since it would require updating existing parameters here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants