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
|
||||
type Meter interface {
|
||||
// Name returns meter name
|
||||
Name() string
|
||||
// Init initialize meter
|
||||
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
|
||||
// FloatCounter get or create float counter
|
||||
FloatCounter(name string, labels ...string) FloatCounter
|
||||
// Gauge get or create gauge
|
||||
Gauge(name string, fn func() float64, labels ...string) Gauge
|
||||
// Set create new meter metrics set
|
||||
Set(opts ...Option) Meter
|
||||
// Histogram get or create histogram
|
||||
Histogram(name string, labels ...string) Histogram
|
||||
// Summary get or create 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
|
||||
// Write writes metrics to io.Writer
|
||||
Write(w io.Writer, opts ...Option) error
|
||||
// Options returns meter options
|
||||
Options() Options
|
||||
// String return meter type
|
||||
String() string
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,15 @@ func NewMeter(opts ...Option) Meter {
|
||||
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 {
|
||||
return r.opts.Name
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user