changing datadog package name to stats

This commit is contained in:
Michael Baird 2017-05-19 09:54:19 -05:00
parent 1d05707026
commit 843e947ca8
3 changed files with 14 additions and 14 deletions

View file

@ -31,9 +31,9 @@ import (
"time"
"github.com/pilosa/pilosa"
"github.com/pilosa/pilosa/datadog"
"github.com/pilosa/pilosa/gossip"
"github.com/pilosa/pilosa/httpbroadcast"
"github.com/pilosa/pilosa/statsd"
)
func init() {
@ -238,7 +238,7 @@ func NewStatsClient(name string, host string) (pilosa.StatsClient, error) {
case "expvar":
return pilosa.NewExpvarStatsClient(), nil
case "statsd":
return datadog.NewStatsClient(host)
return statsd.NewStatsClient(host)
default:
return pilosa.NopStatsClient, nil
}

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package datadog
package statsd
import (
"io"
@ -38,7 +38,7 @@ const (
// Ensure client implements interface.
var _ pilosa.StatsClient = &StatsClient{}
// StatsClient represents a DataDog implementation of pilosa.StatsClient.
// StatsClient represents a StatsD implementation of pilosa.StatsClient.
type StatsClient struct {
client *statsd.Client
tags []string
@ -80,7 +80,7 @@ func (c *StatsClient) WithTags(tags ...string) pilosa.StatsClient {
// Count tracks the number of times something occurs per second.
func (c *StatsClient) Count(name string, value int64, rate float64) {
if err := c.client.Count(Prefix+name, value, c.tags, rate); err != nil {
c.logger().Printf("datadog.StatsClient.Count error: %s", err)
c.logger().Printf("statsd.StatsClient.Count error: %s", err)
}
}
@ -88,35 +88,35 @@ func (c *StatsClient) Count(name string, value int64, rate float64) {
func (c *StatsClient) CountWithCustomTags(name string, value int64, rate float64, t []string) {
tags := append(c.tags, t...)
if err := c.client.Count(Prefix+name, value, tags, rate); err != nil {
c.logger().Printf("datadog.StatsClient.Count error: %s", err)
c.logger().Printf("statsd.StatsClient.Count error: %s", err)
}
}
// Gauge sets the value of a metric.
func (c *StatsClient) Gauge(name string, value float64, rate float64) {
if err := c.client.Gauge(Prefix+name, value, c.tags, rate); err != nil {
c.logger().Printf("datadog.StatsClient.Gauge error: %s", err)
c.logger().Printf("statsd.StatsClient.Gauge error: %s", err)
}
}
// Histogram tracks statistical distribution of a metric.
func (c *StatsClient) Histogram(name string, value float64, rate float64) {
if err := c.client.Histogram(Prefix+name, value, c.tags, rate); err != nil {
c.logger().Printf("datadog.StatsClient.Histogram error: %s", err)
c.logger().Printf("statsd.StatsClient.Histogram error: %s", err)
}
}
// Set tracks number of unique elements.
func (c *StatsClient) Set(name string, value string, rate float64) {
if err := c.client.Set(Prefix+name, value, c.tags, rate); err != nil {
c.logger().Printf("datadog.StatsClient.Set error: %s", err)
c.logger().Printf("statsd.StatsClient.Set error: %s", err)
}
}
// Timing tracks timing information for a metric.
func (c *StatsClient) Timing(name string, value time.Duration, rate float64) {
if err := c.client.Timing(Prefix+name, value, c.tags, rate); err != nil {
c.logger().Printf("datadog.StatsClient.Timing error: %s", err)
c.logger().Printf("statsd.StatsClient.Timing error: %s", err)
}
}

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package datadog_test
package statsd_test
import (
"io/ioutil"
@ -20,12 +20,12 @@ import (
"testing"
"time"
"github.com/pilosa/pilosa/datadog"
"github.com/pilosa/pilosa/statsd"
)
func TestStatsClient_WithTags(t *testing.T) {
// Create a new client.
c, err := datadog.NewStatsClient("localhost:19444")
c, err := statsd.NewStatsClient("localhost:19444")
if err != nil {
t.Fatal(err)
}
@ -47,7 +47,7 @@ func TestStatsClient_WithTags(t *testing.T) {
func TestStatsClient_Methods(t *testing.T) {
// Create a new client.
c, err := datadog.NewStatsClient("localhost:19444")
c, err := statsd.NewStatsClient("localhost:19444")
if err != nil {
t.Fatal(err)
}