workerd icon indicating copy to clipboard operation
workerd copied to clipboard

Implement InvocationSpanContext for user tracing / streaming tail workers

Open jasnell opened this issue 1 year ago • 2 comments

This implements the InvocationSpanContext class. This type holds a tuple of trace ID, invocation ID, and span ID and will be used in support for the updated streaming tail workers implementation. The basic idea is that every top-level request receives a trace ID which is shared across every invocation the occurs within that request. Every individual invocation has a unique invocation ID, and every span within that invocation receives a monotonically increasing span ID.

While this PR does not currently introduce uses of this type, the idea is for all invocations to always have a root InvocationSpanContext and for every child user span created to branch off this root. The current user span then would always have a current InvocationSpanContext that would be propagated outward for all traceable sub requests (generally any subrequest that is not an public internet fetch). A follow up PR will start to introduce the uses and propagation of the span context. This PR only introduces the class impl an the basic test for it. (I'm intentionally breaking this work into smaller incremental PRs to make it easier to review individual chunks).

jasnell avatar Oct 30 '24 16:10 jasnell

Don't merge just yet – will review today

fhanau avatar Oct 30 '24 17:10 fhanau

Don't merge just yet – will review today

Yep, figured as much. Want to make sure this is going to be good with the work you're doing

jasnell avatar Oct 30 '24 17:10 jasnell