Derive Macro TraceEvent
#[derive(TraceEvent)]
{
// Attributes available to this derive:
#[traceevent]
}
dial9 only.Expand description
Derives dial9_trace_format::TraceEvent for a struct with named fields.
Supported attributes:
-
#[traceevent(timestamp)](field, required on exactly oneu64field): marks the event timestamp. It is encoded as a packed delta in the event header, not as a regular field. -
#[traceevent(wire_slot)](struct): opts the type into the encoder’s inline fast path by claiming a static wire-ID slot. -
#[traceevent(name = <expr>)](struct): overrides the wire event name (defaults to the struct name). Accepts any&'static strexpression, not just a string literal, so callers can build a per-call-site-unique name — e.g.concat!("SpanEnter:", file!(), ":", line!()). Useful for generated structs that need a name the viewer recognizes (e.g."SpanEnter:..."), which cannot be a valid Rust identifier. -
#[traceevent(name = "...")](field): overrides the field’s wire-schema name. This is useful for canonical names that are not valid Rust identifiers, such as"dial9.tokio.task_id". -
#[traceevent(unit = "...")](field): attaches aunitschema annotation so viewers render the field in that unit. Supported values:"ns","us","ms","s","bytes". Any other value is a compile error, as is placinguniton the timestamp field (the timestamp is encoded in the event header and is always nanoseconds). -
#[traceevent(role = "...")](field): attaches adial9.roleschema annotation, telling consumers what the field is structurally (e.g."span.name"). The vocabulary lives indial9_core::schema_extensions::roles; an unrecognized role is a compile error (it would otherwise decode as no role). -
#[traceevent(kind = "...")](field): attaches akindschema annotation telling the viewer how to chart the field. Supported values:"gauge","counter","updown-counter". Any other value is a compile error, as is placingkindon the timestamp field.
A malformed or unrecognized traceevent key is a compile error. Only structs
with named fields and at most one lifetime parameter are supported; type and
const parameters are rejected.
§Example
#[derive(TraceEvent)]
struct RequestCompleted {
#[traceevent(timestamp)]
timestamp_ns: u64,
#[traceevent(unit = "us")]
latency_us: u64,
status_code: u32,
}