Skip to content

feat(telemetry-utils): escalate selected performance events to essential#27462

Merged
MarioJGMsoft merged 7 commits into
microsoft:mainfrom
MarioJGMsoft:marioja/performanceEventUpdate
Jun 5, 2026
Merged

feat(telemetry-utils): escalate selected performance events to essential#27462
MarioJGMsoft merged 7 commits into
microsoft:mainfrom
MarioJGMsoft:marioja/performanceEventUpdate

Conversation

@MarioJGMsoft
Copy link
Copy Markdown
Contributor

@MarioJGMsoft MarioJGMsoft commented Jun 1, 2026

Description

Adds opt-in PerformanceEvent markers for promoting selected performance telemetry to essential:

  • endEventEssentialDurationThresholdMs logs _end events as essential when their duration exceeds the configured threshold.
  • logCancelAsEssential logs _cancel events as essential while preserving the configured cancel category.

This lets callers keep normal performance events at their configured verbosity while ensuring long-running operations and configured cancel events are not filtered out. Tests cover threshold behavior, cancel escalation, unchanged default log-level behavior, and existing error-category essential behavior.

Reviewer Guidance

The review process is outlined on this wiki page.

Please focus on whether the marker names and escalation semantics are clear, especially using the existing undefined-log-level path to preserve essential-event behavior.

Fixes: AB#74788

…y are cancel events or if they were above a certain duration
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Hi! Thank you for opening this PR. Want me to review it?

Based on the diff (125 lines, 2 files), I've queued these reviewers:

  • Correctness — logic errors, race conditions, lifecycle issues
  • Security — vulnerabilities, secret exposure, injection
  • API Compatibility — breaking changes, release tags, type design
  • Performance — algorithmic regressions, memory leaks
  • Testing — coverage gaps, hollow tests

How this works

  • Adjust the reviewer set by ticking/unticking boxes above. Reviewer toggles alone don't trigger anything.

  • Tick Start review below to dispatch the review fleet.

  • After review finishes, tick Start review again to request another run — it auto-resets after each dispatch.

  • This comment updates as new commits land; your reviewer selections are preserved.

  • Start review

@MarioJGMsoft MarioJGMsoft marked this pull request as ready for review June 1, 2026 21:29
Copilot AI review requested due to automatic review settings June 1, 2026 21:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds two opt-in markers on IPerformanceEventMarkers to selectively promote performance telemetry events to essential log level: endEventEssentialDurationThresholdMs (escalates _end events whose duration exceeds the threshold) and logCancelAsEssential (escalates _cancel events while preserving their category). Escalation is implemented by returning undefined from a new getLogLevel helper, leveraging the existing sendPerformanceEvent contract that treats undefined as LogLevel.essential. Also fixes a small comment typo (wetherwhether).

Changes:

  • Extend IPerformanceEventMarkers with the two new escalation markers and route reportEvent through a new getLogLevel to apply them.
  • Expand MockLogger in tests to capture per-event log levels and add a Log level escalation suite covering below/above threshold end events, cancel escalation, default behavior, and error-category essential behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/utils/telemetry-utils/src/logger.ts Adds endEventEssentialDurationThresholdMs/logCancelAsEssential markers and getLogLevel to escalate the corresponding events to essential by emitting undefined.
packages/utils/telemetry-utils/src/test/performanceEvent.spec.ts Adds log-level capture to MockLogger and new tests covering threshold-based end escalation, cancel escalation, and unchanged default/error-category behaviors.

Copy link
Copy Markdown
Member

@markfields markfields left a comment

Choose a reason for hiding this comment

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

Thanks for knocking this out! Left some small suggestions

private getLogLevel(
eventNameSuffix: string,
event: ITelemetryPerformanceEventExt,
): typeof LogLevel.verbose | typeof LogLevel.info | undefined {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are we using undefined to signal essential? Seems like unnecessarily tight coupling with the default specified elsewhere

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

because the sendPerformanceEvent can only receive LogLevel.info, LogLevel.verbose or undefined. So we need it to send undefined so that it defaults to LogLevel.essential

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh ok. Might be clearer to update that to take essential at some point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So the reason why I made it that way is because sendPerformanceEvent can only take LogLevel.verbose, LogLevel.info or undefined. With the breaking change happening in #26910, that should be fixable and then it can take esential.

const callback = (): void => {
callbackCalls++;
};
const delay = async (): Promise<void> =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See if you can quickly switch to using Sinon fake timers, which lets you test the delay without taking any real time. Hopefully you can one-shot it with Copilot.

These little ms setTimeouts can quickly add up and unnecessarily bloat unit test run times.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Admittedly 1ms is probably not make-or-break but still good practice to avoid real delays. More reliable way to test too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied change

{ eventName: "EssentialCancel" },
{
cancel: "generic",
logCancelAsEssential: true,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make this the default? Feels likely we'll always want this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I assumed that when you made this the default, I'm guessing you were referring to the logCancelAsEssential code. That change was made

Comment thread packages/utils/telemetry-utils/src/logger.ts
@MarioJGMsoft MarioJGMsoft merged commit 52909a3 into microsoft:main Jun 5, 2026
31 checks passed
@MarioJGMsoft MarioJGMsoft deleted the marioja/performanceEventUpdate branch June 5, 2026 20:10
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.

3 participants