agent/metrics/metrics_engine.go
func (engine *MetricsEngine) recordGenericMetric(apiType APIType, callName string) func() {
	callStarted := make(chan bool, 1)
	if engine == nil || !engine.collection {
		return func() {
		}
	}
	callID := engine.recordMetric(apiType, callName, "", callStarted)
	return func() {
		engine.recordMetric(apiType, callName, callID, callStarted)
	}
}
func (engine *MetricsEngine) recordGenericMetric(apiType APIType, callName string) func() {
	callStarted := make(chan bool, 1)
	if engine == nil || !engine.collection {
		return func() {
		}
	}
	callID := engine.recordMetric(apiType, callName, "", callStarted)
	return func() {
		engine.recordMetric(apiType, callName, callID, callStarted)
	}
}
// Records a call's start and returns a function to be deferred.
// Wrapper functions will use this function for GenericMetricsClients.
// If Metrics collection is enabled from the cfg, we record a metric with callID
// as an empty string (signaling a call start), and then return a function to
// record a second metric with a non-empty callID.
// We use a channel holding 1 bool to ensure that the FireCallEnd is called AFTER
// the FireCallStart (because these are done in separate go routines)
// Recording a metric in an API needs only a wrapper function that supplies the
// APIType and called using the following format:
// defer metrics.MetricsEngineGlobal.RecordMetricWrapper(callName)()