Skip to content

Commit

Permalink
add support for sets
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberdelia committed Nov 10, 2012
1 parent 3ba8369 commit 8c2eebe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ func (c *Client) Gauge(stat string, value int, rate float64) error {
return c.send(stat, rate, "%d|g", value)
}

// Record unique occurences of events
func (c *Client) Unique(stat string, value int, rate float64) error {
return c.send(stat, rate, "%d|s", value)
}

func (c *Client) Close() error {
err := c.buf.Flush()
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func TestGauge(t *testing.T) {
assert.Equal(t, data, "gauge:300|g")
}

func TestUnique(t *testing.T) {
c := fakeClient()
err := c.Unique("unique", 765, 1)
assert.Equal(t, err, nil)
data := readData(c.buf)
assert.Equal(t, data, "unique:765|s")
}

func TestMilliseconds(t *testing.T) {
msec, _ := time.ParseDuration("350ms")
assert.Equal(t, 350, millisecond(msec))
Expand Down

0 comments on commit 8c2eebe

Please sign in to comment.