2021-02-11 05:28:32 +08:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"go.opentelemetry.io/otel/metric"
|
2021-03-01 07:08:33 +08:00
|
|
|
"go.opentelemetry.io/otel/metric/global"
|
2021-02-11 05:28:32 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// WritesCounter is a count of write commands performed.
|
|
|
|
WritesCounter metric.Int64Counter
|
|
|
|
// NewConnectionsCounter is a count of new connections.
|
|
|
|
NewConnectionsCounter metric.Int64Counter
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
Logger.Printf(context.Background(), "Error creating meter github.com/go-redis/redis for Instruments", r)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2021-03-01 07:08:33 +08:00
|
|
|
meter := metric.Must(global.Meter("github.com/go-redis/redis"))
|
2021-02-11 05:28:32 +08:00
|
|
|
|
|
|
|
WritesCounter = meter.NewInt64Counter("redis.writes",
|
|
|
|
metric.WithDescription("the number of writes initiated"),
|
|
|
|
)
|
|
|
|
|
|
|
|
NewConnectionsCounter = meter.NewInt64Counter("redis.new_connections",
|
|
|
|
metric.WithDescription("the number of connections created"),
|
|
|
|
)
|
|
|
|
}
|