metrics

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package metrics provides gRPC interceptors for metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler() http.Handler

Handler returns an http.Handler for the /metrics endpoint.

func IncrCounter

func IncrCounter(name []string, val float32)

IncrCounter increments a counter.

func Initialize

func Initialize() error

Initialize prepares the metrics system with a Prometheus sink. It sets up a global metrics collector that can be used throughout the application. The metrics are exposed on the /metrics endpoint.

func MeasureSince

func MeasureSince(name []string, start time.Time)

MeasureSince measures the time since a given start time and records it.

func NewPrometheusSink

func NewPrometheusSink() (*prometheus.PrometheusSink, error)

NewPrometheusSink creates a new Prometheus sink.

func SetGauge

func SetGauge(name string, val float32, labels ...string)

SetGauge sets the value of a gauge.

func StartServer

func StartServer(addr string) error

StartServer starts an HTTP server to expose the metrics.

Types

type GrpcStatsHandler

type GrpcStatsHandler struct{}

GrpcStatsHandler is a gRPC stats handler that records metrics.

func (*GrpcStatsHandler) HandleConn

func (h *GrpcStatsHandler) HandleConn(_ context.Context, s stats.ConnStats)

HandleConn processes connection stats.

func (*GrpcStatsHandler) HandleRPC

func (h *GrpcStatsHandler) HandleRPC(_ context.Context, s stats.RPCStats)

HandleRPC processes RPC stats.

func (*GrpcStatsHandler) TagConn

TagConn can be used to tag connections with custom information.

func (*GrpcStatsHandler) TagRPC

TagRPC can be used to tag RPCs with custom information.

Jump to

Keyboard shortcuts

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