Last active
September 15, 2016 16:40
-
-
Save raphael/fe330a218ff8f3840ccdcc9eea925834 to your computer and use it in GitHub Desktop.
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
// metriks is the local instance of metrics.Metrics | |
var metriks *metrics.Metrics | |
// lock synchronizes access to the metrics sink | |
var lock = sync.RWMutex{} | |
// NewMetrics initializes goa's metrics instance with the supplied | |
// configuration and metrics sink | |
func SetMetrics(m metrics.Metrics) { | |
lock.Lock() | |
defer lock.Unlock() | |
metriks = m | |
} | |
// AddSample adds a sample to an aggregated metric | |
// reporting count, min, max, mean, and std deviation | |
// Usage: | |
// AddSample([]string{"my","namespace","key"}, 15.0) | |
func AddSample(key []string, val float32) { | |
lock.RLock() | |
defer lock.RUnlock() | |
if metriks != nil { | |
metriks.AddSample(key, val) | |
} | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment