mirror of https://github.com/go-redis/redis.git
Merge 960ff8bd39
into 080e051124
This commit is contained in:
commit
4a9458ea65
|
@ -83,9 +83,9 @@ func InstrumentMetrics(rdb redis.UniversalClient, opts ...MetricsOption) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportPoolStats(rdb *redis.Client, conf *config) error {
|
func reportPoolStats(rdb *redis.Client, conf *config) error {
|
||||||
labels := conf.attrs
|
poolAttrs := attribute.NewSet(conf.attrs...)
|
||||||
idleAttrs := append(labels, attribute.String("state", "idle"))
|
idleAttrs := attribute.NewSet(append(poolAttrs.ToSlice(), attribute.String("state", "idle"))...)
|
||||||
usedAttrs := append(labels, attribute.String("state", "used"))
|
usedAttrs := attribute.NewSet(append(poolAttrs.ToSlice(), attribute.String("state", "used"))...)
|
||||||
|
|
||||||
idleMax, err := conf.meter.Int64ObservableUpDownCounter(
|
idleMax, err := conf.meter.Int64ObservableUpDownCounter(
|
||||||
"db.client.connections.idle.max",
|
"db.client.connections.idle.max",
|
||||||
|
@ -132,14 +132,14 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
|
||||||
func(ctx context.Context, o metric.Observer) error {
|
func(ctx context.Context, o metric.Observer) error {
|
||||||
stats := rdb.PoolStats()
|
stats := rdb.PoolStats()
|
||||||
|
|
||||||
o.ObserveInt64(idleMax, int64(redisConf.MaxIdleConns), metric.WithAttributes(labels...))
|
o.ObserveInt64(idleMax, int64(redisConf.MaxIdleConns), metric.WithAttributeSet(poolAttrs))
|
||||||
o.ObserveInt64(idleMin, int64(redisConf.MinIdleConns), metric.WithAttributes(labels...))
|
o.ObserveInt64(idleMin, int64(redisConf.MinIdleConns), metric.WithAttributeSet(poolAttrs))
|
||||||
o.ObserveInt64(connsMax, int64(redisConf.PoolSize), metric.WithAttributes(labels...))
|
o.ObserveInt64(connsMax, int64(redisConf.PoolSize), metric.WithAttributeSet(poolAttrs))
|
||||||
|
|
||||||
o.ObserveInt64(usage, int64(stats.IdleConns), metric.WithAttributes(idleAttrs...))
|
o.ObserveInt64(usage, int64(stats.IdleConns), metric.WithAttributeSet(idleAttrs))
|
||||||
o.ObserveInt64(usage, int64(stats.TotalConns-stats.IdleConns), metric.WithAttributes(usedAttrs...))
|
o.ObserveInt64(usage, int64(stats.TotalConns-stats.IdleConns), metric.WithAttributeSet(usedAttrs))
|
||||||
|
|
||||||
o.ObserveInt64(timeouts, int64(stats.Timeouts), metric.WithAttributes(labels...))
|
o.ObserveInt64(timeouts, int64(stats.Timeouts), metric.WithAttributeSet(poolAttrs))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
idleMax,
|
idleMax,
|
||||||
|
|
Loading…
Reference in New Issue