Chore: Add additional debug info to live websocket pushes (#75131)

This commit is contained in:
Todd Treece 2023-09-19 19:33:23 -04:00 committed by GitHub
parent 9dc0c8be11
commit 4f06d362df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package pushws
import ( import (
"net/http" "net/http"
"time"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
liveDto "github.com/grafana/grafana-plugin-sdk-go/live" 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() }() defer func() { _ = conn.Close() }()
setupWSConn(r.Context(), conn, s.config) setupWSConn(r.Context(), conn, s.config)
started := time.Now()
for { for {
_, body, err := conn.ReadMessage() _, body, err := conn.ReadMessage()
if err != nil { if err != nil {
@ -78,10 +81,11 @@ func (s *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
frameFormat := pushurl.FrameFormatFromValues(urlValues) frameFormat := pushurl.FrameFormatFromValues(urlValues)
logger.Debug("Live Push request", logger.Debug("Live Push request",
"protocol", "http", "protocol", "ws",
"streamId", streamID, "streamId", streamID,
"bodyLength", len(body), "bodyLength", len(body),
"frameFormat", frameFormat, "frameFormat", frameFormat,
"duration", time.Since(started).String(),
) )
metricFrames, err := s.converter.Convert(body, frameFormat) metricFrames, err := s.converter.Convert(body, frameFormat)

View File

@ -171,14 +171,14 @@ export class LiveDataStream<T = unknown> {
const liveChannelStatusEvent = isLiveChannelStatusEvent(evt); const liveChannelStatusEvent = isLiveChannelStatusEvent(evt);
if (liveChannelStatusEvent && evt.error) { if (liveChannelStatusEvent && evt.error) {
const err = toDataQueryError(evt.error);
this.stream.next({ this.stream.next({
type: InternalStreamMessageType.Error, type: InternalStreamMessageType.Error,
error: { error: {
...toDataQueryError(evt.error), ...err,
message: `Streaming channel error: ${evt.error.message}`, message: `Streaming channel error: ${err.message}`,
}, },
}); });
return;
} }
if ( if (