redisotel

package module
v9.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: BSD-2-Clause Imports: 17 Imported by: 262

README

OpenTelemetry instrumentation for go-redis

Installation

go get github.com/redis/go-redis/extra/redisotel/v9

Usage

Tracing is enabled by adding a hook:

import (
    "github.com/redis/go-redis/v9"
    "github.com/redis/go-redis/extra/redisotel/v9"
)

rdb := rdb.NewClient(&rdb.Options{...})

// Enable tracing instrumentation.
if err := redisotel.InstrumentTracing(rdb); err != nil {
	panic(err)
}

// Enable metrics instrumentation.
if err := redisotel.InstrumentMetrics(rdb); err != nil {
	panic(err)
}

See example and Monitoring Go Redis Performance and Errors for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicCommandFilter added in v9.14.1

func BasicCommandFilter(cmd redis.Cmder) bool

BasicCommandFilter filters out AUTH commands from tracing. Deprecated: use DefaultCommandFilter instead.

func DefaultCommandFilter added in v9.16.0

func DefaultCommandFilter(cmd redis.Cmder) bool

DefaultCommandFilter filters out AUTH commands from tracing.

func InstrumentMetrics

func InstrumentMetrics(rdb redis.UniversalClient, opts ...MetricsOption) error

InstrumentMetrics starts reporting OpenTelemetry Metrics.

Based on https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-metrics.md

func InstrumentTracing

func InstrumentTracing(rdb redis.UniversalClient, opts ...TracingOption) error

Types

type MetricsOption

type MetricsOption interface {
	// contains filtered or unexported methods
}

func WithCloseChan added in v9.12.0

func WithCloseChan(closeChan chan struct{}) MetricsOption

func WithMeterProvider

func WithMeterProvider(mp metric.MeterProvider) MetricsOption

WithMeterProvider configures a metric.Meter used to create instruments.

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAttributes

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

WithAttributes specifies additional attributes to be added to the span.

func WithDBSystem

func WithDBSystem(dbSystem string) Option

type TracingOption

type TracingOption interface {
	// contains filtered or unexported methods
}

func WithCallerEnabled added in v9.11.0

func WithCallerEnabled(on bool) TracingOption

WithCallerEnabled tells the tracing hook to log the calling function, file and line.

func WithCommandFilter added in v9.14.1

func WithCommandFilter(filter func(cmd redis.Cmder) bool) TracingOption

WithCommandFilter allows filtering of commands when tracing to omit commands that may have sensitive details like passwords.

func WithCommandsFilter added in v9.16.0

func WithCommandsFilter(filter func(cmds []redis.Cmder) bool) TracingOption

WithCommandsFilter allows filtering of pipeline commands when tracing to omit commands that may have sensitive details like passwords in a pipeline.

func WithDBStatement

func WithDBStatement(on bool) TracingOption

WithDBStatement tells the tracing hook to log raw redis commands.

func WithDialFilter added in v9.16.0

func WithDialFilter(on bool) TracingOption

WithDialFilter enables or disables filtering of dial commands.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) TracingOption

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.

Jump to

Keyboard shortcuts

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