redis/internal/instruments.go

34 lines
810 B
Go
Raw Normal View History

package internal
import (
"context"
2020-11-21 10:56:52 +03:00
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
)
var (
2020-07-16 10:01:27 +03:00
// WritesCounter is a count of write commands performed.
WritesCounter metric.Int64Counter
2020-07-16 10:01:27 +03:00
// 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)
}
}()
2020-11-21 10:56:52 +03:00
meter := metric.Must(otel.Meter("github.com/go-redis/redis"))
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"),
)
}