redis

package module
v0.0.0-...-c84afdd Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 7 Imported by: 0

README

go-redis-v3

Instruments gopkg.in/redis.v3 interactions with Open Census

Documentation

Overview

Package redis instruments redis interactions with Open Census

Index

Constants

This section is empty.

Variables

View Source
var (
	// GoRedisName is the name of the redis instance.
	GoRedisInstanceName, _ = tag.NewKey("go_redis_instance_name")

	// GoRedisMethod is the client method called.
	GoRedisMethod, _ = tag.NewKey("go_redis_method")

	// GoRedisStatus identifies the command status
	GoRedisStatus, _ = tag.NewKey("go_redis_status")

	DefaultTags = []tag.Key{
		GoRedisMethod,
		GoRedisStatus,
	}
)

The following tags are aooplied to stats recorded by this package

View Source
var (
	MeasureLatencyMs     = stats.Int64("go.redis/latency", "The latency of calls in milliseconds", stats.UnitMilliseconds)
	MeasureResponseBytes = stats.Int64("go.redis/received_bytes", "The number of bytes returned from a command", stats.UnitBytes)
)

The following measures are supported for use in custom views.

View Source
var (
	DefaultSizeDistribution = view.Distribution(
		1024,
		2048,
		4096,
		16384,
		65536,
		262144,
		1048576,
		4194304,
		16777216,
		67108864,
		268435456,
		1073741824,
		4294967296,
	)
	DefaultMillisecondsDistribution = view.Distribution(
		0.0,
		0.001,
		0.005,
		0.01,
		0.05,
		0.1,
		0.5,
		1.0,
		1.5,
		2.0,
		2.5,
		5.0,
		10.0,
		25.0,
		50.0,
		100.0,
		200.0,
		400.0,
		600.0,
		800.0,
		1000.0,
		1500.0,
		2000.0,
		2500.0,
		5000.0,
		10000.0,
		20000.0,
		40000.0,
		100000.0,
		200000.0,
		500000.0,
	)
)

Default distributions used by views in this package

View Source
var (
	GoRedisLatencyView = &view.View{
		Name:        "go.redis/client/latency",
		Description: "The distribution of latency of various calls in milliseconds",
		Measure:     MeasureLatencyMs,
		Aggregation: DefaultMillisecondsDistribution,
		TagKeys:     DefaultTags,
	}

	GoRedisCallsView = &view.View{
		Name:        "go.redis/client/calls",
		Description: "The number of various calls of methods",
		Measure:     MeasureLatencyMs,
		Aggregation: view.Count(),
		TagKeys:     DefaultTags,
	}

	GoRedisBytesView = &view.View{
		Name:        "go.redis/client/received_bytes",
		Description: "Total bytes received from Redis",
		Measure:     MeasureResponseBytes,
		Aggregation: DefaultSizeDistribution,
		TagKeys:     DefaultTags,
	}

	DefaultViews = []*view.View{GoRedisLatencyView, GoRedisCallsView, GoRedisBytesView}
)

Package cache provides some convenience views. You still need to register these views for data to actually be collected. You can use the RegisterAllViews function for this.

Functions

func RegisterAllViews

func RegisterAllViews() error

RegisterAllViews registers all the cache views to enable collection of stats

Types

type BoolCmd

type BoolCmd interface {
	Err() error
	Result() (bool, error)
	String() string
	Val() bool
}

type Client

type Client interface {
	Get(ctx context.Context, key string) StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) StatusCmd
}

type Cmd

type Cmd interface {
	Err() error
	fmt.Stringer
}

type HashClient

type HashClient interface {
	HGet(ctx context.Context, key, field string) StringCmd
	HSet(ctx context.Context, key, field, value string) BoolCmd
	HKeys(ctx context.Context, key string) StringSliceCmd
}

type IntCmd

type IntCmd interface {
	Val() int64
	String() string
	Err() error
	Result() (int64, error)
}

type StatusCmd

type StatusCmd interface {
	Err() error
	Result() (string, error)
	String() string
	Val() string
}

type StringCmd

type StringCmd interface {
	Bytes() ([]byte, error)
	Err() error
	Float64() (float64, error)
	Int64() (int64, error)
	Result() (string, error)
	Scan(val interface{}) error
	String() string
	Uint64() (uint64, error)
	Val() string
}

type StringSliceCmd

type StringSliceCmd interface {
	Err() error
	Result() ([]string, error)
	String() string
	Val() []string
}

type Wrapper

type Wrapper struct {
	// contains filtered or unexported fields
}

func Wrap

func Wrap(client *pkgredis.Client, instanceName string) *Wrapper

func (*Wrapper) Decr

func (w *Wrapper) Decr(ctx context.Context, key string) (cmd IntCmd)

func (*Wrapper) Get

func (w *Wrapper) Get(ctx context.Context, key string) (cmd StringCmd)

func (*Wrapper) HGet

func (w *Wrapper) HGet(ctx context.Context, key, field string) (cmd StringCmd)

func (*Wrapper) HKeys

func (w *Wrapper) HKeys(ctx context.Context, key string) (cmd StringSliceCmd)

func (*Wrapper) HSet

func (w *Wrapper) HSet(ctx context.Context, key, field, value string) (cmd BoolCmd)

func (*Wrapper) Incr

func (w *Wrapper) Incr(ctx context.Context, key string) (cmd IntCmd)

func (*Wrapper) Ping

func (w *Wrapper) Ping(ctx context.Context) (cmd StatusCmd)

func (*Wrapper) Set

func (w *Wrapper) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (cmd StatusCmd)

Jump to

Keyboard shortcuts

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