Repository navigation
Conversation
IsValidInstrumentName used char.IsLetter / char.IsLetterOrDigit, so non-ASCII names were accepted although the spec's instrument name syntax (and the existing warning) only allow ASCII. They are now rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
The ASCII checks reject Unicode letters and digits while preserving valid ASCII instrument names. Existing compatibility helpers support both APIs on .NET 6.
🤖 Bits Code Review · Commit d49e35a
BenchmarksBenchmark execution time: 2026-11-26 15:03:32 Comparing candidate commit d49e35a in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 18 metrics, 0 unstable metrics, 8 known flaky benchmarks, 135 flaky benchmarks without significant changes.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9831) and master. ✅ No regressions detected |
Summary of changes
OTel metrics instrument names must now be ASCII, as the OpenTelemetry spec's instrument name syntax requires. Instruments with non-ASCII names are rejected with the existing warning instead of being exported.
Reason for change
The OTel metrics API spec defines instrument names as ASCII strings:
IsValidInstrumentNameusedchar.IsLetter/char.IsLetterOrDigit, which accept any Unicode letter or digit, so names such asrequêtes, or with a dotlessı, a Kelvin signKor an Arabic-Indic digit٢, were accepted and exported, although the rejection warning already says "Instrument names must be ASCII".Non-ASCII names also case-fold inconsistently (the Kelvin sign lowercases to ASCII
kbut doesn't uppercase toK). Rejecting them rules out mismatches between case-insensitive comparisons of instrument names, which matters for #9727, where stream names are built with a lowercased instrument name.Implementation details
MetricReaderHandler.IsValidInstrumentName: the first character must be an ASCII letter (char.IsAsciiLetter), the following ones ASCII letters or digits (char.IsAsciiLetterOrDigit) or_,.,-,/. The 255-character limit is unchanged.char.IsAsciiLetter/char.IsAsciiLetterOrDigitare .NET 7+ APIs, provided on the .NET 6 build by the repo's existing polyfill (Util/CharHelpers.cs).Behavior changes to note
Instruments whose names contain non-ASCII characters (e.g.
requêtes, Cyrillic or CJK names), which were exported before, are now rejected: their measurements are no longer exported, and a warning is logged when the instrument is created.Test coverage
New theory
MeterListenerTests.OnlyAsciiInstrumentNamesAreExported:test.ascii.name_1/x-y;test.requêtes,éclair.count(non-ASCII first character),test.countı(dotless ı), the Kelvin-sign name andtest.count٢(Arabic-Indic digit). The Kelvin sign is rejected on purpose: OTel .NET's case-insensitive name regex probably accepts it, but the spec only allows ASCII.Without the fix, the five non-ASCII cases fail (they are exported). The OTel tests pass on .NET 11 and .NET 6.
Other details
Resolves the "accept ASCII only" item in #9727's Follow-ups.
🤖 Generated with Claude Code