Documentation
¶
Index ¶
- Constants
- Variables
- func MakeMetricsURL(address string, tlsConf *connection.TLSConfig) (string, error)
- func RegisterMonitoringServer(mux *http.ServeMux, p *Provider)
- type ConnectionMetrics
- type MetricsParameters
- type Provider
- func (p *Provider) NewAtomicChannelLenGauge[T any](opts prometheus.GaugeOpts, ch *atomic.Pointer[chan T]) prometheus.GaugeFunc
- func (p *Provider) NewChannelLenGauge[T any](opts prometheus.GaugeOpts, ch <-chan T) prometheus.GaugeFunc
- func (p *Provider) NewCounter(opts prometheus.CounterOpts) prometheus.Counter
- func (p *Provider) NewCounterFunc(opts prometheus.CounterOpts, function func() float64) prometheus.CounterFunc
- func (p *Provider) NewCounterVec(opts prometheus.CounterOpts, labels []string) *prometheus.CounterVec
- func (p *Provider) NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge
- func (p *Provider) NewGaugeFunc(opts prometheus.GaugeOpts, fn func() float64) prometheus.GaugeFunc
- func (p *Provider) NewGaugeVec(opts prometheus.GaugeOpts, labels []string) *prometheus.GaugeVec
- func (p *Provider) NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram
- func (p *Provider) NewHistogramVec(opts prometheus.HistogramOpts, labels []string) *prometheus.HistogramVec
- func (p *Provider) Registry() *prometheus.Registry
- type ThroughputMetrics
Constants ¶
const (
// MetricsSubPath is the path for prometheus metrics endpoint.
MetricsSubPath = "/metrics"
)
Variables ¶
var LatencyBuckets = []float64{.0001, .001, .002, .003, .004, .005, .01, .03, .05, .1, .3, .5, 1, 2, 3, 4, 5, 10}
LatencyBuckets are the shared histogram bucket boundaries (seconds) for the gRPC request-latency metric, so those histograms are comparable across services. It reaches 10s to cover slow RPCs; components timing shorter internal work (e.g. VC and dependency-graph batches) keep their own narrower buckets.
var StreamDurationBuckets = []float64{.1, .5, 1, 5, 15, 30, 60, 120, 300, 600, 1800, 3600, 10800, 21600}
StreamDurationBuckets are the histogram bucket boundaries (seconds) for the gRPC stream-duration metric. Streams (notification subscriptions, verification streams, health watches) stay open from well under a second to hours, so the buckets span that range rather than reusing LatencyBuckets, whose 10s ceiling would collapse every long-lived stream into the +Inf bucket. The range is 0.1s to 6h.
Functions ¶
func MakeMetricsURL ¶
func MakeMetricsURL(address string, tlsConf *connection.TLSConfig) (string, error)
MakeMetricsURL construct the Prometheus metrics URL. based on the secure level, we set the url scheme to http or https.
func RegisterMonitoringServer ¶ added in v1.0.0
RegisterMonitoringServer registers the monitoring endpoints with the provided HTTP mux. It sets up Prometheus metrics endpoint and pprof profiling handlers. It uses the similar signature as GRPC server registration to allow common language for all server<->service interfaces.
Types ¶
type ConnectionMetrics ¶
type ConnectionMetrics struct {
Status *prometheus.GaugeVec
FailureTotal *prometheus.CounterVec
// contains filtered or unexported fields
}
ConnectionMetrics supports common connection metrics.
func NewConnectionMetrics ¶ added in v1.0.0
func NewConnectionMetrics(p *Provider, params MetricsParameters) *ConnectionMetrics
NewConnectionMetrics supports common connection metrics.
func (*ConnectionMetrics) Connected ¶
func (m *ConnectionMetrics) Connected(grpcTarget string)
Connected observed connected.
func (*ConnectionMetrics) Disconnected ¶
func (m *ConnectionMetrics) Disconnected(grpcTarget string)
Disconnected observe disconnected. The failure count is increased only if the status was connected.
type MetricsParameters ¶ added in v1.0.0
MetricsParameters describes metrics namespace and subsystem.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is a prometheus metrics provider.
func NewProvider ¶
func NewProvider() *Provider
NewProvider creates a new prometheus metrics provider.
func (*Provider) NewAtomicChannelLenGauge ¶ added in v1.0.5
func (p *Provider) NewAtomicChannelLenGauge[T any]( opts prometheus.GaugeOpts, ch *atomic.Pointer[chan T], ) prometheus.GaugeFunc
NewAtomicChannelLenGauge creates a new prometheus gauge that reports the number of items buffered in the channel ch currently points to. Use it for a queue that is replaced during the service's lifetime, such as one recreated per session: the value follows whichever channel is installed, and an unset pointer reports zero rather than the previous channel's last value.
func (*Provider) NewChannelLenGauge ¶ added in v1.0.5
func (p *Provider) NewChannelLenGauge[T any]( opts prometheus.GaugeOpts, ch <-chan T, ) prometheus.GaugeFunc
NewChannelLenGauge creates a new prometheus gauge that reports the number of items buffered in ch on every scrape. Prefer it over a NewGauge that a dedicated goroutine samples on a timer. A nil channel reports zero.
func (*Provider) NewCounter ¶
func (p *Provider) NewCounter(opts prometheus.CounterOpts) prometheus.Counter
NewCounter creates a new prometheus counter.
func (*Provider) NewCounterFunc ¶ added in v1.0.5
func (p *Provider) NewCounterFunc(opts prometheus.CounterOpts, function func() float64) prometheus.CounterFunc
NewCounterFunc registers a counter whose value is computed at scrape time by function. Use it for a cumulative total derived from other state rather than incremented via Add.
func (*Provider) NewCounterVec ¶
func (p *Provider) NewCounterVec(opts prometheus.CounterOpts, labels []string) *prometheus.CounterVec
NewCounterVec creates a new prometheus counter vector.
func (*Provider) NewGauge ¶
func (p *Provider) NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge
NewGauge creates a new prometheus gauge.
func (*Provider) NewGaugeFunc ¶ added in v1.0.5
func (p *Provider) NewGaugeFunc(opts prometheus.GaugeOpts, fn func() float64) prometheus.GaugeFunc
NewGaugeFunc creates a new prometheus gauge whose value is reported by calling fn on every scrape. Use it instead of a NewGauge that a dedicated goroutine samples on a timer: the value is exact rather than as fresh as the sampling interval, and no goroutine is needed. fn is called by the scrape handler, so it must be cheap and safe for concurrent use.
func (*Provider) NewGaugeVec ¶
func (p *Provider) NewGaugeVec(opts prometheus.GaugeOpts, labels []string) *prometheus.GaugeVec
NewGaugeVec creates a new prometheus gauge vector.
func (*Provider) NewHistogram ¶
func (p *Provider) NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram
NewHistogram creates a new prometheus histogram.
func (*Provider) NewHistogramVec ¶
func (p *Provider) NewHistogramVec(opts prometheus.HistogramOpts, labels []string) *prometheus.HistogramVec
NewHistogramVec creates a new prometheus histogram vector.
func (*Provider) Registry ¶
func (p *Provider) Registry() *prometheus.Registry
Registry returns the prometheus registry.
type ThroughputMetrics ¶ added in v1.0.0
type ThroughputMetrics struct {
Input prometheus.Counter
Output prometheus.Counter
}
ThroughputMetrics supports common throughput metrics.
func NewThroughputMetrics ¶ added in v1.0.0
func NewThroughputMetrics(p *Provider, params MetricsParameters) *ThroughputMetrics
NewThroughputMetrics creates a new prometheus throughput counter.