redisotel

package module
v9.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: BSD-2-Clause Imports: 15 Imported by: 176

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 InstrumentMetrics

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

InstrumentMetrics starts reporting OpenTelemetry Metrics.

Based on https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/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 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 WithDBStatement

func WithDBStatement(on bool) TracingOption

WithDBStatement tells the tracing hook not to log raw redis 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