MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / processRuntimeStats

Method processRuntimeStats

pkg/controller/task.go:294–313  ·  view source on GitHub ↗
(rt *rtctrl.RuntimeInfo, logger *logs.Logger)

Source from the content-addressed store, hash-verified

292}
293
294func (controller *Controller) processRuntimeStats(rt *rtctrl.RuntimeInfo, logger *logs.Logger) {
295 input := api.FuncletClientContainerInfoInput{
296 RequestID: id.GetRequestID(),
297 ID: rt.RuntimeID,
298 }
299 info, err := controller.FuncletClient.Info(&input)
300 if err != nil {
301 logger.Errorf("get runtime %s info from funclet failed: %s", rt.RuntimeID, err)
302 return
303 }
304 if info.ResourceStats == nil || info.ResourceStats.CPUStats == nil || info.ResourceStats.MemoryStats == nil {
305 logger.Warnf("get runtime %s info from funclet failed: resource stats is nil", rt.RuntimeID)
306 return
307 }
308 value := metric.GetCounterValue(RuntimeMetricName(RuntimeCPUUsageSeconds), info.ContainerID)
309 inc := (float64(info.ResourceStats.CPUStats.TotalUsage) - value) / float64(time.Second)
310 metric.AddWithLabels(RuntimeMetricName(RuntimeCPUUsageSeconds), inc, getResourceLabels(info.ContainerID))
311 metric.SetGaugeWithLabels(RuntimeMetricName(RuntimeMemoryUsageBytes), float64(info.ResourceStats.MemoryStats.Usage), getResourceLabels(info.ContainerID))
312 return
313}
314
315func getResourceLabels(ID string) *prometheus.Labels {
316 labels := prometheus.Labels{}

Callers 1

runtimeMetricsMethod · 0.95

Calls 9

GetRequestIDFunction · 0.92
GetCounterValueFunction · 0.92
AddWithLabelsFunction · 0.92
SetGaugeWithLabelsFunction · 0.92
RuntimeMetricNameFunction · 0.85
getResourceLabelsFunction · 0.85
ErrorfMethod · 0.80
WarnfMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected