Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Created March 30, 2016 13:31
Show Gist options
  • Save gonzaloserrano/ae0b606916254d7b07f64274df3cb25f to your computer and use it in GitHub Desktop.
Save gonzaloserrano/ae0b606916254d7b07f64274df3cb25f to your computer and use it in GitHub Desktop.
package metrics
type dummyMetrics struct{}
func NewDummy() Metrics {
return &dummyMetrics{}
}
func (d *dummyMetrics) Counter(name string, tags ...Tag) Counter {
return &dummyCounter{Name: name, tags: tags}
}
func (d *dummyMetrics) Gauge(name string, tags ...Tag) Gauge {
return &dummyGauge{name: name, tags: tags}
}
func (d *dummyMetrics) Event(title string, tags ...Tag) Event {
return &dummyEvent{title: title, tags: tags}
}
func (d *dummyMetrics) Flush() {
}
type dummyCounter struct {
Name string
tags Tags
value uint64
}
func (c *dummyCounter) Add(delta uint64) {
c.value += delta
}
func (c *dummyCounter) Inc() {
c.value += 1
}
type dummyGauge struct {
name string
tags Tags
value interface{}
}
func (g *dummyGauge) Update(value interface{}) {
g.value = value
}
type dummyEvent struct {
title string
text string
tags Tags
}
func (g *dummyEvent) Send() {
}
func (g *dummyEvent) SendWithText(text string) {
g.text = text
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment