Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more stats for otel #2930

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions extra/redisotel/metrics.go
Expand Up @@ -127,6 +127,22 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
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()
_, err = conf.meter.RegisterCallback(
func(ctx context.Context, o metric.Observer) error {
Expand All @@ -140,13 +156,17 @@ func reportPoolStats(rdb *redis.Client, conf *config) error {
o.ObserveInt64(usage, int64(stats.TotalConns-stats.IdleConns), metric.WithAttributes(usedAttrs...))

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
},
idleMax,
idleMin,
connsMax,
usage,
timeouts,
hits,
misses,
)

return err
Expand Down