Skip to content

Commit db1f5fa

Browse files
odinugegiorio94
authored andcommitted
etcd: add metrics for watch and paginated list requests
Previously there were no metrics emitted for paginated list calls or the corresponding watch events. This leads to a blind spot that could hide real bugs or performance issues. One example was the issue where quorum was down and the list request were executed with "WithSerializable" while the watch required quorum. That resulted in the watch failing and the list starting again - all in a tight loop. That issue was fixed in 1c82d58 ("etcd: require quorum on etcd range requests"), and is no longer present The watch metric only measures the setup time and not the actual time a watch request is open. Signed-off-by: Odin Ugedal <ougedal@palantir.com> Signed-off-by: Odin Ugedal <odin@uged.al>
1 parent a261b7f commit db1f5fa

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pkg/kvstore/etcd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,11 @@ reList:
796796
}
797797
}
798798

799+
watcherDuration := spanstat.Start()
799800
etcdWatch := e.client.Watch(client.WithRequireLeader(ctx), prefix,
800801
client.WithPrefix(), client.WithRev(nextRev))
802+
// This does not measure the actual time a watcher is open, but just the fact that it was opened
803+
increaseMetric(prefix, metricRead, "WatchStart", watcherDuration.EndError(nil).Total(), nil)
801804
lr.Done()
802805

803806
for {
@@ -889,10 +892,12 @@ func (e *etcdClient) paginatedList(ctx context.Context, log *slog.Logger, prefix
889892
start, end := prefix, client.GetPrefixRangeEnd(prefix)
890893

891894
for {
895+
duration := spanstat.Start()
892896
res, err := e.client.Get(ctx, start, client.WithRange(end),
893897
client.WithSort(client.SortByKey, client.SortAscend),
894898
client.WithRev(revision), client.WithLimit(int64(e.listBatchSize)),
895899
)
900+
increaseMetric(prefix, metricRead, "ListPrefixPaginated", duration.EndError(err).Total(), err)
896901
if err != nil {
897902
return nil, 0, err
898903
}

0 commit comments

Comments
 (0)