Skip to content

Commit 4cedb5c

Browse files
rfyiamcoolofekshenawandyakov
authored
feat: add more stats for otel (#2930)
Signed-off-by: rfyiamcool <[email protected]> Co-authored-by: ofekshenawa <[email protected]> Co-authored-by: Nedyalko Dyakov <[email protected]>
1 parent 6d788cb commit 4cedb5c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

extra/redisotel/metrics.go

+20
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
127127
return err
128128
}
129129

130+
hits, err := conf.meter.Int64ObservableUpDownCounter(
131+
"db.client.connections.hits",
132+
metric.WithDescription("The number of times free connection was found in the pool"),
133+
)
134+
if err != nil {
135+
return err
136+
}
137+
138+
misses, err := conf.meter.Int64ObservableUpDownCounter(
139+
"db.client.connections.misses",
140+
metric.WithDescription("The number of times free connection was not found in the pool"),
141+
)
142+
if err != nil {
143+
return err
144+
}
145+
130146
redisConf := rdb.Options()
131147
_, err = conf.meter.RegisterCallback(
132148
func(ctx context.Context, o metric.Observer) error {
@@ -140,13 +156,17 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
140156
o.ObserveInt64(usage, int64(stats.TotalConns-stats.IdleConns), metric.WithAttributes(usedAttrs...))
141157

142158
o.ObserveInt64(timeouts, int64(stats.Timeouts), metric.WithAttributes(labels...))
159+
o.ObserveInt64(hits, int64(stats.Hits), metric.WithAttributes(labels...))
160+
o.ObserveInt64(misses, int64(stats.Misses), metric.WithAttributes(labels...))
143161
return nil
144162
},
145163
idleMax,
146164
idleMin,
147165
connsMax,
148166
usage,
149167
timeouts,
168+
hits,
169+
misses,
150170
)
151171

152172
return err

0 commit comments

Comments
 (0)