metrics

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrDuplicatedName utils.Error = "duplicated metrics name"
)

Variables

This section is empty.

Functions

func AppName

func AppName(name string) utils.OptionFunc[useOption]

func Construct

func Construct(ctx context.Context, confs map[string]*Conf, opts ...utils.OptionExtender) func()

func HttpHandler

func HttpHandler(path, name string, opts ...utils.OptionExtender) http.Handler

func Labels

func Labels(labels []Label) utils.OptionFunc[option]

func NewDI

func NewDI(name, job string, opts ...utils.OptionExtender) func() Sink

func Precision

func Precision() utils.OptionFunc[option]

func PrometheusBuckets

func PrometheusBuckets(buckets []float64) utils.OptionFunc[option]

func Timeout

func Timeout(timeout time.Duration) utils.OptionFunc[option]

func WithoutTimeout

func WithoutTimeout() utils.OptionFunc[option]

Types

type Conf

type Conf struct {
	Type                  metricsType       `yaml:"type" json:"type" toml:"type"`
	Mode                  mode              `yaml:"mode" json:"mode" toml:"mode"`
	Interval              string            `yaml:"interval" json:"interval" toml:"interval"`
	Endpoint              *endpointConf     `yaml:"endpoint" json:"endpoint" toml:"endpoint"`
	Labels                map[string]string `yaml:"labels" json:"labels" toml:"labels"`
	EnableServiceLabel    bool              `yaml:"enable_service_label" json:"enable_service_label" toml:"enable_service_label"`
	EnableInternalMetrics bool              `yaml:"enable_internal_metrics" json:"enable_internal_metrics" toml:"enable_internal_metrics"`
	QueueLimit            int               `yaml:"queue_limit" json:"queue_limit" toml:"queue_limit" default:"16384"`
	QueueConcurrency      int               `yaml:"queue_concurrency" json:"queue_concurrency" toml:"queue_concurrency"`
	Logger                string            `yaml:"logger" json:"logger" toml:"logger" default:"github.com/wfusion/gofusion/log/customlogger.metricsLogger"`
	LogInstance           string            `yaml:"log_instance" json:"log_instance" toml:"log_instance" default:"default"`
	EnableLogger          bool              `yaml:"enable_logger" json:"enable_logger" toml:"enable_logger" default:"false"`
}

Conf metrics conf nolint: revive // struct tag too long issue

type Label

type Label struct {
	Key, Value string
}

type Sink

type Sink interface {
	// SetGauge A Gauge should retain the last value it is set to
	SetGauge(ctx context.Context, key []string, val float64, opts ...utils.OptionExtender)

	// IncrCounter Counters should accumulate values
	IncrCounter(ctx context.Context, key []string, val float64, opts ...utils.OptionExtender)

	// AddSample Samples are for timing information, where quantiles are used
	AddSample(ctx context.Context, key []string, val float64, opts ...utils.OptionExtender)

	// MeasureSince A better way to add timer samples
	MeasureSince(ctx context.Context, key []string, start time.Time, opts ...utils.OptionExtender)

	// IsEnableServiceLabel check if enable service label
	IsEnableServiceLabel() bool
	// contains filtered or unexported methods
}

The Sink interface is used to transmit metrics information to an external system

func Internal

func Internal(opts ...utils.OptionExtender) (sinks []Sink)

func Use

func Use(name, job string, opts ...utils.OptionExtender) Sink

Jump to

Keyboard shortcuts

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