Commit e846b922 authored by ale's avatar ale
Browse files

add a hostname prefix to all statsd metrics

parent 135d2fc6
autoradio (0.3.2p1) unstable; urgency=medium
* Instrumentation fix.
-- ale <ale@incal.net> Thu, 09 Oct 2014 08:45:50 +0100
autoradio (0.3.2) unstable; urgency=medium
* Add statsd instrumentation.
......
......@@ -2,7 +2,9 @@ package instrumentation
import (
"flag"
"fmt"
"log"
"os"
"sync"
"github.com/cactus/go-statsd-client/statsd"
......@@ -15,11 +17,21 @@ var (
clientInit sync.Once
client *statsd.Client
prefix string
)
func init() {
hostname, err := os.Hostname()
if err != nil {
log.Fatal("Could not determine hostname: %v", err)
}
prefix = fmt.Sprintf("autoradio.%s.", hostname)
}
func getClient() *statsd.Client {
clientInit.Do(func() {
c, err := statsd.New(*statsdServer, "autoradio.")
c, err := statsd.New(*statsdServer, prefix)
if err != nil {
log.Fatal("Error initializing instrumentation: %v", err)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment