(rt *rtctrl.RuntimeInfo, logger *logs.Logger)
| 292 | } |
| 293 | |
| 294 | func (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 | |
| 315 | func getResourceLabels(ID string) *prometheus.Labels { |
| 316 | labels := prometheus.Labels{} |
no test coverage detected