Skip to content

Commit

Permalink
add PassthroughTraceWorker definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Nov 22, 2024
1 parent 9614788 commit 4382ef0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/workerd/io/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,11 @@ class BaseTracer {
kj::Date timestamp, kj::String channel, kj::Array<kj::byte> 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;
};
Expand Down Expand Up @@ -617,8 +617,8 @@ class WorkerTracer final: public kj::Refcounted, public BaseTracer {
kj::Maybe<kj::String> stack) override;
void addDiagnosticChannelEvent(
kj::Date timestamp, kj::String channel, kj::Array<kj::byte> 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
Expand Down
25 changes: 25 additions & 0 deletions src/workerd/io/worker-interface.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -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): Add this once Span definitions exist in workerd.
# addSpan @2 (span :TraceCollector.Span, spanContext :Text);
}

0 comments on commit 4382ef0

Please sign in to comment.