meter: add Clone method
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
37d937d7ae
commit
3f5b19497c
@ -28,17 +28,31 @@ var (
|
|||||||
|
|
||||||
// Meter is an interface for collecting and instrumenting metrics
|
// Meter is an interface for collecting and instrumenting metrics
|
||||||
type Meter interface {
|
type Meter interface {
|
||||||
|
// Name returns meter name
|
||||||
Name() string
|
Name() string
|
||||||
|
// Init initialize meter
|
||||||
Init(opts ...Option) error
|
Init(opts ...Option) error
|
||||||
|
// Clone create meter copy with new options
|
||||||
|
Clone(opts ...Option) Meter
|
||||||
|
// Counter get or create counter
|
||||||
Counter(name string, labels ...string) Counter
|
Counter(name string, labels ...string) Counter
|
||||||
|
// FloatCounter get or create float counter
|
||||||
FloatCounter(name string, labels ...string) FloatCounter
|
FloatCounter(name string, labels ...string) FloatCounter
|
||||||
|
// Gauge get or create gauge
|
||||||
Gauge(name string, fn func() float64, labels ...string) Gauge
|
Gauge(name string, fn func() float64, labels ...string) Gauge
|
||||||
|
// Set create new meter metrics set
|
||||||
Set(opts ...Option) Meter
|
Set(opts ...Option) Meter
|
||||||
|
// Histogram get or create histogram
|
||||||
Histogram(name string, labels ...string) Histogram
|
Histogram(name string, labels ...string) Histogram
|
||||||
|
// Summary get or create summary
|
||||||
Summary(name string, labels ...string) Summary
|
Summary(name string, labels ...string) Summary
|
||||||
|
// SummaryExt get or create summary with spcified quantiles and window time
|
||||||
SummaryExt(name string, window time.Duration, quantiles []float64, labels ...string) Summary
|
SummaryExt(name string, window time.Duration, quantiles []float64, labels ...string) Summary
|
||||||
|
// Write writes metrics to io.Writer
|
||||||
Write(w io.Writer, opts ...Option) error
|
Write(w io.Writer, opts ...Option) error
|
||||||
|
// Options returns meter options
|
||||||
Options() Options
|
Options() Options
|
||||||
|
// String return meter type
|
||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,15 @@ func NewMeter(opts ...Option) Meter {
|
|||||||
return &noopMeter{opts: NewOptions(opts...)}
|
return &noopMeter{opts: NewOptions(opts...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clone return old meter with new options
|
||||||
|
func (r *noopMeter) Clone(opts ...Option) Meter {
|
||||||
|
options := r.opts
|
||||||
|
for _, o := range opts {
|
||||||
|
o(&options)
|
||||||
|
}
|
||||||
|
return &noopMeter{opts: options}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *noopMeter) Name() string {
|
func (r *noopMeter) Name() string {
|
||||||
return r.opts.Name
|
return r.opts.Name
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user