Use valkeyotel.NewClient
to create a client with OpenTelemetry Tracing and Connection Metrics enabled.
Builtin connection metrics are:
valkey_dial_attempt
: number of dial attemptsvalkey_dial_success
: number of successful dialsvalkey_dial_conns
: number of connectionsvalkey_dial_latency
: dial latency in seconds
Client side caching metrics:
valkey_do_cache_miss
: number of cache miss on client sidevalkey_do_cache_hits
: number of cache hits on client side
package main
import (
"github.com/valkey-io/valkey-go"
"github.com/valkey-io/valkey-go/valkeyotel"
)
func main() {
client, err := valkeyotel.NewClient(valkey.ClientOption{InitAddress: []string{"127.0.0.1:6379"}})
if err != nil {
panic(err)
}
defer client.Close()
}
See valkeyhook if you want more customizations.
Note: valkeyotel.NewClient
is not supported on go1.18 and go1.19 builds. Reference