示例#1
0
func (r *reporter) reportMeter(name string, val metrics.Meter) {
	r.reportMetric(fmt.Sprintf("%s.count", name), Int, val.Count())
	r.reportMetric(fmt.Sprintf("%s.one-minute", name), Double, val.Rate1())
	r.reportMetric(fmt.Sprintf("%s.five-minute", name), Double, val.Rate5())
	r.reportMetric(fmt.Sprintf("%s.fifteen-minute", name), Double, val.Rate15())
	r.reportMetric(fmt.Sprintf("%s.mean", name), Double, val.RateMean())
}
示例#2
0
func dumpMeter(name string, metric gometrics.Meter) {
	m := metric.Snapshot()
	logger.WithFields(logrus.Fields{
		"name":                name,
		"count":               m.Count(),
		"rate-one-minute":     m.Rate1(),
		"rate-five-minute":    m.Rate5(),
		"rate-fifteen-minute": m.Rate15(),
		"rate-mean":           m.RateMean(),
	}).Info()
}
func (hm *HttpMetrics) markSingleCode(statusCode int) {
	// TOOD(pquerna): profile to see if this is horrible
	hm.rcmutex.Lock()
	defer hm.rcmutex.Unlock()
	var meter gmetrics.Meter

	meter, ok := hm.ResponseCodes[statusCode]

	if !ok {
		hm.ResponseCodes[statusCode] = gmetrics.NewMeter()
		meter = hm.ResponseCodes[statusCode]
		gmetrics.Register(fmt.Sprintf("%s.http.status.%d", hm.prefix, statusCode), meter)
	}

	meter.Mark(1)
}
示例#4
0
func updateMeter(meter gmetrics.Meter, newValue uint64) {
	va := int64(newValue) - meter.Count()
	meter.Mark(int64(va))
}
示例#5
0
// AddMeterMetric Adds various metrics based on a Meter, according to the supplied
// MetricConfig
func AddMeterMetric(plugin *newrelic.Plugin, meter metrics.Meter, config MetricConfig) {
	if config.Count {
		plugin.AddMetric(newrelic.NewMetric(config.Name+"/Totals/Count", config.Unit, func() (float64, error) { return float64(meter.Snapshot().Count()), nil }))
	}
	if config.Rate1 {
		plugin.AddMetric(newrelic.NewMetric(config.Name+"/Rate/1 Min. Rate", config.Unit+"/second", func() (float64, error) { return meter.Snapshot().Rate1(), nil }))
	}
	if config.Rate5 {
		plugin.AddMetric(newrelic.NewMetric(config.Name+"/Rate/5 Min. Rate", config.Unit+"/second", func() (float64, error) { return meter.Snapshot().Rate5(), nil }))
	}
	if config.Rate15 {
		plugin.AddMetric(newrelic.NewMetric(config.Name+"/Rate/15 Min. Rate", config.Unit+"/second", func() (float64, error) { return meter.Snapshot().Rate15(), nil }))
	}
	if config.RateMean {
		plugin.AddMetric(newrelic.NewMetric(config.Name+"/Rate/Mean Rate", config.Unit+"/second", func() (float64, error) { return meter.Snapshot().RateMean(), nil }))
	}
}