@cryptotaxi247 / kubo / commits / 6bd66cc8c

Move metrics to gx

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Jun 11, 2016 at 16:23 UTC 6bd66cc8c3c519858eb5c53d21cd27c49faee47e
15 files changed +7 -793
Godeps/_workspace/src/github.com/codahale/metrics/.travis.yml deleted
-9
@@ -1,9 +0,0 @@
1 -language: go
2 -go:
3 - - 1.3.3
4 -notifications:
5 - # See http://about.travis-ci.org/docs/user/build-configuration/ to learn more
6 - # about configuring notification recipients and more.
7 - email:
8 - recipients:
9 - - coda.hale@gmail.com
Godeps/_workspace/src/github.com/codahale/metrics/LICENSE deleted
-21
@@ -1,21 +0,0 @@
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2014 Coda Hale
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in
13 -all copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -THE SOFTWARE.
Godeps/_workspace/src/github.com/codahale/metrics/README.md deleted
-8
@@ -1,8 +0,0 @@
1 -metrics
2 -=======
3 -
4 -[![Build Status](https://travis-ci.org/codahale/metrics.png?branch=master)](https://travis-ci.org/codahale/metrics)
5 -
6 -A Go library which provides light-weight instrumentation for your application.
7 -
8 -For documentation, check [godoc](http://godoc.org/github.com/codahale/metrics).
Godeps/_workspace/src/github.com/codahale/metrics/metrics.go deleted
-329
@@ -1,329 +0,0 @@
1 -// Package metrics provides minimalist instrumentation for your applications in
2 -// the form of counters and gauges.
3 -//
4 -// Counters
5 -//
6 -// A counter is a monotonically-increasing, unsigned, 64-bit integer used to
7 -// represent the number of times an event has occurred. By tracking the deltas
8 -// between measurements of a counter over intervals of time, an aggregation
9 -// layer can derive rates, acceleration, etc.
10 -//
11 -// Gauges
12 -//
13 -// A gauge returns instantaneous measurements of something using signed, 64-bit
14 -// integers. This value does not need to be monotonic.
15 -//
16 -// Histograms
17 -//
18 -// A histogram tracks the distribution of a stream of values (e.g. the number of
19 -// milliseconds it takes to handle requests), adding gauges for the values at
20 -// meaningful quantiles: 50th, 75th, 90th, 95th, 99th, 99.9th.
21 -//
22 -// Reporting
23 -//
24 -// Measurements from counters and gauges are available as expvars. Your service
25 -// should return its expvars from an HTTP endpoint (i.e., /debug/vars) as a JSON
26 -// object.
27 -package metrics
28 -
29 -import (
30 - "expvar"
31 - "sync"
32 - "time"
33 -
34 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/hdrhistogram"
35 -)
36 -
37 -// A Counter is a monotonically increasing unsigned integer.
38 -//
39 -// Use a counter to derive rates (e.g., record total number of requests, derive
40 -// requests per second).
41 -type Counter string
42 -
43 -// Add increments the counter by one.
44 -func (c Counter) Add() {
45 - c.AddN(1)
46 -}
47 -
48 -// AddN increments the counter by N.
49 -func (c Counter) AddN(delta uint64) {
50 - cm.Lock()
51 - counters[string(c)] += delta
52 - cm.Unlock()
53 -}
54 -
55 -// SetFunc sets the counter's value to the lazily-called return value of the
56 -// given function.
57 -func (c Counter) SetFunc(f func() uint64) {
58 - cm.Lock()
59 - defer cm.Unlock()
60 -
61 - counterFuncs[string(c)] = f
62 -}
63 -
64 -// SetBatchFunc sets the counter's value to the lazily-called return value of
65 -// the given function, with an additional initializer function for a related
66 -// batch of counters, all of which are keyed by an arbitrary value.
67 -func (c Counter) SetBatchFunc(key interface{}, init func(), f func() uint64) {
68 - cm.Lock()
69 - defer cm.Unlock()
70 -
71 - gm.Lock()
72 - defer gm.Unlock()
73 -
74 - counterFuncs[string(c)] = f
75 - if _, ok := inits[key]; !ok {
76 - inits[key] = init
77 - }
78 -}
79 -
80 -// Remove removes the given counter.
81 -func (c Counter) Remove() {
82 - cm.Lock()
83 - defer cm.Unlock()
84 -
85 - gm.Lock()
86 - defer gm.Unlock()
87 -
88 - delete(counters, string(c))
89 - delete(counterFuncs, string(c))
90 - delete(inits, string(c))
91 -}
92 -
93 -// A Gauge is an instantaneous measurement of a value.
94 -//
95 -// Use a gauge to track metrics which increase and decrease (e.g., amount of
96 -// free memory).
97 -type Gauge string
98 -
99 -// Set the gauge's value to the given value.
100 -func (g Gauge) Set(value int64) {
101 - gm.Lock()
102 - defer gm.Unlock()
103 -
104 - gauges[string(g)] = func() int64 {
105 - return value
106 - }
107 -}
108 -
109 -// SetFunc sets the gauge's value to the lazily-called return value of the given
110 -// function.
111 -func (g Gauge) SetFunc(f func() int64) {
112 - gm.Lock()
113 - defer gm.Unlock()
114 -
115 - gauges[string(g)] = f
116 -}
117 -
118 -// SetBatchFunc sets the gauge's value to the lazily-called return value of the
119 -// given function, with an additional initializer function for a related batch
120 -// of gauges, all of which are keyed by an arbitrary value.
121 -func (g Gauge) SetBatchFunc(key interface{}, init func(), f func() int64) {
122 - gm.Lock()
123 - defer gm.Unlock()
124 -
125 - gauges[string(g)] = f
126 - if _, ok := inits[key]; !ok {
127 - inits[key] = init
128 - }
129 -}
130 -
131 -// Remove removes the given gauge.
132 -func (g Gauge) Remove() {
133 - gm.Lock()
134 - defer gm.Unlock()
135 -
136 - delete(gauges, string(g))
137 - delete(inits, string(g))
138 -}
139 -
140 -// Reset removes all existing counters and gauges.
141 -func Reset() {
142 - cm.Lock()
143 - defer cm.Unlock()
144 -
145 - gm.Lock()
146 - defer gm.Unlock()
147 -
148 - hm.Lock()
149 - defer hm.Unlock()
150 -
151 - counters = make(map[string]uint64)
152 - counterFuncs = make(map[string]func() uint64)
153 - gauges = make(map[string]func() int64)
154 - histograms = make(map[string]*Histogram)
155 - inits = make(map[interface{}]func())
156 -}
157 -
158 -// Snapshot returns a copy of the values of all registered counters and gauges.
159 -func Snapshot() (c map[string]uint64, g map[string]int64) {
160 - cm.Lock()
161 - defer cm.Unlock()
162 -
163 - gm.Lock()
164 - defer gm.Unlock()
165 -
166 - hm.Lock()
167 - defer hm.Unlock()
168 -
169 - for _, init := range inits {
170 - init()
171 - }
172 -
173 - c = make(map[string]uint64, len(counters)+len(counterFuncs))
174 - for n, v := range counters {
175 - c[n] = v
176 - }
177 -
178 - for n, f := range counterFuncs {
179 - c[n] = f()
180 - }
181 -
182 - g = make(map[string]int64, len(gauges))
183 - for n, f := range gauges {
184 - g[n] = f()
185 - }
186 -
187 - return
188 -}
189 -
190 -// NewHistogram returns a windowed HDR histogram which drops data older than
191 -// five minutes. The returned histogram is safe to use from multiple goroutines.
192 -//
193 -// Use a histogram to track the distribution of a stream of values (e.g., the
194 -// latency associated with HTTP requests).
195 -func NewHistogram(name string, minValue, maxValue int64, sigfigs int) *Histogram {
196 - hm.Lock()
197 - defer hm.Unlock()
198 -
199 - if _, ok := histograms[name]; ok {
200 - panic(name + " already exists")
201 - }
202 -
203 - hist := &Histogram{
204 - name: name,
205 - hist: hdrhistogram.NewWindowed(5, minValue, maxValue, sigfigs),
206 - }
207 - histograms[name] = hist
208 -
209 - Gauge(name+".P50").SetBatchFunc(hname(name), hist.merge, hist.valueAt(50))
210 - Gauge(name+".P75").SetBatchFunc(hname(name), hist.merge, hist.valueAt(75))
211 - Gauge(name+".P90").SetBatchFunc(hname(name), hist.merge, hist.valueAt(90))
212 - Gauge(name+".P95").SetBatchFunc(hname(name), hist.merge, hist.valueAt(95))
213 - Gauge(name+".P99").SetBatchFunc(hname(name), hist.merge, hist.valueAt(99))
214 - Gauge(name+".P999").SetBatchFunc(hname(name), hist.merge, hist.valueAt(99.9))
215 -
216 - return hist
217 -}
218 -
219 -// Remove removes the given histogram.
220 -func (h *Histogram) Remove() {
221 -
222 - hm.Lock()
223 - defer hm.Unlock()
224 -
225 - Gauge(h.name + ".P50").Remove()
226 - Gauge(h.name + ".P75").Remove()
227 - Gauge(h.name + ".P90").Remove()
228 - Gauge(h.name + ".P95").Remove()
229 - Gauge(h.name + ".P99").Remove()
230 - Gauge(h.name + ".P999").Remove()
231 -
232 - delete(histograms, h.name)
233 -}
234 -
235 -type hname string // unexported to prevent collisions
236 -
237 -// A Histogram measures the distribution of a stream of values.
238 -type Histogram struct {
239 - name string
240 - hist *hdrhistogram.WindowedHistogram
241 - m *hdrhistogram.Histogram
242 - rw sync.RWMutex
243 -}
244 -
245 -// Name returns the name of the histogram
246 -func (h *Histogram) Name() string {
247 - return h.name
248 -}
249 -
250 -// RecordValue records the given value, or returns an error if the value is out
251 -// of range.
252 -// Returned error values are of type Error.
253 -func (h *Histogram) RecordValue(v int64) error {
254 - h.rw.Lock()
255 - defer h.rw.Unlock()
256 -
257 - err := h.hist.Current.RecordValue(v)
258 - if err != nil {
259 - return Error{h.name, err}
260 - }
261 - return nil
262 -}
263 -
264 -func (h *Histogram) rotate() {
265 - h.rw.Lock()
266 - defer h.rw.Unlock()
267 -
268 - h.hist.Rotate()
269 -}
270 -
271 -func (h *Histogram) merge() {
272 - h.rw.Lock()
273 - defer h.rw.Unlock()
274 -
275 - h.m = h.hist.Merge()
276 -}
277 -
278 -func (h *Histogram) valueAt(q float64) func() int64 {
279 - return func() int64 {
280 - h.rw.RLock()
281 - defer h.rw.RUnlock()
282 -
283 - if h.m == nil {
284 - return 0
285 - }
286 -
287 - return h.m.ValueAtQuantile(q)
288 - }
289 -}
290 -
291 -// Error describes an error and the name of the metric where it occurred.
292 -type Error struct {
293 - Metric string
294 - Err error
295 -}
296 -
297 -func (e Error) Error() string {
298 - return e.Metric + ": " + e.Err.Error()
299 -}
300 -
301 -var (
302 - counters = make(map[string]uint64)
303 - counterFuncs = make(map[string]func() uint64)
304 - gauges = make(map[string]func() int64)
305 - inits = make(map[interface{}]func())
306 - histograms = make(map[string]*Histogram)
307 -
308 - cm, gm, hm sync.Mutex
309 -)
310 -
311 -func init() {
312 - expvar.Publish("metrics", expvar.Func(func() interface{} {
313 - counters, gauges := Snapshot()
314 - return map[string]interface{}{
315 - "Counters": counters,
316 - "Gauges": gauges,
317 - }
318 - }))
319 -
320 - go func() {
321 - for _ = range time.NewTicker(1 * time.Minute).C {
322 - hm.Lock()
323 - for _, h := range histograms {
324 - h.rotate()
325 - }
326 - hm.Unlock()
327 - }
328 - }()
329 -}
Godeps/_workspace/src/github.com/codahale/metrics/metrics_test.go deleted
-217
@@ -1,217 +0,0 @@
1 -package metrics_test
2 -
3 -import (
4 - "testing"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
7 -)
8 -
9 -func TestCounter(t *testing.T) {
10 - metrics.Reset()
11 -
12 - metrics.Counter("whee").Add()
13 - metrics.Counter("whee").AddN(10)
14 -
15 - counters, _ := metrics.Snapshot()
16 - if v, want := counters["whee"], uint64(11); v != want {
17 - t.Errorf("Counter was %v, but expected %v", v, want)
18 - }
19 -}
20 -
21 -func TestCounterFunc(t *testing.T) {
22 - metrics.Reset()
23 -
24 - metrics.Counter("whee").SetFunc(func() uint64 {
25 - return 100
26 - })
27 -
28 - counters, _ := metrics.Snapshot()
29 - if v, want := counters["whee"], uint64(100); v != want {
30 - t.Errorf("Counter was %v, but expected %v", v, want)
31 - }
32 -}
33 -
34 -func TestCounterBatchFunc(t *testing.T) {
35 - metrics.Reset()
36 -
37 - var a, b uint64
38 -
39 - metrics.Counter("whee").SetBatchFunc(
40 - "yay",
41 - func() {
42 - a, b = 1, 2
43 - },
44 - func() uint64 {
45 - return a
46 - },
47 - )
48 -
49 - metrics.Counter("woo").SetBatchFunc(
50 - "yay",
51 - func() {
52 - a, b = 1, 2
53 - },
54 - func() uint64 {
55 - return b
56 - },
57 - )
58 -
59 - counters, _ := metrics.Snapshot()
60 - if v, want := counters["whee"], uint64(1); v != want {
61 - t.Errorf("Counter was %v, but expected %v", v, want)
62 - }
63 -
64 - if v, want := counters["woo"], uint64(2); v != want {
65 - t.Errorf("Counter was %v, but expected %v", v, want)
66 - }
67 -}
68 -
69 -func TestCounterRemove(t *testing.T) {
70 - metrics.Reset()
71 -
72 - metrics.Counter("whee").Add()
73 - metrics.Counter("whee").Remove()
74 -
75 - counters, _ := metrics.Snapshot()
76 - if v, ok := counters["whee"]; ok {
77 - t.Errorf("Counter was %v, but expected nothing", v)
78 - }
79 -}
80 -
81 -func TestGaugeValue(t *testing.T) {
82 - metrics.Reset()
83 -
84 - metrics.Gauge("whee").Set(-100)
85 -
86 - _, gauges := metrics.Snapshot()
87 - if v, want := gauges["whee"], int64(-100); v != want {
88 - t.Errorf("Gauge was %v, but expected %v", v, want)
89 - }
90 -}
91 -
92 -func TestGaugeFunc(t *testing.T) {
93 - metrics.Reset()
94 -
95 - metrics.Gauge("whee").SetFunc(func() int64 {
96 - return -100
97 - })
98 -
99 - _, gauges := metrics.Snapshot()
100 - if v, want := gauges["whee"], int64(-100); v != want {
101 - t.Errorf("Gauge was %v, but expected %v", v, want)
102 - }
103 -}
104 -
105 -func TestGaugeRemove(t *testing.T) {
106 - metrics.Reset()
107 -
108 - metrics.Gauge("whee").Set(1)
109 - metrics.Gauge("whee").Remove()
110 -
111 - _, gauges := metrics.Snapshot()
112 - if v, ok := gauges["whee"]; ok {
113 - t.Errorf("Gauge was %v, but expected nothing", v)
114 - }
115 -}
116 -
117 -func TestHistogram(t *testing.T) {
118 - metrics.Reset()
119 -
120 - h := metrics.NewHistogram("heyo", 1, 1000, 3)
121 - for i := 100; i > 0; i-- {
122 - for j := 0; j < i; j++ {
123 - h.RecordValue(int64(i))
124 - }
125 - }
126 -
127 - _, gauges := metrics.Snapshot()
128 -
129 - if v, want := gauges["heyo.P50"], int64(71); v != want {
130 - t.Errorf("P50 was %v, but expected %v", v, want)
131 - }
132 -
133 - if v, want := gauges["heyo.P75"], int64(87); v != want {
134 - t.Errorf("P75 was %v, but expected %v", v, want)
135 - }
136 -
137 - if v, want := gauges["heyo.P90"], int64(95); v != want {
138 - t.Errorf("P90 was %v, but expected %v", v, want)
139 - }
140 -
141 - if v, want := gauges["heyo.P95"], int64(98); v != want {
142 - t.Errorf("P95 was %v, but expected %v", v, want)
143 - }
144 -
145 - if v, want := gauges["heyo.P99"], int64(100); v != want {
146 - t.Errorf("P99 was %v, but expected %v", v, want)
147 - }
148 -
149 - if v, want := gauges["heyo.P999"], int64(100); v != want {
150 - t.Errorf("P999 was %v, but expected %v", v, want)
151 - }
152 -}
153 -
154 -func TestHistogramRemove(t *testing.T) {
155 - metrics.Reset()
156 -
157 - h := metrics.NewHistogram("heyo", 1, 1000, 3)
158 - h.Remove()
159 -
160 - _, gauges := metrics.Snapshot()
161 - if v, ok := gauges["heyo.P50"]; ok {
162 - t.Errorf("Gauge was %v, but expected nothing", v)
163 - }
164 -}
165 -
166 -func BenchmarkCounterAdd(b *testing.B) {
167 - metrics.Reset()
168 -
169 - b.ReportAllocs()
170 - b.ResetTimer()
171 -
172 - b.RunParallel(func(pb *testing.PB) {
173 - for pb.Next() {
174 - metrics.Counter("test1").Add()
175 - }
176 - })
177 -}
178 -
179 -func BenchmarkCounterAddN(b *testing.B) {
180 - metrics.Reset()
181 -
182 - b.ReportAllocs()
183 - b.ResetTimer()
184 -
185 - b.RunParallel(func(pb *testing.PB) {
186 - for pb.Next() {
187 - metrics.Counter("test2").AddN(100)
188 - }
189 - })
190 -}
191 -
192 -func BenchmarkGaugeSet(b *testing.B) {
193 - metrics.Reset()
194 -
195 - b.ReportAllocs()
196 - b.ResetTimer()
197 -
198 - b.RunParallel(func(pb *testing.PB) {
199 - for pb.Next() {
200 - metrics.Gauge("test2").Set(100)
201 - }
202 - })
203 -}
204 -
205 -func BenchmarkHistogramRecordValue(b *testing.B) {
206 - metrics.Reset()
207 - h := metrics.NewHistogram("hist", 1, 1000, 3)
208 -
209 - b.ReportAllocs()
210 - b.ResetTimer()
211 -
212 - b.RunParallel(func(pb *testing.PB) {
213 - for pb.Next() {
214 - h.RecordValue(100)
215 - }
216 - })
217 -}
Godeps/_workspace/src/github.com/codahale/metrics/runtime/doc.go deleted
-18
@@ -1,18 +0,0 @@
1 -// Package runtime registers gauges and counters for various operationally
2 -// important aspects of the Go runtime.
3 -//
4 -// To use, import this package:
5 -//
6 -// import _ "github.com/codahale/metrics/runtime"
7 -//
8 -// This registers the following gauges:
9 -//
10 -// FileDescriptors.Max
11 -// FileDescriptors.Used
12 -// Mem.NumGC
13 -// Mem.PauseTotalNs
14 -// Mem.LastGC
15 -// Mem.Alloc
16 -// Mem.HeapObjects
17 -// Goroutines.Num
18 -package runtime
Godeps/_workspace/src/github.com/codahale/metrics/runtime/fds.go deleted
-46
@@ -1,46 +0,0 @@
1 -// +build !windows
2 -
3 -package runtime
4 -
5 -import (
6 - "io/ioutil"
7 - "syscall"
8 -
9 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
10 -)
11 -
12 -func getFDLimit() (uint64, error) {
13 - var rlimit syscall.Rlimit
14 - if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
15 - return 0, err
16 - }
17 - // rlimit.Cur's type is platform-dependent, so here we widen it as far as Go
18 - // will allow by converting it to a uint64.
19 - return uint64(rlimit.Cur), nil
20 -}
21 -
22 -func getFDUsage() (uint64, error) {
23 - fds, err := ioutil.ReadDir("/proc/self/fd")
24 - if err != nil {
25 - return 0, err
26 - }
27 - return uint64(len(fds)), nil
28 -}
29 -
30 -func init() {
31 - metrics.Gauge("FileDescriptors.Max").SetFunc(func() int64 {
32 - v, err := getFDLimit()
33 - if err != nil {
34 - return 0
35 - }
36 - return int64(v)
37 - })
38 -
39 - metrics.Gauge("FileDescriptors.Used").SetFunc(func() int64 {
40 - v, err := getFDUsage()
41 - if err != nil {
42 - return 0
43 - }
44 - return int64(v)
45 - })
46 -}
Godeps/_workspace/src/github.com/codahale/metrics/runtime/fds_test.go deleted
-24
@@ -1,24 +0,0 @@
1 -// +build !windows
2 -
3 -package runtime
4 -
5 -import (
6 - "testing"
7 -
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
9 -)
10 -
11 -func TestFdStats(t *testing.T) {
12 - _, gauges := metrics.Snapshot()
13 -
14 - expected := []string{
15 - "FileDescriptors.Max",
16 - "FileDescriptors.Used",
17 - }
18 -
19 - for _, name := range expected {
20 - if _, ok := gauges[name]; !ok {
21 - t.Errorf("Missing gauge %q", name)
22 - }
23 - }
24 -}
Godeps/_workspace/src/github.com/codahale/metrics/runtime/fds_windows.go deleted
-4
@@ -1,4 +0,0 @@
1 -package runtime
2 -
3 -func init() {
4 -}
Godeps/_workspace/src/github.com/codahale/metrics/runtime/goroutines.go deleted
-13
@@ -1,13 +0,0 @@
1 -package runtime
2 -
3 -import (
4 - "runtime"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
7 -)
8 -
9 -func init() {
10 - metrics.Gauge("Goroutines.Num").SetFunc(func() int64 {
11 - return int64(runtime.NumGoroutine())
12 - })
13 -}
Godeps/_workspace/src/github.com/codahale/metrics/runtime/goroutines_test.go deleted
-21
@@ -1,21 +0,0 @@
1 -package runtime
2 -
3 -import (
4 - "testing"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
7 -)
8 -
9 -func TestGoroutinesStats(t *testing.T) {
10 - _, gauges := metrics.Snapshot()
11 -
12 - expected := []string{
13 - "Goroutines.Num",
14 - }
15 -
16 - for _, name := range expected {
17 - if _, ok := gauges[name]; !ok {
18 - t.Errorf("Missing gauge %q", name)
19 - }
20 - }
21 -}
Godeps/_workspace/src/github.com/codahale/metrics/runtime/memstats.go deleted
-48
@@ -1,48 +0,0 @@
1 -package runtime
2 -
3 -import (
4 - "runtime"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
7 -)
8 -
9 -func init() {
10 - msg := &memStatGauges{}
11 -
12 - metrics.Counter("Mem.NumGC").SetBatchFunc(key{}, msg.init, msg.numGC)
13 - metrics.Counter("Mem.PauseTotalNs").SetBatchFunc(key{}, msg.init, msg.totalPause)
14 -
15 - metrics.Gauge("Mem.LastGC").SetBatchFunc(key{}, msg.init, msg.lastPause)
16 - metrics.Gauge("Mem.Alloc").SetBatchFunc(key{}, msg.init, msg.alloc)
17 - metrics.Gauge("Mem.HeapObjects").SetBatchFunc(key{}, msg.init, msg.objects)
18 -}
19 -
20 -type key struct{} // unexported to prevent collision
21 -
22 -type memStatGauges struct {
23 - stats runtime.MemStats
24 -}
25 -
26 -func (msg *memStatGauges) init() {
27 - runtime.ReadMemStats(&msg.stats)
28 -}
29 -
30 -func (msg *memStatGauges) numGC() uint64 {
31 - return uint64(msg.stats.NumGC)
32 -}
33 -
34 -func (msg *memStatGauges) totalPause() uint64 {
35 - return msg.stats.PauseTotalNs
36 -}
37 -
38 -func (msg *memStatGauges) lastPause() int64 {
39 - return int64(msg.stats.LastGC)
40 -}
41 -
42 -func (msg *memStatGauges) alloc() int64 {
43 - return int64(msg.stats.Alloc)
44 -}
45 -
46 -func (msg *memStatGauges) objects() int64 {
47 - return int64(msg.stats.HeapObjects)
48 -}
Godeps/_workspace/src/github.com/codahale/metrics/runtime/memstats_test.go deleted
-34
@@ -1,34 +0,0 @@
1 -package runtime
2 -
3 -import (
4 - "testing"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
7 -)
8 -
9 -func TestMemStats(t *testing.T) {
10 - counters, gauges := metrics.Snapshot()
11 -
12 - expectedCounters := []string{
13 - "Mem.NumGC",
14 - "Mem.PauseTotalNs",
15 - }
16 -
17 - expectedGauges := []string{
18 - "Mem.LastGC",
19 - "Mem.Alloc",
20 - "Mem.HeapObjects",
21 - }
22 -
23 - for _, name := range expectedCounters {
24 - if _, ok := counters[name]; !ok {
25 - t.Errorf("Missing counters %q", name)
26 - }
27 - }
28 -
29 - for _, name := range expectedGauges {
30 - if _, ok := gauges[name]; !ok {
31 - t.Errorf("Missing gauge %q", name)
32 - }
33 - }
34 -}
cmd/ipfs/daemon.go
+1 -1
@@ -11,8 +11,8 @@ import (
11 "strings"
12 "sync"
13
14 - _ "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics/runtime"
14 "gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net"
15 + _ "gx/ipfs/QmV3NSS3A1kX5s28r7yLczhDsXzkgo65cqRgKFXYunWZmD/metrics/runtime"
16
17 ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
18
package.json
+6
@@ -147,6 +147,12 @@
147 "hash": "QmZ6A6P6AMo8SR3jXAwzTuSU6B9R2Y4eqW2yW9VvfUayDN",
148 "name": "go-datastore",
149 "version": "0.0.1"
150 + },
151 + {
152 + "author": "codahale",
153 + "hash": "QmV3NSS3A1kX5s28r7yLczhDsXzkgo65cqRgKFXYunWZmD",
154 + "name": "metrics",
155 + "version": "0.0.0"
156 }
157 ],
158 "gxVersion": "0.4.0",