Documentation
¶
Overview ¶
Package metrics provides gRPC interceptors for metrics.
Index ¶
- func Handler() http.Handler
- func IncrCounter(name []string, val float32)
- func Initialize() error
- func MeasureSince(name []string, start time.Time)
- func NewPrometheusSink() (*prometheus.PrometheusSink, error)
- func SetGauge(name string, val float32, labels ...string)
- func StartServer(addr string) error
- type GrpcStatsHandler
- func (h *GrpcStatsHandler) HandleConn(_ context.Context, s stats.ConnStats)
- func (h *GrpcStatsHandler) HandleRPC(_ context.Context, s stats.RPCStats)
- func (h *GrpcStatsHandler) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context
- func (h *GrpcStatsHandler) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 StartServer ¶
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 ¶
func (h *GrpcStatsHandler) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context
TagConn can be used to tag connections with custom information.
func (*GrpcStatsHandler) TagRPC ¶
func (h *GrpcStatsHandler) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
TagRPC can be used to tag RPCs with custom information.