Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix KeyNotFoundException on HttpRequestLatencyListener.OnEventWritten for uknown event sources#6821

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@ssmelov
Copy link
Contributor

@ssmelovssmelov commentedSep 19, 2025
edited
Loading

Description

The current implementation of HttpRequestLatencyListener.OnEventWritten always expects that eventSourceName should be available in the _eventToTokenMap dictionary.
Certain events (e.g., EventCounters) bypass the enabled events check, which results in OnEventWritten throwing a KeyNotFoundException.

https://github.com/dotnet/runtime/blob/ac8354e3e94f04fae2d6d942427d025395197f76/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs#L2187

Microsoft Reviewers:Open in CodeFlow

Fixes#6822

CopilotAI review requested due to automatic review settingsSeptember 19, 2025 11:42
@ssmelovssmelov requested a review froma team as acode ownerSeptember 19, 2025 11:42
Copy link
Contributor

CopilotAI 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

This PR fixes a KeyNotFoundException that occurs in HttpRequestLatencyListener.OnEventWritten when handling unknown event sources. The issue arises when events like EventCounters bypass the enabled events check, causing the method to attempt dictionary access with a non-existent key.

  • Adds safe dictionary access to prevent KeyNotFoundException when unknown event sources are encountered
  • Includes test coverage to verify the fix handles unknown events correctly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

FileDescription
HttpRequestLatencyListener.csImplements safe dictionary access using TryGetValue to prevent KeyNotFoundException
HttpRequestLatencyListenerTest.csAdds test to verify unknown events don't cause exceptions or add checkpoints

Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.

dariusclayand others added2 commitsSeptember 23, 2025 10:33
…ency/Internal/HttpRequestLatencyListenerTest.csCo-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dariusclaydariusclayenabled auto-merge (squash)September 23, 2025 08:36
@ssmelov
Copy link
ContributorAuthor

@dotnet-policy-service agree company="Microsoft"

@dariusclaydariusclay merged commite5b7f5d intodotnet:mainSep 23, 2025
6 checks passed
This was referencedOct 14, 2025
This was referencedOct 22, 2025
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 24, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

Copilot code reviewCopilotCopilot left review comments

@dariusclaydariusclaydariusclay approved these changes

@evgenyfedorov2evgenyfedorov2evgenyfedorov2 approved these changes

Assignees

@ssmelovssmelov

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

HttpRequestLatencyListener.OnEventWritten throws KeyNotFoundException for unknown event sources

3 participants

@ssmelov@dariusclay@evgenyfedorov2

[8]ページ先頭

©2009-2025 Movatter.jp