Add canonical tracing attribute encoding - #2509
Merged
Merged
Conversation
Mirko-von-Leipzig
marked this pull request as ready for review
August 24, 2026 09:11
Mirko-von-Leipzig
marked this pull request as draft
August 24, 2026 09:35
Mirko-von-Leipzig
force-pushed
the
mirko/tracing-attributes
branch
3 times, most recently
from
August 24, 2026 15:20
cb47702 to
d3c0526
Compare
Comment on lines
+12
to
+143
| const BOOLEAN_FIELD_NAMES: &[&str] = &[ | ||
| "account.updated", | ||
| "note.erased", | ||
| "note.id_resolved", | ||
| "panic", | ||
| "request.include_mmr_proof", | ||
| "request.include_proof", | ||
| "rpc.authentication.configured", | ||
| ]; | ||
|
|
||
| const NUMBER_FIELD_NAMES: &[&str] = &[ | ||
| "account.id.length", | ||
| "account.index", | ||
| "asset.amount", | ||
| "batch.expiration_height", | ||
| "batch.expires_at", | ||
| "batch.reference_block.number", | ||
| "batch.size", | ||
| "block.from", | ||
| "block.number", | ||
| "block.protocol.version", | ||
| "block.size", | ||
| "block.timestamp", | ||
| "block_range.from", | ||
| "block_range.to", | ||
| "counter.failures.consecutive", | ||
| "counter.latency.timeout_ms", | ||
| "counter.value.expected", | ||
| "counter.value.observed", | ||
| "counter.value.target", | ||
| "current_client_block_height", | ||
| "cutoff_block", | ||
| "db.account_state_forest.size", | ||
| "db.account_tree.size", | ||
| "db.block_store.size", | ||
| "db.nullifier_tree.size", | ||
| "db.sqlite.connection_pool_size", | ||
| "db.sqlite.size", | ||
| "db.sqlite.wal.size", | ||
| "dice_roll", | ||
| "failure_rate", | ||
| "inputs_size", | ||
| "mempool.accounts", | ||
| "mempool.batches.proposed", | ||
| "mempool.batches.proven", | ||
| "mempool.nullifiers", | ||
| "mempool.output_notes", | ||
| "mempool.transactions.unbatched", | ||
| "mempool.transactions.uncommitted", | ||
| "note.tag", | ||
| "ntx_builder.max_cycles", | ||
| "ntx_builder.tx_expiration_delta", | ||
| "port", | ||
| "pow.hash", | ||
| "pow.nonce", | ||
| "pow.target", | ||
| "pow.target.leading_zero_bits", | ||
| "prefix_len", | ||
| "proof_size", | ||
| "prover.capacity", | ||
| "prover.port", | ||
| "prover.proof_type.raw", | ||
| "reference_block.number", | ||
| "retry.attempt", | ||
| "retry.delay_ms", | ||
| "shutdown.grace_period_ms", | ||
| "snapshot.block_num", | ||
| "snapshot.lifetime_ms", | ||
| "snapshot.superseded_for_ms", | ||
| "snapshots.live", | ||
| "subscription.idle_ms", | ||
| "subscription.stall_timeout_ms", | ||
| "sync.block_gap", | ||
| "sync.ready_threshold", | ||
| "sync.upstream_block", | ||
| "timeout.ms", | ||
| "tip.number", | ||
| "tip.stale_duration_secs", | ||
| "transaction.expiration_delta", | ||
| "transaction.expires_at", | ||
| "transaction.reference_block.number", | ||
| "transaction.submitted_at", | ||
| "worker.status.raw", | ||
| "workers.active", | ||
| "workers.capacity", | ||
| ]; | ||
|
|
||
| const STRING_FIELD_NAMES: &[&str] = &[ | ||
| "account.id", | ||
| "account.storage.kind", | ||
| "account.storage.map.entry.operation", | ||
| "account.storage.operation", | ||
| "asset.symbol", | ||
| "batch.interval", | ||
| "block.interval", | ||
| "dependency.endpoint", | ||
| "dependency.name", | ||
| "genesis.source", | ||
| "genesis.source.kind", | ||
| "internal.listen", | ||
| "mempool.removal.reason", | ||
| "network_monitor.listen", | ||
| "node.role", | ||
| "note.execution_cycles", | ||
| "ntx_builder.endpoint", | ||
| "ntx_builder.idle_timeout", | ||
| "ntx_builder.listen", | ||
| "operation.name", | ||
| "path", | ||
| "pow.challenge.prefix", | ||
| "prover", | ||
| "prover.kind", | ||
| "prover.timeout", | ||
| "request.kind", | ||
| "rpc.endpoint", | ||
| "rpc.listen", | ||
| "sequencer.endpoint", | ||
| "service.name", | ||
| "service.version", | ||
| "shutdown.signal", | ||
| "sync.block_source.endpoint", | ||
| "task.name", | ||
| "transaction.id", | ||
| "transaction.input_notes", | ||
| "transaction.output_notes", | ||
| "tx_prover.endpoint", | ||
| "validator.admin_listen", | ||
| "validator.endpoints", | ||
| "validator.listen", | ||
| "validator.signer", | ||
| "worker.name", | ||
| ]; |
Collaborator
Author
There was a problem hiding this comment.
This long list of primitives fall primarily into two camps:
- Things that should be opt-out/once off so they shouldn't be here, or
- things that are named wrong e.g. endpoint/listen etc should probably just be
listen.
We should attempt to minimize these going further.
Mirko-von-Leipzig
marked this pull request as ready for review
August 24, 2026 15:30
sergerad
reviewed
Aug 24, 2026
| } | ||
|
|
||
| impl RecordAttribute for Path { | ||
| const FIELD_NAMES: &'static [&'static str] = &["data.directory", "genesis.file", "path"]; |
Collaborator
There was a problem hiding this comment.
This kind of thing feels strange (domain specific language in the utility crate) but the end result is positive.
Collaborator
Author
There was a problem hiding this comment.
Yeah, its a bit unfortunate, but that's what Rust's orphan rules result in :/
In theory we could new type this, or do something cleverer, but at this point its not super worth it imo. I also move this into a dedicated tracing crate at end-of-stack which may make it slightly less weird.
Mirko-von-Leipzig
force-pushed
the
mirko/tracing-attributes
branch
from
August 27, 2026 13:04
d3c0526 to
f2e667f
Compare
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.
Closes #2325
Summary
Adds a new tracing trait
RecordAttribute. Recorded fields must implement this trait in order to be recorded (opt-out is possible).The trait allows a type to define its trace value encoding, as well as the attribute names it allows. This tightens the contract on what key-value fields may assume, I'm hoping this allows us to standardize better.
This PR doesn't migrate to this trait yet; that will come in follow-up stack PRs.
One additional (debateable) detail is that this automatically allows for pluralisation for list-type containers. This is pretty basic; but we can extend the grammar e.g. if
Tallowstransaction.idthen&[T]allowstransaction.ids.Changelog