[OpenTelemetry] Fix NotSupportedException - #7788
Merged
Merged
Conversation
Handle `NotSupportedException` when building the wildcard Regex for a large number of activity sources. Fixes open-telemetry#7787.
Pull request dashboard statusMerged · refreshed 2026-09-21 06:30 UTC Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused fix handles the reported exception with bounded fallback behavior and regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes wildcard regex construction failures on .NET 8.
Changes:
- Falls back to a timeout-bounded backtracking regex.
- Adds regression coverage and changelog documentation.
| File | Description |
|---|---|
src/OpenTelemetry/Internal/WildcardHelper.cs |
Adds safe regex fallback. |
test/OpenTelemetry.Tests/Internal/WildcardHelperTests.cs |
Tests large pattern collections. |
src/OpenTelemetry/CHANGELOG.md |
Documents the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7788 +/- ##
==========================================
- Coverage 91.90% 91.87% -0.04%
==========================================
Files 339 339
Lines 18543 18545 +2
==========================================
- Hits 17042 17038 -4
- Misses 1501 1507 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
martincostello
marked this pull request as ready for review
September 19, 2026 08:25
martincostello
enabled auto-merge
September 19, 2026 08:25
martincostello
disabled auto-merge
September 19, 2026 11:14
`RegexOptions.NonBacktracking` causes significantly more memory for the same patterns, so rely solely on the match timeout to avoid `OutOfMemoryException` in consumers in large patterns.
martincostello
enabled auto-merge
September 19, 2026 13:19
martincostello
disabled auto-merge
September 20, 2026 10:12
4 tasks
Extend the same fix to views for the only other usage of `RegexOptions.NonBacktracking` too.
martincostello
enabled auto-merge
September 20, 2026 17:39
Kielek
approved these changes
Sep 21, 2026
This was referenced Sep 25, 2026
Closed
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7787
Changes
The internal limit on automata in .NET 8 is 1,000 but for .NET 9+ it's 10,000, which could cause
NotSupportedExceptionon .NET 8 when building the wildcard Regex for a large number of activity sources.In usage with a lot of
TracerProviderinstances being created, non-backtracking could also causeOutOfMemoryExceptionto be thrown, as it consumes ~35x more memory perRegex.The fix is to stop using
RegexOptions.NonBacktrackingand useRegexOptions.Compiledfor all TFMs. The match timeout should guard against the scenarios that prompted the original change.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)