diff --git a/cli/daemon/dash/dash.go b/cli/daemon/dash/dash.go index 3b77e407b7..248b65c440 100644 --- a/cli/daemon/dash/dash.go +++ b/cli/daemon/dash/dash.go @@ -337,7 +337,7 @@ func (s *Server) listenTraces() { continue } - data, err := protoEncoder.Marshal(sp) + data, err := protoEncoder.Marshal(sp.Span) if err != nil { log.Error().Err(err).Msg("dash: could not marshal trace") continue @@ -345,7 +345,10 @@ func (s *Server) listenTraces() { s.notify(¬ification{ Method: "trace/new", - Params: json.RawMessage(data), + Params: map[string]any{ + "app_id": sp.AppID, + "span": json.RawMessage(data), + }, }) } } diff --git a/cli/daemon/dash/server.go b/cli/daemon/dash/server.go index f26cc004a6..f0206c9073 100644 --- a/cli/daemon/dash/server.go +++ b/cli/daemon/dash/server.go @@ -19,7 +19,6 @@ import ( "encr.dev/cli/internal/jsonrpc2" "encr.dev/internal/conf" "encr.dev/pkg/fns" - tracepb2 "encr.dev/proto/encore/engine/trace2" ) var upgrader = websocket.Upgrader{ @@ -45,7 +44,7 @@ func NewServer(appsMgr *apps.Manager, runMgr *run.Manager, tr trace2.Store, dash run: runMgr, tr: tr, dashPort: dashPort, - traceCh: make(chan *tracepb2.SpanSummary, 10), + traceCh: make(chan trace2.NewSpanEvent, 10), clients: make(map[chan<- *notification]struct{}), } @@ -63,7 +62,7 @@ type Server struct { run *run.Manager tr trace2.Store dashPort int - traceCh chan *tracepb2.SpanSummary + traceCh chan trace2.NewSpanEvent mu sync.Mutex clients map[chan<- *notification]struct{} diff --git a/cli/daemon/engine/trace2/sqlite/read.go b/cli/daemon/engine/trace2/sqlite/read.go index 9d3c24c636..44fd9001f5 100644 --- a/cli/daemon/engine/trace2/sqlite/read.go +++ b/cli/daemon/engine/trace2/sqlite/read.go @@ -97,7 +97,10 @@ func (s *Store) emitCompleteSpanToListeners(ctx context.Context, appID, traceID, ts := time.Unix(0, startedAt) t.StartedAt = timestamppb.New(ts) for _, ln := range s.listeners { - ln <- &t + ln <- trace2.NewSpanEvent{ + AppID: appID, + Span: &t, + } } } diff --git a/cli/daemon/engine/trace2/sqlite/write.go b/cli/daemon/engine/trace2/sqlite/write.go index 26fec66fbb..0950959f00 100644 --- a/cli/daemon/engine/trace2/sqlite/write.go +++ b/cli/daemon/engine/trace2/sqlite/write.go @@ -24,12 +24,12 @@ func New(db *sql.DB) *Store { type Store struct { db *sql.DB - listeners []chan<- *tracepbcli.SpanSummary + listeners []chan<- trace2.NewSpanEvent } var _ trace2.Store = (*Store)(nil) -func (s *Store) Listen(ch chan<- *tracepbcli.SpanSummary) { +func (s *Store) Listen(ch chan<- trace2.NewSpanEvent) { s.listeners = append(s.listeners, ch) } diff --git a/cli/daemon/engine/trace2/store.go b/cli/daemon/engine/trace2/store.go index a64c17798b..2839b852b8 100644 --- a/cli/daemon/engine/trace2/store.go +++ b/cli/daemon/engine/trace2/store.go @@ -72,5 +72,10 @@ type Store interface { Get(ctx context.Context, appID, traceID string, iter EventIterator) error // Listen listens for new spans. - Listen(ch chan<- *tracepb2.SpanSummary) + Listen(ch chan<- NewSpanEvent) +} + +type NewSpanEvent struct { + AppID string + Span *tracepb2.SpanSummary }