Skip to content

feat: add custom tracing macro to use reports#1500

Draft
drahnr wants to merge 12 commits intonextfrom
bernhard-1269-tracing-impro
Draft

feat: add custom tracing macro to use reports#1500
drahnr wants to merge 12 commits intonextfrom
bernhard-1269-tracing-impro

Conversation

@drahnr
Copy link
Contributor

@drahnr drahnr commented Jan 12, 2026

Ref #1406

Adds a miden-node-tracing crate and the inner proc macro impl crate.

The name instrument_with_err_report is suboptimal, open to suggestions or if we want to replace tracing::instrument completely and enhance our instrument_with.. to also handly anyhow errors?

Problem: High cardinality key-spaces slow the backend down

account_id vs account.id make it
a) very hard to find what you need in the honeycomb UI
b) create two different time series which means a cardinality bump

Trimmed UI

tracing::instrument is rather verbose with its key-value style attributes, we only ever use a subset, i.e. we never re-parent spans, but only use parent = None to define a new root span.

Impl

The allowlist controls field keys only — the names on the left-hand side of key = value pairs inside a span or event. It has nothing to do with function names, component names, or span names.

Concretely:

#[instrument(rpc: account.id = %id)]
//           ^^^  ^^^^^^^^^^   ^^^
//           │    │             └─ value  – unrestricted, any _expression_
//           │    └─ field key   – _must_ be in `./allowlist.txt` - this prevents the cardinality bump and accidental key mismatches
//           └─ component    – must be an identifier (const `COMPONENT` or `"string"`
  • Component (rpc:, store:, "block-producer":) — becomes the tracing target
  • Function name — derived from the Rust function name by tracing::instrument, or overridden via name = "...". Not touched by this macro at all
  • Field keys (account.id, block.number, nullifier.id) — the only thing checked against the accountlist.

Details

The PR takes tracing::instrument and tracing::log and wraps them with a custom front-end. If a user provides an unknown key which does not exist verbatim in the allowlist.txt, we do error out and yield a small number of possible alternatives based on some character distance.

See full examples in crates/tracing/tests/ui/pass/instrument.rs

@drahnr drahnr marked this pull request as draft March 4, 2026 11:54
@drahnr drahnr added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Mar 9, 2026
@drahnr drahnr force-pushed the bernhard-1269-tracing-impro branch from 1fb5db1 to baf9b38 Compare March 13, 2026 14:34
@drahnr drahnr requested a review from sergerad March 17, 2026 15:09
@drahnr
Copy link
Contributor Author

drahnr commented Mar 17, 2026

Open questions: Do we want to prefix the function name with the component in the otel? I.e. component.fnname is always constructed and would allow to scope functions by declared component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant