Update oxy dependency
This commit is contained in:
parent
d81c4e6d1a
commit
07be89d6e9
31 changed files with 636 additions and 195 deletions
30
vendor/github.com/vulcand/oxy/memmetrics/histogram.go
generated
vendored
30
vendor/github.com/vulcand/oxy/memmetrics/histogram.go
generated
vendored
|
@ -20,6 +20,7 @@ type HDRHistogram struct {
|
|||
h *hdrhistogram.Histogram
|
||||
}
|
||||
|
||||
// NewHDRHistogram creates a new HDRHistogram
|
||||
func NewHDRHistogram(low, high int64, sigfigs int) (h *HDRHistogram, err error) {
|
||||
defer func() {
|
||||
if msg := recover(); msg != nil {
|
||||
|
@ -34,37 +35,42 @@ func NewHDRHistogram(low, high int64, sigfigs int) (h *HDRHistogram, err error)
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (r *HDRHistogram) Export() *HDRHistogram {
|
||||
var hist *hdrhistogram.Histogram = nil
|
||||
if r.h != nil {
|
||||
snapshot := r.h.Export()
|
||||
// Export export a HDRHistogram
|
||||
func (h *HDRHistogram) Export() *HDRHistogram {
|
||||
var hist *hdrhistogram.Histogram
|
||||
if h.h != nil {
|
||||
snapshot := h.h.Export()
|
||||
hist = hdrhistogram.Import(snapshot)
|
||||
}
|
||||
return &HDRHistogram{low: r.low, high: r.high, sigfigs: r.sigfigs, h: hist}
|
||||
return &HDRHistogram{low: h.low, high: h.high, sigfigs: h.sigfigs, h: hist}
|
||||
}
|
||||
|
||||
// Returns latency at quantile with microsecond precision
|
||||
// LatencyAtQuantile sets latency at quantile with microsecond precision
|
||||
func (h *HDRHistogram) LatencyAtQuantile(q float64) time.Duration {
|
||||
return time.Duration(h.ValueAtQuantile(q)) * time.Microsecond
|
||||
}
|
||||
|
||||
// Records latencies with microsecond precision
|
||||
// RecordLatencies Records latencies with microsecond precision
|
||||
func (h *HDRHistogram) RecordLatencies(d time.Duration, n int64) error {
|
||||
return h.RecordValues(int64(d/time.Microsecond), n)
|
||||
}
|
||||
|
||||
// Reset reset a HDRHistogram
|
||||
func (h *HDRHistogram) Reset() {
|
||||
h.h.Reset()
|
||||
}
|
||||
|
||||
// ValueAtQuantile sets value at quantile
|
||||
func (h *HDRHistogram) ValueAtQuantile(q float64) int64 {
|
||||
return h.h.ValueAtQuantile(q)
|
||||
}
|
||||
|
||||
// RecordValues sets record values
|
||||
func (h *HDRHistogram) RecordValues(v, n int64) error {
|
||||
return h.h.RecordValues(v, n)
|
||||
}
|
||||
|
||||
// Merge merge a HDRHistogram
|
||||
func (h *HDRHistogram) Merge(other *HDRHistogram) error {
|
||||
if other == nil {
|
||||
return fmt.Errorf("other is nil")
|
||||
|
@ -75,6 +81,7 @@ func (h *HDRHistogram) Merge(other *HDRHistogram) error {
|
|||
|
||||
type rhOptSetter func(r *RollingHDRHistogram) error
|
||||
|
||||
// RollingClock sets a clock
|
||||
func RollingClock(clock timetools.TimeProvider) rhOptSetter {
|
||||
return func(r *RollingHDRHistogram) error {
|
||||
r.clock = clock
|
||||
|
@ -82,7 +89,7 @@ func RollingClock(clock timetools.TimeProvider) rhOptSetter {
|
|||
}
|
||||
}
|
||||
|
||||
// RollingHistogram holds multiple histograms and rotates every period.
|
||||
// RollingHDRHistogram holds multiple histograms and rotates every period.
|
||||
// It provides resulting histogram as a result of a call of 'Merged' function.
|
||||
type RollingHDRHistogram struct {
|
||||
idx int
|
||||
|
@ -96,6 +103,7 @@ type RollingHDRHistogram struct {
|
|||
clock timetools.TimeProvider
|
||||
}
|
||||
|
||||
// NewRollingHDRHistogram created a new RollingHDRHistogram
|
||||
func NewRollingHDRHistogram(low, high int64, sigfigs int, period time.Duration, bucketCount int, options ...rhOptSetter) (*RollingHDRHistogram, error) {
|
||||
rh := &RollingHDRHistogram{
|
||||
bucketCount: bucketCount,
|
||||
|
@ -127,6 +135,7 @@ func NewRollingHDRHistogram(low, high int64, sigfigs int, period time.Duration,
|
|||
return rh, nil
|
||||
}
|
||||
|
||||
// Export export a RollingHDRHistogram
|
||||
func (r *RollingHDRHistogram) Export() *RollingHDRHistogram {
|
||||
export := &RollingHDRHistogram{}
|
||||
export.idx = r.idx
|
||||
|
@ -147,6 +156,7 @@ func (r *RollingHDRHistogram) Export() *RollingHDRHistogram {
|
|||
return export
|
||||
}
|
||||
|
||||
// Append append a RollingHDRHistogram
|
||||
func (r *RollingHDRHistogram) Append(o *RollingHDRHistogram) error {
|
||||
if r.bucketCount != o.bucketCount || r.period != o.period || r.low != o.low || r.high != o.high || r.sigfigs != o.sigfigs {
|
||||
return fmt.Errorf("can't merge")
|
||||
|
@ -160,6 +170,7 @@ func (r *RollingHDRHistogram) Append(o *RollingHDRHistogram) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Reset reset a RollingHDRHistogram
|
||||
func (r *RollingHDRHistogram) Reset() {
|
||||
r.idx = 0
|
||||
r.lastRoll = r.clock.UtcNow()
|
||||
|
@ -173,6 +184,7 @@ func (r *RollingHDRHistogram) rotate() {
|
|||
r.buckets[r.idx].Reset()
|
||||
}
|
||||
|
||||
// Merged gets merged histogram
|
||||
func (r *RollingHDRHistogram) Merged() (*HDRHistogram, error) {
|
||||
m, err := NewHDRHistogram(r.low, r.high, r.sigfigs)
|
||||
if err != nil {
|
||||
|
@ -194,10 +206,12 @@ func (r *RollingHDRHistogram) getHist() *HDRHistogram {
|
|||
return r.buckets[r.idx]
|
||||
}
|
||||
|
||||
// RecordLatencies sets records latencies
|
||||
func (r *RollingHDRHistogram) RecordLatencies(v time.Duration, n int64) error {
|
||||
return r.getHist().RecordLatencies(v, n)
|
||||
}
|
||||
|
||||
// RecordValues set record values
|
||||
func (r *RollingHDRHistogram) RecordValues(v, n int64) error {
|
||||
return r.getHist().RecordValues(v, n)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue