Skip to content

feat(api): accept quoted-key fields in otel logging macros#3567

Merged
cijothomas merged 3 commits into
open-telemetry:mainfrom
cijothomas:cijothomas/otel-macros-quoted-keys
Jun 25, 2026
Merged

feat(api): accept quoted-key fields in otel logging macros#3567
cijothomas merged 3 commits into
open-telemetry:mainfrom
cijothomas:cijothomas/otel-macros-quoted-keys

Conversation

@cijothomas

Copy link
Copy Markdown
Member

Changes $key:ident to $key:tt in the otel_info!, otel_warn!, otel_debug!, and otel_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 — tt matches 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 public otel_info! macro.

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.
@cijothomas
cijothomas requested a review from a team as a code owner June 23, 2026 17:22
@cijothomas cijothomas added the enhancement New feature or request label Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.0%. Comparing base (fb2af9d) to head (7c3b0d8).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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:ident to $key:tt for 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 (via stringify!($key)).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread opentelemetry/src/global/internal_logging.rs
Comment thread opentelemetry/src/global/internal_logging.rs
Comment thread opentelemetry/src/global/internal_logging.rs
Comment thread opentelemetry/src/global/internal_logging.rs
@bantonsson

Copy link
Copy Markdown
Contributor

I think that there should be a CHANGELOG entry for this.

@cijothomas

Copy link
Copy Markdown
Member Author

I think that there should be a CHANGELOG entry for this.

Added.

@cijothomas
cijothomas added this pull request to the merge queue Jun 25, 2026
Merged via the queue into open-telemetry:main with commit 90a39a0 Jun 25, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants