feat(WO-1143): add SpanKind to SpanOpen and Outcome STW events#6471
feat(WO-1143): add SpanKind to SpanOpen and Outcome STW events#6471repository wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR adds SpanKind (matching the OTel spec) to SpanOpen, Onset, and related data structures, threading it through serialization and the span submission/reporting interfaces.
Findings (ranked by severity):
-
[MEDIUM] Tests don't verify
spanKindround-trips through serialization/clone. The existingRead/Write SpanOpen worksandRead/Write Onset workstests (src/workerd/io/trace-test.c++) only exercise the defaultSpanKind::INTERNALand never assert the field value. A serialization bug (e.g.copyToor the reader constructor silently dropping the field) would not be caught. I'd recommend adding test cases that constructSpanOpenandOnsetwith a non-defaultSpanKind(e.g.,CLIENTorSERVER) and assert it survives:copyTo→ reader → constructor round-tripclone()
For example, for
SpanOpen:KJ_TEST("Read/Write SpanOpen preserves SpanKind") { capnp::MallocMessageBuilder builder; auto infoBuilder = builder.initRoot<rpc::Trace::SpanOpen>(); SpanOpen info(0x2a2a2a2a2a2a2a2a, "foo"_kjc, SpanKind::CLIENT); KJ_ASSERT(info.spanKind == SpanKind::CLIENT); info.copyTo(infoBuilder); auto reader = infoBuilder.asReader(); SpanOpen info2(reader); KJ_ASSERT(info2.spanKind == SpanKind::CLIENT); SpanOpen info3 = info.clone(); KJ_ASSERT(info3.spanKind == SpanKind::CLIENT); }
And similarly for
OnsetwithSpanKind::SERVER. -
[LOW]
CompleteSpanhasspanKindfield butUserSpanDatacapnp does not. This is fine becauseCompleteSpan/UserSpanDatais legacy (markedobsolete26) and theCompleteSpanis decomposed intoSpanOpenData+SpanEndDatabefore transmission. Just noting for awareness — no action needed.
Everything else looks correct: cap'n proto changes are purely additive (wire-compatible), serialization/deserialization is consistent across all paths, defaults are sensible, and the SpanKind enum values match the OTel spec.
This review was generated by an AI assistant and may contain inaccuracies.
|
Review posted successfully on PR #6471. The main finding is a medium-severity gap in test coverage -- the existing serialization round-trip tests for |
We currently determine SpanKind in our streaming tail worker based on the names/attributes of the spans, but we'd like this kind of determination to be made directly in the runtime when spans are crated.
This adds the field
SpanKindto theOnsetandSpanOpenfor the STW, which can be "one ofClient,Server,Internal,Producer, orConsumer" as per OTel spec.If not specified, spans created via
UserSpanObserver::reportStartwill default toInternal.This is the first of three changes. Please also see:
Exposing
SpanKindonOnsetto JS, and determining it by the onset info typehttps://github.com/cloudflare/workerd/pull/TBD
repository/workerd@lngo/spankind-1...repository:workerd:lngo/spankind-2
Exposing
SpanKindonSpanOpento JS, adding methods to set it, and setting it at various call siteshttps://github.com/cloudflare/workerd/pull/TBD
repository/workerd@lngo/spankind-1...repository:workerd:lngo/spankind-3