Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
Signed-off-by: RHARI <[email protected]>
  • Loading branch information
RaviHari committed Nov 14, 2023
1 parent 8d6ace6 commit f8dbba6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 4 additions & 4 deletions server/etcdserver/txn/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ var (
Namespace: "etcd",
Subsystem: "server",
Name: "range_duration_seconds",
Help: "The latency distributions of v2 apply called by backend.",
Help: "The latency distributions of txn.Range",

// lowest bucket start of upper bound 0.0001 sec (0.1 ms) with factor 2
// highest bucket start of 0.0001 sec * 2^19 == 52.4288 sec
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 20),
},
[]string{"version", "op", "success"})
[]string{"op", "success"})
)

func ApplySecObserve(version, op string, success bool, latency time.Duration) {
applySec.WithLabelValues(version, op, strconv.FormatBool(success)).Observe(float64(latency.Microseconds()) / 1000000.0)
}

func RangeSecObserve(version, op string, success bool, latency time.Duration) {
rangeSec.WithLabelValues(version, op, strconv.FormatBool(success)).Observe(float64(latency.Microseconds()) / 1000000.0)
func RangeSecObserve(op string, success bool, latency time.Duration) {
rangeSec.WithLabelValues(op, strconv.FormatBool(success)).Observe(float64(latency.Microseconds()) / 1000000.0)
}

func init() {
Expand Down
4 changes: 1 addition & 3 deletions server/etcdserver/txn/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,9 @@ func Range(ctx context.Context, lg *zap.Logger, kv mvcc.KV, r *pb.RangeRequest)
ctx = context.WithValue(ctx, traceutil.TraceKey{}, trace)
}
op := "range"
stringer := &pb.InternalRaftStringer{Request: &pb.InternalRaftRequest{Range: r}}
defer func(start time.Time) {
success := err == nil
RangeSecObserve(v3Version, op, success, time.Since(start))
WarnOfExpensiveRequest(lg, DefaultRangeWarningApplyDuration, start, stringer, nil, nil)
RangeSecObserve(op, success, time.Since(start))
}(time.Now())
txnRead := kv.Read(mvcc.ConcurrentReadTxMode, trace)
defer txnRead.End()
Expand Down

0 comments on commit f8dbba6

Please sign in to comment.