feat(api): accept quoted-key fields in otel logging macros#3567
Conversation
Change $key:ident to $key:tt in otel_info!/otel_warn!/otel_debug!/otel_error! macro arms. This allows dotted attribute names like "otel.component.type" = "value" required by SDK self-observability semantic conventions (open-telemetry/semantic-conventions#3723). Existing callers using plain ident keys continue to work unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3567 +/- ##
=====================================
Coverage 83.0% 83.0%
=====================================
Files 130 130
Lines 27952 27952
=====================================
Hits 23210 23210
Misses 4742 4742 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the public otel_info!, otel_warn!, otel_debug!, and otel_error! macros in the opentelemetry crate to accept quoted attribute keys (string literals) in addition to identifier keys, enabling semantic-convention attribute names like "otel.component.type" for internal/self-observability logging.
Changes:
- Relax macro field-key matching from
$key:identto$key:ttfor the key/value field arms. - Preserve existing behavior for identifier keys while enabling string-literal keys in the same call sites.
- Keep the existing
#[cfg(test)]stdout-print behavior (viastringify!($key)).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I think that there should be a |
Added. |
…s-quoted-keys # Conflicts: # opentelemetry/CHANGELOG.md
Changes
$key:identto$key:ttin theotel_info!,otel_warn!,otel_debug!, andotel_error!macro arms. This allows dotted attribute names like"otel.component.type" = "value"which are required by SDK self-observability semantic conventions (open-telemetry/semantic-conventions#3723).Existing callers using plain ident keys continue to work unchanged —
ttmatches both identifiers and string literals. The#[cfg(test)]print branch also works:stringify!on a string-literal tt produces the quoted form (e.g."otel.component.type"=value), which is still readable debug output.Once this lands, the shutdown-event POC (#3552) can switch from
opentelemetry::_private::info!to the publicotel_info!macro.