@@ -1699,10 +1699,10 @@ class RequestObserverWithTracer final: public RequestObserver, public WorkerInte
16991699 kj::uint fetchStatus = 0 ;
17001700};
17011701
1702- class SpanSubmitter final : public kj::Refcounted {
1702+ class SequentialSpanSubmitter final : public SpanSubmitter {
17031703 public:
1704- SpanSubmitter (kj::Own<WorkerTracer> workerTracer): workerTracer(kj::mv(workerTracer)) {}
1705- void submitSpan (tracing::SpanId spanId, tracing::SpanId parentSpanId, const Span& span) {
1704+ SequentialSpanSubmitter (kj::Own<WorkerTracer> workerTracer): workerTracer(kj::mv(workerTracer)) {}
1705+ void submitSpan (tracing::SpanId spanId, tracing::SpanId parentSpanId, const Span& span) override {
17061706 // We largely recreate the span here which feels inefficient, but is hard to avoid given the
17071707 // mismatch between the Span type and the full span information required for OTel.
17081708 tracing::CompleteSpan span2 (
@@ -1718,45 +1718,16 @@ class SpanSubmitter final: public kj::Refcounted {
17181718 workerTracer->addSpan (kj::mv (span2));
17191719 }
17201720
1721- tracing::SpanId makeSpanId () {
1722- return tracing::SpanId (predictableSpanId ++);
1721+ tracing::SpanId makeSpanId () override {
1722+ return tracing::SpanId (nextSpanId ++);
17231723 }
1724- KJ_DISALLOW_COPY_AND_MOVE (SpanSubmitter );
1724+ KJ_DISALLOW_COPY_AND_MOVE (SequentialSpanSubmitter );
17251725
17261726 private:
1727- uint64_t predictableSpanId = 0 ;
1727+ uint64_t nextSpanId = 1 ;
17281728 kj::Own<WorkerTracer> workerTracer;
17291729};
17301730
1731- class WorkerTracerSpanObserver : public SpanObserver {
1732- public:
1733- WorkerTracerSpanObserver (
1734- kj::Own<SpanSubmitter> spanSubmitter, tracing::SpanId parentSpanId = tracing::SpanId::nullId)
1735- : spanSubmitter(kj::mv(spanSubmitter)),
1736- spanId (this ->spanSubmitter->makeSpanId ()),
1737- parentSpanId(parentSpanId) {}
1738-
1739- KJ_DISALLOW_COPY_AND_MOVE (WorkerTracerSpanObserver);
1740-
1741- [[nodiscard]] kj::Own<SpanObserver> newChild () override {
1742- return kj::refcounted<WorkerTracerSpanObserver>(kj::addRef (*spanSubmitter), spanId);
1743- }
1744-
1745- void report (const Span& span) override {
1746- spanSubmitter->submitSpan (spanId, parentSpanId, span);
1747- }
1748-
1749- // Provide I/O time to the tracing system for user spans.
1750- kj::Date getTime () override {
1751- return IoContext::current ().now ();
1752- }
1753-
1754- private:
1755- kj::Own<SpanSubmitter> spanSubmitter;
1756- tracing::SpanId spanId;
1757- tracing::SpanId parentSpanId;
1758- };
1759-
17601731// IsolateLimitEnforcer that enforces no limits.
17611732class NullIsolateLimitEnforcer final : public IsolateLimitEnforcer {
17621733 public:
@@ -2201,8 +2172,8 @@ class Server::WorkerService final: public Service,
22012172
22022173 KJ_IF_SOME (w, workerTracer) {
22032174 w->setMakeUserRequestSpanFunc ([&w = *w]() {
2204- return SpanParent (
2205- kj::refcounted<WorkerTracerSpanObserver>(kj::refcounted<SpanSubmitter >(kj::addRef (w))));
2175+ return SpanParent (kj::refcounted<UserSpanObserver>(
2176+ kj::refcounted<SequentialSpanSubmitter >(kj::addRef (w))));
22062177 });
22072178 }
22082179 kj::Own<RequestObserver> observer =
0 commit comments