metrics

package
v0.0.0-...-29e355a Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitCounter

func EmitCounter(name string, value float32, labels ...Label)

func EmitKey

func EmitKey(name string, value float32, labels ...Label)

func EmitTimer

func EmitTimer(name string, value time.Duration, labels ...Label)

func RecordAPIRequest

func RecordAPIRequest(req APIRequest)

func RecordDBOperation

func RecordDBOperation(op DBOperation)

func RecordLogicOperation

func RecordLogicOperation(op LogicOperation)

Types

type APIRequest

type APIRequest struct {
	Method           string
	Path             string
	StatusCode       int
	Success          bool
	Duration         time.Duration
	BusinessCategory string
}

func (APIRequest) ToLabels

func (r APIRequest) ToLabels() []Label

type DBOperation

type DBOperation struct {
	Database         string
	Table            string
	OperationType    string
	BusinessCategory string
	Success          bool
	Duration         time.Duration
}

func (DBOperation) ToLabels

func (op DBOperation) ToLabels() []Label

type Label

type Label struct {
	Name  string
	Value string
}

func MapToLabel

func MapToLabel(m map[string]string) []Label

func StructFieldToLabel

func StructFieldToLabel(s interface{}) []Label

type LogicOperation

type LogicOperation struct {
	PrimaryCategory   string
	SecondaryCategory string
	TertiaryCategory  string
	Success           bool
	Duration          time.Duration
}

func (LogicOperation) ToLabels

func (op LogicOperation) ToLabels() []Label

type MetricsBackendType

type MetricsBackendType string
const (
	PrometheusBackendType MetricsBackendType = "prometheus"
	InmemBackendType      MetricsBackendType = "inmem"
)

type MetricsHub

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

func NewMetricsHub

func NewMetricsHub(ctx context.Context, args *MetricsHubConfig) (*MetricsHub, error)

func (*MetricsHub) Init

func (self *MetricsHub) Init() error

init it

func (*MetricsHub) Release

func (self *MetricsHub) Release()

release it

type MetricsHubConfig

type MetricsHubConfig struct {
	ServiceName string
	BackendType MetricsBackendType

	ExpirationSec int64
}

Jump to

Keyboard shortcuts

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