Documentation
¶
Index ¶
- Constants
- func ToGRPCPromCounterOption(opts *Options) grpcProm.CounterOption
- func ToGRPCPromHistogramOption(opts *Options) grpcProm.HistogramOption
- type Counter
- type DummyRegistry
- func (d *DummyRegistry) NewCounter(key string, opts ...Option) Counter
- func (d *DummyRegistry) NewGauge(key string, opts ...Option) Gauge
- func (d *DummyRegistry) NewHistogram(key string, opts ...Option) Histogram
- func (d *DummyRegistry) NewServerMetrics(opts ...Option) ServerMetrics
- func (d *DummyRegistry) NewTimer(key string, opts ...Option) Timer
- func (d *DummyRegistry) NewWorker(key string, opts ...Option) Worker
- func (d *DummyRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Gauge
- type Histogram
- type Option
- type Options
- type PrometheusRegistry
- func (p *PrometheusRegistry) AppendLabels(labels map[string]string)
- func (p *PrometheusRegistry) NewCounter(key string, opts ...Option) Counter
- func (p *PrometheusRegistry) NewGauge(key string, opts ...Option) Gauge
- func (p *PrometheusRegistry) NewHistogram(key string, opts ...Option) Histogram
- func (p *PrometheusRegistry) NewServerMetrics(opts ...Option) ServerMetrics
- func (p *PrometheusRegistry) NewTimer(key string, opts ...Option) Timer
- func (p *PrometheusRegistry) NewWorker(key string, opts ...Option) Worker
- func (p *PrometheusRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (p *PrometheusRegistry) SetNamespace(namespace string)
- type Registry
- type ServerMetrics
- type Timer
- type Worker
Constants ¶
const MetricsEnabledFlag = "metrics"
Variables ¶
This section is empty.
Functions ¶
func ToGRPCPromCounterOption ¶
func ToGRPCPromCounterOption(opts *Options) grpcProm.CounterOption
To support grpc prometheus options
func ToGRPCPromHistogramOption ¶
func ToGRPCPromHistogramOption(opts *Options) grpcProm.HistogramOption
Types ¶
type Counter ¶
type Counter interface {
Inc()
Add(float64)
}
Counter is a Metric that represents a single numerical value that only ever goes up. A Counter is typically used to count requests served, tasks completed, errors occurred, etc.
func NewCounter ¶
type DummyRegistry ¶
type DummyRegistry struct {
}
func NewDummyRegistry ¶
func NewDummyRegistry() *DummyRegistry
func (*DummyRegistry) NewCounter ¶
func (d *DummyRegistry) NewCounter(key string, opts ...Option) Counter
func (*DummyRegistry) NewHistogram ¶
func (d *DummyRegistry) NewHistogram(key string, opts ...Option) Histogram
func (*DummyRegistry) NewServerMetrics ¶
func (d *DummyRegistry) NewServerMetrics(opts ...Option) ServerMetrics
func (*DummyRegistry) NewWorker ¶
func (d *DummyRegistry) NewWorker(key string, opts ...Option) Worker
func (*DummyRegistry) ServeHTTP ¶
func (d *DummyRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Gauge ¶
type Gauge interface {
Set(float64)
}
Gauge is a Metric that represents a single numerical value that can arbitrarily go up and down. A Gauge is typically used for measured values like temperatures or current memory usage.
type Histogram ¶
type Histogram interface {
Observe(float64)
}
A Histogram counts individual observations from an event or sample stream in configurable buckets. Similar to a summary, it also provides a sum of observations and an observation count.
func NewHistogram ¶
type PrometheusRegistry ¶
type PrometheusRegistry struct {
// contains filtered or unexported fields
}
func NewPrometheusRegistry ¶
func NewPrometheusRegistry() *PrometheusRegistry
func (*PrometheusRegistry) AppendLabels ¶
func (p *PrometheusRegistry) AppendLabels(labels map[string]string)
func (*PrometheusRegistry) NewCounter ¶
func (p *PrometheusRegistry) NewCounter(key string, opts ...Option) Counter
func (*PrometheusRegistry) NewGauge ¶
func (p *PrometheusRegistry) NewGauge(key string, opts ...Option) Gauge
func (*PrometheusRegistry) NewHistogram ¶
func (p *PrometheusRegistry) NewHistogram(key string, opts ...Option) Histogram
func (*PrometheusRegistry) NewServerMetrics ¶
func (p *PrometheusRegistry) NewServerMetrics(opts ...Option) ServerMetrics
func (*PrometheusRegistry) NewTimer ¶
func (p *PrometheusRegistry) NewTimer(key string, opts ...Option) Timer
func (*PrometheusRegistry) NewWorker ¶
func (p *PrometheusRegistry) NewWorker(key string, opts ...Option) Worker
func (*PrometheusRegistry) ServeHTTP ¶
func (p *PrometheusRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*PrometheusRegistry) SetNamespace ¶
func (p *PrometheusRegistry) SetNamespace(namespace string)
type Registry ¶
type Registry interface {
NewServerMetrics(opts ...Option) ServerMetrics
NewCounter(key string, opts ...Option) Counter
NewGauge(key string, opts ...Option) Gauge
NewHistogram(key string, opts ...Option) Histogram
NewTimer(key string, opts ...Option) Timer
NewWorker(key string, opts ...Option) Worker
// ServeHTTP is used to display all metric values through http request
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
Registry is a metrics gather
var DefaultRegistry Registry = NewDummyRegistry()
type ServerMetrics ¶
type ServerMetrics interface {
InitializeMetrics(*grpc.Server)
StreamServerInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
UnaryServerInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
}
ServerMetrics is an integrated metric collector to measure count of any kind of error and elapsed time of each grpc method.
func NewServerMetrics ¶
func NewServerMetrics(opts ...Option) ServerMetrics
type Timer ¶
Timer represents a Histogram Metrics to observe the time duration according to given begin time. Timer is usually used to time a function call in the following way:
func TimeMe() {
begin := time.Now()
defer Timer.Observe(begin)
}
type Worker ¶
Worker includes Timer Metrics to observe the time duration according to given begin time, and counter Metreic to gather the success count and fail count. Worker is usually used to measure a function call in the following way:
func MeasureMe()(err error) {
begin := time.Now()
defer Worker.Observe(begin, err)
}