Skip to content

Thread RoutingMetadata trait through user tracing; move routing heade…#1

Draft
mar-cf wants to merge 3 commits into
user-tracing-7from
user-tracing-7-wip
Draft

Thread RoutingMetadata trait through user tracing; move routing heade…#1
mar-cf wants to merge 3 commits into
user-tracing-7from
user-tracing-7-wip

Conversation

@mar-cf

@mar-cf mar-cf commented Jul 7, 2026

Copy link
Copy Markdown
Owner

// RoutingMetadata is a trait — you define the concrete routing type. group_key batches
// spans that share it into one request; encode produces the routing header's value.
#[derive(Debug)]
struct MyRouting { zone_id: u64, account_id: u64 }

impl RoutingMetadata for MyRouting {
fn group_key(&self) -> String { format!("{}|{}", self.zone_id, self.account_id) }
fn encode(&self) -> String { format!("zone={};account={}", self.zone_id, self.account_id) }
}

// Per request: open the root. routing is required and fixed at construction (inherited by all
// descendants); inbound continues an upstream W3C trace, or None for a fresh one.
let _root = tracing::start_user_trace(
"example_span_name",
MyRouting { zone_id, account_id },
inbound, // Option
);

mar-cf added 3 commits July 1, 2026 13:20
Adds the per-process user pipeline — `UserTracingSettings`, `init_user`/`USER_HARNESS`, and the OTLP-over-UDS exporter that encodes `RoutingMetadata` into the `cf-trace-config` header — wired into `telemetry::init`. `start_user_trace` now takes a required `RoutingMetadata` attached at span construction and inherited by descendants (the exporter drops routing-less spans). Verified end-to-end by producer tests that decode the exported OTLP body.
Adds the `TraceparentContext` W3C parser and wires it through: `start_user_trace` gains an optional `inbound` traceparent that stitches the user root onto the upstream trace (shared trace id, inbound parent), and `user_tracing::w3c_traceparent()` derives the header for the current user span for outbound propagation. Covered by parser unit tests plus continuation tests through the test harness and the OTLP/UDS producer path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant