rueidisotel

package module
v1.0.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 9

README

OpenTelemetry Tracing & Connection Metrics

Use rueidisotel.NewClient to create a client with OpenTelemetry Tracing and Connection Metrics enabled. Builtin connection metrics are:

  • rueidis_dial_attempt: number of dial attempts
  • rueidis_dial_success: number of successful dials
  • rueidis_dial_conns: number of connections
  • rueidis_dial_latency: dial latency in seconds

Client side caching metrics:

  • rueidis_do_cache_miss: number of cache miss on client side
  • rueidis_do_cache_hits: number of cache hits on client side
package main

import (
    "github.com/redis/rueidis"
    "github.com/redis/rueidis/rueidisotel"
)

func main() {
    client, err := rueidisotel.NewClient(rueidis.ClientOption{InitAddress: []string{"127.0.0.1:6379"}})
    if err != nil {
        panic(err)
    }
    defer client.Close()
}

See rueidishook if you want more customizations.

Note: rueidisotel.NewClient is not supported on go1.18 and go1.19 builds. Reference

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(clientOption rueidis.ClientOption, opts ...Option) (rueidis.Client, error)

NewClient creates a new Client. The following metrics are recorded: - rueidis_dial_attempt: number of dial attempts - rueidis_dial_success: number of successful dials - rueidis_dial_conns: number of active connections - rueidis_dial_latency: dial latency in seconds

func WithClient deprecated

func WithClient(client rueidis.Client, opts ...Option) rueidis.Client

WithClient creates a new rueidis.Client with OpenTelemetry tracing enabled.

Deprecated: use NewClient() instead.

Example (OpenTelemetry)
client, err := rueidis.NewClient(rueidis.ClientOption{InitAddress: []string{"127.0.0.1:6379"}})
if err != nil {
	panic(err)
}
client = WithClient(client)
defer client.Close()
Output:

Types

type HistogramOption

type HistogramOption struct {
	Buckets []float64
}

type Option

type Option func(o *otelclient)

Option is the Functional Options interface

func MetricAttrs

func MetricAttrs(attrs ...attribute.KeyValue) Option

MetricAttrs set additional attributes to append to each metric.

func TraceAttrs

func TraceAttrs(attrs ...attribute.KeyValue) Option

TraceAttrs set additional attributes to append to each trace.

func WithDBStatement added in v1.0.34

func WithDBStatement(f StatementFunc) Option

WithDBStatement tells the tracing hook to add raw redis commands to db.statement attribute.

func WithHistogramOption

func WithHistogramOption(histogramOption HistogramOption) Option

WithHistogramOption sets the HistogramOption. If not set, DefaultHistogramBuckets will be used.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider sets the MeterProvider for the otelclient.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider sets the TracerProvider for the otelclient.

type StatementFunc added in v1.0.34

type StatementFunc func(cmdTokens []string) string

StatementFunc is a the function that maps a command's tokens to a string to put in the db.statement attribute

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL