metrics

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RedisBackend  *redis.Client
	ShutdownCtx   context.Context
	PrometheusURL string
}

type IMetrics

type IMetrics interface {
	FetchCounters(ctx context.Context) ([]*protos.Metric, error)

	GetAllRateCounters(_ context.Context) map[string]*RateCounter

	HandleMetricsRequest(ctx context.Context, req *protos.MetricsRequest) error

	IncreaseRate(ctx context.Context, t RateCounterType, aud *protos.Audience, value int64)
}

type Metrics

type Metrics struct {
	*Config
	VecCounters    map[string]*prometheus.CounterVec
	VecCountersMtx *sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) (*Metrics, error)

func (*Metrics) FetchCounters

func (m *Metrics) FetchCounters(ctx context.Context) ([]*protos.Metric, error)

func (*Metrics) GetAllRateCounters

func (m *Metrics) GetAllRateCounters(_ context.Context) map[string]*RateCounter

func (*Metrics) GetRateCounter

func (m *Metrics) GetRateCounter(_ context.Context, aud *protos.Audience) *RateCounter

func (*Metrics) HandleMetricsRequest

func (m *Metrics) HandleMetricsRequest(ctx context.Context, req *protos.MetricsRequest) error

func (*Metrics) IncreaseRate

func (m *Metrics) IncreaseRate(ctx context.Context, t RateCounterType, aud *protos.Audience, value int64)

type RateCounter

type RateCounter struct {
	Bytes     *ratecounter.RateCounter `json:"bytes"`
	Processed *ratecounter.RateCounter `json:"processed"`
}

type RateCounterType

type RateCounterType string
const (
	RateBytes     RateCounterType = "bytes"
	RateProcessed RateCounterType = "processed"
)

Jump to

Keyboard shortcuts

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