From 4f06d362df2fd7390e830a056d30d4419e84b13b Mon Sep 17 00:00:00 2001 From: Todd Treece <360020+toddtreece@users.noreply.github.com> Date: Tue, 19 Sep 2023 19:33:23 -0400 Subject: [PATCH] Chore: Add additional debug info to live websocket pushes (#75131) --- pkg/services/live/pushws/push_stream.go | 6 +++++- public/app/features/live/centrifuge/LiveDataStream.ts | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/services/live/pushws/push_stream.go b/pkg/services/live/pushws/push_stream.go index 12f6adf309d..649a97d9f34 100644 --- a/pkg/services/live/pushws/push_stream.go +++ b/pkg/services/live/pushws/push_stream.go @@ -2,6 +2,7 @@ package pushws import ( "net/http" + "time" "github.com/gorilla/websocket" liveDto "github.com/grafana/grafana-plugin-sdk-go/live" @@ -60,6 +61,8 @@ func (s *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { defer func() { _ = conn.Close() }() setupWSConn(r.Context(), conn, s.config) + started := time.Now() + for { _, body, err := conn.ReadMessage() if err != nil { @@ -78,10 +81,11 @@ func (s *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { frameFormat := pushurl.FrameFormatFromValues(urlValues) logger.Debug("Live Push request", - "protocol", "http", + "protocol", "ws", "streamId", streamID, "bodyLength", len(body), "frameFormat", frameFormat, + "duration", time.Since(started).String(), ) metricFrames, err := s.converter.Convert(body, frameFormat) diff --git a/public/app/features/live/centrifuge/LiveDataStream.ts b/public/app/features/live/centrifuge/LiveDataStream.ts index 07613ff676f..fbb93929b81 100644 --- a/public/app/features/live/centrifuge/LiveDataStream.ts +++ b/public/app/features/live/centrifuge/LiveDataStream.ts @@ -171,14 +171,14 @@ export class LiveDataStream { const liveChannelStatusEvent = isLiveChannelStatusEvent(evt); if (liveChannelStatusEvent && evt.error) { + const err = toDataQueryError(evt.error); this.stream.next({ type: InternalStreamMessageType.Error, error: { - ...toDataQueryError(evt.error), - message: `Streaming channel error: ${evt.error.message}`, + ...err, + message: `Streaming channel error: ${err.message}`, }, }); - return; } if (