goredis

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

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

Hook represents a go-redis hook that exports metrics of commands and pipelines.

The following metrics are exported:

- Single commands (not-pipelined)

  • Histogram of duration
  • Counter of errors

- Pipelined commands

  • Counter of commands
  • Counter of errors

The duration of individual pipelined commands won't be collected, but the overall duration of the pipeline will, with a pseudo-command called "pipeline".

func NewHook

func NewHook(instanceName string, opts ...Option) *Hook

NewHook creates a new go-redis hook instance and registers Prometheus collectors.

func (*Hook) AfterProcess

func (hook *Hook) AfterProcess(ctx context.Context, cmd redis.Cmder) error

func (*Hook) AfterProcessPipeline

func (hook *Hook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error

func (*Hook) BeforeProcess

func (hook *Hook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error)

func (*Hook) BeforeProcessPipeline

func (hook *Hook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error)

type Option

type Option func(*Options)

func WithDurationBuckets

func WithDurationBuckets(buckets []float64) Option

WithDurationBuckets sets the duration buckets of single commands metrics.

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace sets the namespace of all metrics.

func WithStatInterval

func WithStatInterval(interval time.Duration) Option

WithStatInterval sets the duration buckets of single commands metrics.

func WithSubsystem

func WithSubsystem(subsystem string) Option

WithSubsystem sets the namespace of all metrics.

type Options

type Options struct {
	Namespace       string
	Subsystem       string
	DurationBuckets []float64
	StatInterval    time.Duration
}

Options represents options to customize the exported metrics.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns the default options.

func (*Options) Merge

func (options *Options) Merge(opts ...Option)

type Stats

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

func NewStat

func NewStat(instanceName string, opts ...Option) *Stats

func (*Stats) StartStat

func (s *Stats) StartStat(redisClient *redis.Client)

Jump to

Keyboard shortcuts

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