redis

package
v0.0.0-...-a1dd794 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

README

Redis client for Golang

Installation

go-redis supports 2 last Go versions and requires a Go version with modules support. So make sure to initialize a Go module:

go mod init github.com/my/repo
go get -u github.com/otel-contrib/instrumentation

Quick start

package main

import (
    "context"
    "log"
    "time"

    "github.com/otel-contrib/instrumentation/github.com/go-redis/redis"
)

func main() {
    c := redis.NewClient(&redis.Options{
        Addr:     "localhost:6379",
        Password: "", // no password set
        DB:       0,  // use default DB
    })

    if err := c.Set(context.Background(), "key", "value", time.Minute).Err(); err != nil {
        log.Fatal(err)
    }
}

Documentation

Overview

Package redis implements a Redis client.

Index

Constants

View Source
const (
	LabelKeyDBRedisNumCMD = label.Key("db.redis.num_cmd")
)

Semantic conventions for attribute keys for redis.

View Source
const (
	// Nil reply returned by Redis when key does not exist.
	Nil = redis.Nil
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client = redis.Client

Client is a Redis client representing a pool of zero or more underlying connections. It's safe for concurrent use by multiple goroutines.

func NewClient

func NewClient(opt *Options, opts ...Option) *Client

NewClient returns a client to the Redis Server specified by Options.

type Cmder

type Cmder = redis.Cmder

Cmder defines redis command interface.

type Hook

type Hook = redis.Hook

Hook defines redis OpenTelemetry hook interface.

func NewOTelHook

func NewOTelHook(opt *Options, opts ...Option) (Hook, error)

NewOTelHook returns hook that provides OpenTelemetry tracing and metrics to redis.

type Option

type Option interface {
	Apply(*config)
}

Option applies a configuration to the given config.

func WithMeterProvider

func WithMeterProvider(mp metric.MeterProvider) Option

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

func WithOperationName

func WithOperationName(name string) Option

WithOperationName specifies a operation name. If none is specified, the default operation name is used

func WithSpanNameFormatter

func WithSpanNameFormatter(f SpanNameFormatter) Option

WithSpanNameFormatter specifies a formatter to used to format span names. If none is specified, the default SpanNameFormatter is used

func WithSpanNameFormatterPipeline

func WithSpanNameFormatterPipeline(f SpanNameFormatterPipeline) Option

WithSpanNameFormatterPipeline specifies a formatter to used to format span names. If none is specified, the default SpanNameFormatterPipeline is used

func WithTracerProvider

func WithTracerProvider(tp trace.TracerProvider) Option

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

type OptionFunc

type OptionFunc func(c *config)

OptionFunc provides a convenience wrapper for simple Options that can be represented as functions.

func (OptionFunc) Apply

func (o OptionFunc) Apply(c *config)

Apply will apply the option to the config.

type Options

type Options = redis.Options

Options keeps the settings to setup redis connection.

type SpanNameFormatter

type SpanNameFormatter func(operation string, cmd Cmder) string

SpanNameFormatter creates a custom span name from the operation and cmder interface.

type SpanNameFormatterPipeline

type SpanNameFormatterPipeline func(operation string, cmds []Cmder) string

SpanNameFormatterPipeline creates a custom span name from the operation and cmder interface.

Jump to

Keyboard shortcuts

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