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 (
"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)

View File

@ -171,14 +171,14 @@ export class LiveDataStream<T = unknown> {
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 (