mirror of
https://github.com/redis/go-redis.git
synced 2025-07-31 05:04:23 +03:00
feat: add more stats for otel (#2930)
Signed-off-by: rfyiamcool <rfyiamcool@163.com> Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
This commit is contained in:
@ -127,6 +127,22 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hits, err := conf.meter.Int64ObservableUpDownCounter(
|
||||||
|
"db.client.connections.hits",
|
||||||
|
metric.WithDescription("The number of times free connection was found in the pool"),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
misses, err := conf.meter.Int64ObservableUpDownCounter(
|
||||||
|
"db.client.connections.misses",
|
||||||
|
metric.WithDescription("The number of times free connection was not found in the pool"),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
redisConf := rdb.Options()
|
redisConf := rdb.Options()
|
||||||
_, err = conf.meter.RegisterCallback(
|
_, err = conf.meter.RegisterCallback(
|
||||||
func(ctx context.Context, o metric.Observer) error {
|
func(ctx context.Context, o metric.Observer) error {
|
||||||
@ -140,6 +156,8 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
|
|||||||
o.ObserveInt64(usage, int64(stats.TotalConns-stats.IdleConns), metric.WithAttributes(usedAttrs...))
|
o.ObserveInt64(usage, int64(stats.TotalConns-stats.IdleConns), metric.WithAttributes(usedAttrs...))
|
||||||
|
|
||||||
o.ObserveInt64(timeouts, int64(stats.Timeouts), metric.WithAttributes(labels...))
|
o.ObserveInt64(timeouts, int64(stats.Timeouts), metric.WithAttributes(labels...))
|
||||||
|
o.ObserveInt64(hits, int64(stats.Hits), metric.WithAttributes(labels...))
|
||||||
|
o.ObserveInt64(misses, int64(stats.Misses), metric.WithAttributes(labels...))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
idleMax,
|
idleMax,
|
||||||
@ -147,6 +165,8 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
|
|||||||
connsMax,
|
connsMax,
|
||||||
usage,
|
usage,
|
||||||
timeouts,
|
timeouts,
|
||||||
|
hits,
|
||||||
|
misses,
|
||||||
)
|
)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user