From 966b44e593b81cd207a0e7e335ccc2731c9a2647 Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 30 Jul 2024 22:07:03 +0900 Subject: [PATCH] feat: log redis latency --- node/pkg/aggregator/types.go | 1 + node/pkg/aggregator/utils.go | 1 + node/pkg/dal/collector/collector.go | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/node/pkg/aggregator/types.go b/node/pkg/aggregator/types.go index 45ebb0bb9..425e5a1b2 100644 --- a/node/pkg/aggregator/types.go +++ b/node/pkg/aggregator/types.go @@ -34,6 +34,7 @@ type Proof types.Proof type GlobalAggregate types.GlobalAggregate type SubmissionData struct { + PublishTime time.Time GlobalAggregate GlobalAggregate Proof Proof } diff --git a/node/pkg/aggregator/utils.go b/node/pkg/aggregator/utils.go index 3fc760648..0c88445f0 100644 --- a/node/pkg/aggregator/utils.go +++ b/node/pkg/aggregator/utils.go @@ -47,6 +47,7 @@ func PublishGlobalAggregateAndProof(ctx context.Context, globalAggregate GlobalA data := SubmissionData{ GlobalAggregate: globalAggregate, Proof: proof, + PublishTime: time.Now(), } diff := time.Since(globalAggregate.Timestamp) diff --git a/node/pkg/dal/collector/collector.go b/node/pkg/dal/collector/collector.go index 58d6edb8f..796ce2327 100644 --- a/node/pkg/dal/collector/collector.go +++ b/node/pkg/dal/collector/collector.go @@ -161,7 +161,12 @@ func (c *Collector) processIncomingData(ctx context.Context, data aggregator.Sub symbol := c.Symbols[data.GlobalAggregate.ConfigID] diff := time.Since(data.GlobalAggregate.Timestamp) if diff > 1*time.Second { - log.Warn().Int64("value", data.GlobalAggregate.Value).Dur("duration", diff).Str("Symbol", symbol).Str("Player", "DalCollector").Msg("processing incoming data") + log.Warn().Dur("duration", diff).Str("Symbol", symbol).Str("Player", "DalCollector").Msg("processing incoming data") + } + + diffFromPublish := time.Since(data.PublishTime) + if diffFromPublish > 100*time.Millisecond { + log.Warn().Dur("redisDelay", diffFromPublish).Str("Symbol", symbol).Str("Player", "DalCollector").Msg("redis delay over 100 millisec") } result, err := c.IncomingDataToOutgoingData(ctx, data)