VOL-2112 move to voltha-lib-go
Change-Id: Ic1af08003c1d2c698c0cce371e64f47b47b8d875
diff --git a/vendor/github.com/armon/go-metrics/inmem_endpoint.go b/vendor/github.com/armon/go-metrics/inmem_endpoint.go
index 504f1b3..5fac958 100644
--- a/vendor/github.com/armon/go-metrics/inmem_endpoint.go
+++ b/vendor/github.com/armon/go-metrics/inmem_endpoint.go
@@ -41,6 +41,16 @@
DisplayLabels map[string]string `json:"Labels"`
}
+// deepCopy allocates a new instance of AggregateSample
+func (source *SampledValue) deepCopy() SampledValue {
+ dest := *source
+ if source.AggregateSample != nil {
+ dest.AggregateSample = &AggregateSample{}
+ *dest.AggregateSample = *source.AggregateSample
+ }
+ return dest
+}
+
// DisplayMetrics returns a summary of the metrics from the most recent finished interval.
func (i *InmemSink) DisplayMetrics(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
data := i.Data()
@@ -52,12 +62,15 @@
return nil, fmt.Errorf("no metric intervals have been initialized yet")
case n == 1:
// Show the current interval if it's all we have
- interval = i.intervals[0]
+ interval = data[0]
default:
// Show the most recent finished interval if we have one
- interval = i.intervals[n-2]
+ interval = data[n-2]
}
+ interval.RLock()
+ defer interval.RUnlock()
+
summary := MetricsSummary{
Timestamp: interval.Interval.Round(time.Second).UTC().String(),
Gauges: make([]GaugeValue, 0, len(interval.Gauges)),