forked from DataDog/datadog-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves DataDog#88
- Loading branch information
Sam Park
committed
Sep 10, 2019
1 parent
5f2042b
commit 584a084
Showing
2 changed files
with
122 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package statsd | ||
|
||
import "time" | ||
|
||
// NoOpClient is a statsd client that does nothing. Can be useful in testing | ||
// situations for library users. | ||
type NoOpClient struct{} | ||
|
||
func (n *NoOpClient) Gauge(name string, value float64, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Count(name string, value int64, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Histogram(name string, value float64, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Distribution(name string, value float64, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Decr(name string, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Incr(name string, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Set(name string, value string, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Timing(name string, value time.Duration, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) TimeInMilliseconds(name string, value float64, tags []string, rate float64) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) Event(e *Event) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) SimpleEvent(title, text string) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) ServiceCheck(sc *ServiceCheck) error { | ||
return nil | ||
} | ||
|
||
func (n *NoOpClient) SimpleServiceCheck(name string, status ServiceCheckStatus) error { | ||
return nil | ||
} |
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 statsd | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestNoOpClient(t *testing.T) { | ||
c := NoOpClient{} | ||
tags := []string{"a:b"} | ||
|
||
if c.Gauge("asd", 123.4, tags, 56.0) != nil { | ||
t.Error("Gauge output not nil") | ||
} | ||
|
||
if c.Count("asd", 1234, tags, 56.0) != nil { | ||
t.Error("Count output not nil") | ||
} | ||
|
||
if c.Histogram("asd", 12.34, tags, 56.0) != nil { | ||
t.Error("Histogram output not nil") | ||
} | ||
|
||
if c.Distribution("asd", 1.234, tags, 56.0) != nil { | ||
t.Error("Distribution output not nil") | ||
} | ||
|
||
if c.Decr("asd", tags, 56.0) != nil { | ||
t.Error("Decr output not nil") | ||
} | ||
|
||
if c.Incr("asd", tags, 56.0) != nil { | ||
t.Error("Incr output not nil") | ||
} | ||
|
||
if c.Set("asd", "asd", tags, 56.0) != nil { | ||
t.Error("Set output not nil") | ||
} | ||
|
||
if c.Timing("asd", time.Second, tags, 56.0) != nil { | ||
t.Error("Timing output not nil") | ||
} | ||
|
||
if c.TimeInMilliseconds("asd", 1234.5, tags, 56.0) != nil { | ||
t.Error("TimeInMilliseconds output not nil") | ||
} | ||
|
||
if c.Event(nil) != nil { | ||
t.Error("Event output not nil") | ||
} | ||
|
||
if c.SimpleEvent("asd", "zxc") != nil { | ||
t.Error("SimpleEvent output not nil") | ||
} | ||
|
||
if c.ServiceCheck(nil) != nil { | ||
t.Error("ServiceCheck output not nil") | ||
} | ||
|
||
if c.SimpleServiceCheck("asd", Ok) != nil { | ||
t.Error("SimpleServiceCheck output not nil") | ||
} | ||
} |