Skip to content

Commit

Permalink
[receiver/redis] Seconds as unit for redis.cmd.latency metric. (open-…
Browse files Browse the repository at this point in the history
…telemetry#26686)

Changed unit for `redis.cmd.latency` metric from
microseconds to seconds.

open-telemetry#6942

Co-authored-by: Alex Boten <aboten@lightstep.com>
  • Loading branch information
2 people authored and jorgeancal committed Sep 18, 2023
1 parent b4f997d commit 7c96f61
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion receiver/redisreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Command execution latency

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| us | Gauge | Double |
| s | Gauge | Double |

#### Attributes

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion receiver/redisreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ metrics:
redis.cmd.latency:
enabled: false
description: Command execution latency
unit: us
unit: s
gauge:
value_type: double
attributes: [cmd, percentile]
Expand Down
4 changes: 3 additions & 1 deletion receiver/redisreceiver/redis_scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,16 @@ func (rs *redisScraper) recordCmdStatsMetrics(ts pcommon.Timestamp, cmd, val str

// recordCmdLatencyMetrics record latency metrics of a particular Redis command.
// 'cmd' is the Redis command, 'val' is the values string (e.g. "p50=1.003,p99=1.003,p99.9=1.003).
// Latency values in the values string are expressed in microseconds.
func (rs *redisScraper) recordCmdLatencyMetrics(ts pcommon.Timestamp, cmd, val string) {
latencies, err := parseLatencyStats(val)
if err != nil {
return
}

for percentile, latency := range latencies {
for percentile, usecs := range latencies {
if percentileAttr, ok := metadata.MapAttributePercentile[percentile]; ok {
latency := usecs / 1e6 // metric is in seconds
rs.mb.RecordRedisCmdLatencyDataPoint(ts, latency, cmd, percentileAttr)
}
}
Expand Down

0 comments on commit 7c96f61

Please sign in to comment.