metrics

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(logger clog.CLog, registry Registry, healthCheck *HealthChecker) *server

Types

type HealthChecker

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

func NewHealthChecker

func NewHealthChecker(logger clog.CLog) *HealthChecker

func (*HealthChecker) LivenessHandler

func (hc *HealthChecker) LivenessHandler(w http.ResponseWriter, r *http.Request)

func (*HealthChecker) ReadinessHandler

func (hc *HealthChecker) ReadinessHandler(w http.ResponseWriter, r *http.Request)

func (*HealthChecker) SetHealthy

func (hc *HealthChecker) SetHealthy(healthy bool)

func (*HealthChecker) SetReady

func (hc *HealthChecker) SetReady(ready bool)

type Registry

type Registry interface {
	Inc(string, prometheus.Labels)
	RecordDuration(string, prometheus.Labels, float64)
	PrometheusRegistry() *prometheus.Registry
}

Registry defines the interface for managing metrics.

func NewRegistry

func NewRegistry(subsystem, namespace string) Registry

NewRegistry creates a new metrics registry with the specified subsystem and namespace.

func NewRegistryStub

func NewRegistryStub() Registry

NewRegistryStub creates a new instance of a no-op registry.

type Series

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

func FromContext

func FromContext(ctx context.Context) Series

FromContext retrieves the Series from the context.

func NewSeries

func NewSeries(st SeriesType, subType string) Series

NewSeries creates a new Series instance with the given type and subType.

func (Series) Duration

func (s Series) Duration(d time.Duration, msg string) (string, prometheus.Labels, float64)

Duration returns the metric name and labels for recording a duration, where msg carries any additional information

func (Series) Error

func (s Series) Error(message string) (string, prometheus.Labels)

Error returns the metric name and labels for an error event.

func (Series) Info

func (s Series) Info(message string) (string, prometheus.Labels)

Info returns the metric name and labels for an informational event.

func (Series) Success

func (s Series) Success() (string, prometheus.Labels)

Success returns the metric name and labels for a success event.

func (Series) ToContext

func (s Series) ToContext(ctx context.Context) context.Context

ToContext adds the Series to the context.

func (Series) WithLabels added in v0.0.35

func (s Series) WithLabels(labels prometheus.Labels) Series

WithLabels adds custom labels to the Series.

func (Series) WithOperation

func (s Series) WithOperation(ctx context.Context, operation string) (context.Context, Series)

WithOperation sets the operation name in the Series and returns an updated context.

type SeriesType

type SeriesType string
const (
	SeriesTypeRPCHandler      SeriesType = "rpc_handler"
	SeriesTypeApiHandler      SeriesType = "api_handler"
	SeriesTypeUseCase         SeriesType = "use_case"
	SeriesTypeClient          SeriesType = "client"
	SeriesTypeDB              SeriesType = "postgres"
	SeriesTypeDatabusConsumer SeriesType = "databus_consumer"
)

func (SeriesType) String

func (st SeriesType) String() string

type Server

type Server interface {
	Start(ctx context.Context, address string)
	Stop(ctx context.Context)
}

Jump to

Keyboard shortcuts

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