From 17c939d38edd87fe54b6dc49fa4a7250d8a5ba10 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Fri, 22 Nov 2024 14:01:54 -0500 Subject: [PATCH] add PassthroughTraceWorker definitions --- src/workerd/io/trace.h | 8 ++++---- src/workerd/io/worker-interface.capnp | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/workerd/io/trace.h b/src/workerd/io/trace.h index ac379159d77..3c203ec95a7 100644 --- a/src/workerd/io/trace.h +++ b/src/workerd/io/trace.h @@ -584,11 +584,11 @@ class BaseTracer { kj::Date timestamp, kj::String channel, kj::Array message) = 0; // Adds info about the event that triggered the trace. Must not be called more than once. - virtual void setEventInfo(kj::Date timestamp, tracing::EventInfo&&) = 0; + virtual void setEventInfo(kj::Date timestamp, tracing::EventInfo&& info) = 0; // Adds info about the response. Must not be called more than once, and only // after passing a FetchEventInfo to setEventInfo(). - virtual void setFetchResponseInfo(tracing::FetchResponseInfo&&) = 0; + virtual void setFetchResponseInfo(tracing::FetchResponseInfo&& info) = 0; virtual void setOutcome(EventOutcome outcome, kj::Duration cpuTime, kj::Duration wallTime) = 0; }; @@ -617,8 +617,8 @@ class WorkerTracer final: public kj::Refcounted, public BaseTracer { kj::Maybe stack) override; void addDiagnosticChannelEvent( kj::Date timestamp, kj::String channel, kj::Array message) override; - void setEventInfo(kj::Date timestamp, tracing::EventInfo&&) override; - void setFetchResponseInfo(tracing::FetchResponseInfo&&) override; + void setEventInfo(kj::Date timestamp, tracing::EventInfo&& info) override; + void setFetchResponseInfo(tracing::FetchResponseInfo&& info) override; void setOutcome(EventOutcome outcome, kj::Duration cpuTime, kj::Duration wallTime) override; // Used only for a Trace in a process sandbox. Copies the content of this tracer's trace to the diff --git a/src/workerd/io/worker-interface.capnp b/src/workerd/io/worker-interface.capnp index 10c8b4a60e2..89e28e11f16 100644 --- a/src/workerd/io/worker-interface.capnp +++ b/src/workerd/io/worker-interface.capnp @@ -486,3 +486,28 @@ interface WorkerdBootstrap { # TODO(someday): Pass cfBlobJson? Currently doesn't matter since the cf blob is only present for # HTTP requests which can be delivered over regular HTTP instead of capnp. } + +interface PassthroughTraceWorker { + struct EventInfo { + union { + fetch @0 :Trace.FetchEventInfo; + jsRpc @1 :Trace.JsRpcEventInfo; + scheduled @2 :Trace.ScheduledEventInfo; + alarm @3 :Trace.AlarmEventInfo; + queue @4 :Trace.QueueEventInfo; + custom @5 :Trace.CustomEventInfo; + email @6 :Trace.EmailEventInfo; + trace @7 :Trace.TraceEventInfo; + hibernatableWebSocket @8 :Trace.HibernatableWebSocketEventInfo; + } + } + + setEventInfo @0 (timestampNs :Int64, eventInfo :EventInfo); + addLog @1 (timestampNs :Int64, logLevel :Trace.Log.Level, message :Text, isSpan :Bool); + addException @2 (timestampNs :Int64, name :Text, message :Text, stack :Text = null); + addDiagnosticChannelEvent @3 (timestampNs :Int64, channel :Text, message :Data); + setFetchResponseInfo @4 (info :Trace.FetchResponseInfo); + setOutcome @5 (outcome :EventOutcome, cpuTime :UInt64, wallTime :UInt64); + # TODO(soon): Uncomment when Span definitions exist in workerd. + # addSpan @2 (span :TraceCollector.Span, spanContext :Text); +}