func (m *metrics) fetchMetrics(serviceName string, ctx context.Context) (system.Result, error) {
	result, err := m.genClients[serviceName].FetchMetrics(ctx)
	if err != nil {
		return nil, err
	}

	var s telemetry.SystemUsage
	if err := json.NewDecoder(bytes.NewBuffer([]byte(result))).Decode(&s); err != nil {
		return nil, fmt.Errorf("error decoding telemetry.SystemUsage: %s", err.Error())
	}

	return system.MetricsSuccess(serviceName, ExecutorType, s.CpuBusyAvg, int64(s.Memory.Sys), []byte(result)), nil
}
// fetchMetrics provides a common implementation to gather metrics from a service defined in genClients,
// transform and normalize the cpuUsedPercent and memoryUsed fields provided by every executor (along with the raw
// result returned by the service), and return a corresponding MetricsSuccessResult.
fetchMetrics provides a common implementation to gather metrics from a service defined in genClients,
transform and normalize the cpuUsedPercent and memoryUsed fields provided by every executor (along with the raw
result returned by the service), and return a corresponding MetricsSuccessResult.
// fetchMetrics provides a common implementation to gather metrics from a service defined in genClients // transform and normalize the cpuUsedPercent and memoryUsed fields provided by every executor ( along with the raw // result returned by the service ) and return a corresponding MetricsSuccessResult .
func (m *metrics) fetchMetrics(serviceName string, ctx context.Context) (system.Result, error) {
	result, err := m.genClients[serviceName].FetchMetrics(ctx)
	if err != nil {
		return nil, err
	}
	var s telemetry.SystemUsage
	if err := json.NewDecoder(bytes.NewBuffer([]byte(result))).Decode(&s); err != nil {
		return nil, fmt.Errorf("error decoding telemetry.SystemUsage: %s", err.Error())
	}
	return system.MetricsSuccess(serviceName, ExecutorType, s.CpuBusyAvg, int64(s.Memory.Sys), []byte(result)), nil
}
func ( m * metrics ) fetchMetrics ( serviceName string , ctx context . Context ) ( system . Result , error ) { result , err := m . genClients [ serviceName ] . FetchMetrics ( ctx ) if err != nil { return nil , err } var s telemetry . SystemUsage if err := json . NewDecoder ( bytes . NewBuffer ( [ ] byte ( result ) ) ) . Decode ( & s ) ; err != nil { return nil , fmt . Errorf ( " " , err . Error ( ) ) } return system . MetricsSuccess ( serviceName , ExecutorType , s . CpuBusyAvg , int64 ( s . Memory . Sys ) , [ ] byte ( result ) ) , nil }
fetchMetrics provides a common implementation to gather metrics from a service defined in genClients,
transform and normalize the cpuUsedPercent and memoryUsed fields provided by every executor (along with the raw
result returned by the service), and return a corresponding MetricsSuccessResult.
fetchMetrics provides a common implementation to gather metrics from a service defined in genClients transform and normalize the cpuUsedPercent and memoryUsed fields provided by every executor ( along with the raw result returned by the service ) and return a corresponding MetricsSuccessResult .