Documentation
¶
Overview ¶
Package metrics provides a small OpenMetrics registry for go-iroh metrics.
The Go API is not stable before v1 and may change in any v0 release.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Family ¶
type Family struct {
// contains filtered or unexported fields
}
Family is a metric vector keyed by a fixed label set.
func NewFamily ¶
func NewFamily(name string, typ MetricType, labelNames ...string) *Family
NewFamily returns a metric family with labelNames in output order.
Example ¶
f := NewFamily("connections", CounterMetric, "family")
quic, _ := f.With("quic")
quic.Add(2)
r := NewRegistry()
_ = r.Register("endpoint", f)
_ = r.WriteOpenMetrics(io.Discard)
func (*Family) StructuredSnapshot ¶
func (f *Family) StructuredSnapshot() StructuredSnapshot
StructuredSnapshot returns all children in f.
type FamilyMetric ¶
type FamilyMetric struct {
// contains filtered or unexported fields
}
FamilyMetric is one labeled metric in a Family.
func (*FamilyMetric) Add ¶
func (m *FamilyMetric) Add(delta uint64)
Add adds delta to m. Use it for counter families.
func (*FamilyMetric) Set ¶
func (m *FamilyMetric) Set(value float64)
Set sets m to value. Use it for gauge families.
type HistogramBucket ¶
type HistogramBucket struct {
// Le is the inclusive upper bound. Use math.Inf(1) for +Inf.
Le float64
// Count is the cumulative count for this bucket.
Count uint64
}
HistogramBucket is one cumulative histogram bucket.
type MetricType ¶
type MetricType string
MetricType is the OpenMetrics type of a metric value.
const ( // CounterMetric is a monotonically increasing counter. CounterMetric MetricType = "counter" // GaugeMetric is a point-in-time value that may increase or decrease. GaugeMetric MetricType = "gauge" // HistogramMetric is a cumulative histogram. HistogramMetric MetricType = "histogram" )
type MetricValue ¶
type MetricValue struct {
Name string
Type MetricType
Labels []Label
Counter uint64
Gauge float64
Sum float64
Count uint64
Buckets []HistogramBucket
}
MetricValue is one metric sample in a StructuredSnapshot.
func Histogram ¶
func Histogram(sum float64, count uint64, buckets []HistogramBucket) MetricValue
Histogram returns a histogram metric value. Buckets are copied and sorted by upper bound before OpenMetrics output.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry collects named metric sources.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a small HTTP server for OpenMetrics scraping.
func (*Server) ListenAndServe ¶
ListenAndServe serves metrics until the server is shut down.
type Source ¶
type Source interface {
Snapshot() Snapshot
}
Source returns a point-in-time metrics snapshot.
type StructuredSnapshot ¶
type StructuredSnapshot map[string]MetricValue
StructuredSnapshot is a point-in-time set of typed metric values.
type StructuredSource ¶
type StructuredSource interface {
StructuredSnapshot() StructuredSnapshot
}
StructuredSource returns a point-in-time typed metrics snapshot.