-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a statds reporter which does not aggregate values. Fixes #327
- Loading branch information
1 parent
1a6d59d
commit 1b454db
Showing
3 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package metrics | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"time" | ||
|
||
alstatsd "github.com/alexcesaro/statsd" | ||
) | ||
|
||
func newRawStatsDRegistry(prefix, addr string, interval time.Duration) (Registry, error) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if addr == "" { | ||
return nil, errors.New(" statsd addr missing") | ||
This comment has been minimized.
Sorry, something went wrong.
drawks
|
||
} | ||
|
||
c, err := alstatsd.New(alstatsd.Address(addr), alstatsd.FlushPeriod(interval)) | ||
if err != nil { | ||
return nil, fmt.Errorf(" cannot init statsd client: %s", err) | ||
} | ||
|
||
return &rawStatsDRegistry{c}, nil | ||
} | ||
|
||
type rawStatsDRegistry struct { | ||
c *alstatsd.Client | ||
} | ||
|
||
func (r *rawStatsDRegistry) Names() []string { return nil } | ||
func (r *rawStatsDRegistry) Unregister(name string) {} | ||
func (r *rawStatsDRegistry) UnregisterAll() {} | ||
|
||
func (r *rawStatsDRegistry) GetCounter(name string) Counter { | ||
return &rawStatsDCounter{r.c, name} | ||
} | ||
|
||
func (r *rawStatsDRegistry) GetTimer(name string) Timer { | ||
return &rawStatsDTimer{r.c, name} | ||
} | ||
|
||
type rawStatsDCounter struct { | ||
c *alstatsd.Client | ||
name string | ||
} | ||
|
||
func (c *rawStatsDCounter) Inc(n int64) { | ||
c.c.Increment(c.name) | ||
} | ||
|
||
type rawStatsDTimer struct { | ||
c *alstatsd.Client | ||
name string | ||
} | ||
|
||
func (t *rawStatsDTimer) Update(d time.Duration) { | ||
t.c.Timing(t.name, int(d/time.Millisecond)) | ||
} | ||
|
||
func (t *rawStatsDTimer) UpdateSince(start time.Time) { | ||
t.Update(time.Now().Sub(start)) | ||
} | ||
|
||
func (t *rawStatsDTimer) Rate1() float64 { return 0 } | ||
func (t *rawStatsDTimer) Percentile(nth float64) float64 { return 0 } |
Your constructor takes
prefix
but doesn't do anything with it. I would expect that the prefix would be appended to statsd metric names just as withmetrics.target=statsd