diff --git a/pkg/services/live/managedstream/cache_memory.go b/pkg/services/live/managedstream/cache_memory.go index e90afd06a0b..1f7f44f0826 100644 --- a/pkg/services/live/managedstream/cache_memory.go +++ b/pkg/services/live/managedstream/cache_memory.go @@ -6,18 +6,22 @@ import ( "sync" "github.com/grafana/grafana-plugin-sdk-go/data" + + "github.com/grafana/grafana/pkg/infra/log" ) // MemoryFrameCache ... type MemoryFrameCache struct { mu sync.RWMutex frames map[int64]map[string]data.FrameJSONCache + log log.Logger } // NewMemoryFrameCache ... func NewMemoryFrameCache() *MemoryFrameCache { return &MemoryFrameCache{ frames: map[int64]map[string]data.FrameJSONCache{}, + log: log.New("live.memoryframecache"), } } @@ -39,7 +43,13 @@ func (c *MemoryFrameCache) GetFrame(ctx context.Context, orgID int64, channel st c.mu.RLock() defer c.mu.RUnlock() cachedFrame, ok := c.frames[orgID][channel] - return cachedFrame.Bytes(data.IncludeAll), ok, nil + raw := cachedFrame.Bytes(data.IncludeAll) + c.log.Debug("Cache get", + "orgId", orgID, + "channel", channel, + "length", len(raw), + ) + return raw, ok, nil } func (c *MemoryFrameCache) Update(ctx context.Context, orgID int64, channel string, jsonFrame data.FrameJSONCache) (bool, error) { @@ -51,5 +61,10 @@ func (c *MemoryFrameCache) Update(ctx context.Context, orgID int64, channel stri cachedJsonFrame, exists := c.frames[orgID][channel] schemaUpdated := !exists || !cachedJsonFrame.SameSchema(&jsonFrame) c.frames[orgID][channel] = jsonFrame + c.log.Debug("Cache update", + "orgId", orgID, + "channel", channel, + "length", len(jsonFrame.Bytes(data.IncludeAll)), + ) return schemaUpdated, nil }