Skip to content
Snippets Groups Projects
Commit e846b922 authored by ale's avatar ale
Browse files

add a hostname prefix to all statsd metrics

parent 135d2fc6
No related branches found
No related tags found
No related merge requests found
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 autoradio (0.3.2) unstable; urgency=medium
* Add statsd instrumentation. * Add statsd instrumentation.
......
...@@ -2,7 +2,9 @@ package instrumentation ...@@ -2,7 +2,9 @@ package instrumentation
import ( import (
"flag" "flag"
"fmt"
"log" "log"
"os"
"sync" "sync"
"github.com/cactus/go-statsd-client/statsd" "github.com/cactus/go-statsd-client/statsd"
...@@ -15,11 +17,21 @@ var ( ...@@ -15,11 +17,21 @@ var (
clientInit sync.Once clientInit sync.Once
client *statsd.Client 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 { func getClient() *statsd.Client {
clientInit.Do(func() { clientInit.Do(func() {
c, err := statsd.New(*statsdServer, "autoradio.") c, err := statsd.New(*statsdServer, prefix)
if err != nil { if err != nil {
log.Fatal("Error initializing instrumentation: %v", err) log.Fatal("Error initializing instrumentation: %v", err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment