Skip to content

Commit

Permalink
Merge pull request #5512 from oasisprotocol/ptrus/feature/get-diff-me…
Browse files Browse the repository at this point in the history
…tric

go/storage: Add storage metrics for GetDiff
  • Loading branch information
ptrus authored Jan 4, 2024
2 parents bd33e9a + 7b77fe4 commit 8ab01ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .changelog/5512.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/storage: Add storage metrics for `GetDiff` method
14 changes: 14 additions & 0 deletions go/storage/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var (
labelSyncGet = prometheus.Labels{"call": "sync_get"}
labelSyncGetPrefixes = prometheus.Labels{"call": "sync_get_prefixes"}
labelSyncIterate = prometheus.Labels{"call": "sync_iterate"}
labelGetDiff = prometheus.Labels{"call": "get_diff"}

metricsOnce sync.Once
)
Expand All @@ -60,6 +61,19 @@ type metricsWrapper struct {
Backend
}

func (w *metricsWrapper) GetDiff(ctx context.Context, request *GetDiffRequest) (WriteLogIterator, error) {
start := time.Now()
it, err := w.Backend.GetDiff(ctx, request)
storageLatency.With(labelGetDiff).Observe(time.Since(start).Seconds())
if err != nil {
storageFailures.With(labelGetDiff).Inc()
return nil, err
}

storageCalls.With(labelGetDiff).Inc()
return it, err
}

func (w *metricsWrapper) SyncGet(ctx context.Context, request *GetRequest) (*ProofResponse, error) {
start := time.Now()
res, err := w.Backend.SyncGet(ctx, request)
Expand Down

0 comments on commit 8ab01ca

Please sign in to comment.