Beispiel #1
0
func logCountMetric(m *metrics.DogStatsD, name, funcName string, value int64) {
	if err := m.Count(
		name,  // metric name
		value, // count
		[]string{"funcName:" + funcName}, // tags for metric call
		1.0, // rate
	); err != nil {
		// TODO(cihangir) should we log/return error?
	}
}
Beispiel #2
0
func logGaugeMetric(m *metrics.DogStatsD, name, funcName string, value float64) {
	if err := m.Gauge(
		name,  // metric name
		value, // count
		// using funcName: for consistency with callCount
		[]string{"funcName:" + funcName},
		1.0, // rate
	); err != nil {
		// TODO(cihangir) should we log/return error?
	}
}
Beispiel #3
0
func createTracker(metrics *metrics.DogStatsD) kite.HandlerFunc {
	return func(r *kite.Request) (interface{}, error) {
		// if metrics not set, act as noop
		if metrics == nil {
			return true, nil
		}

		if err := metrics.Count(
			"callCount", // metric name
			1,           // count
			[]string{"funcName:" + r.Method}, // tags for metric call
			1.0, // rate
		); err != nil {
			// TODO(cihangir) should we log/return error?
		}

		return true, nil
	}
}