package containers import ( "encoding/json" "fmt" "github.com/coroot/coroot-node-agent/utils" "github.com/coroot/coroot-node-agent/utils/modelse" "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" "os" "path" ) const ( Namespace = "namespace" PodName = "pod_name" Workload = "workload" ProcessName = "process_name" ) func setLabels(container_id, ns, pod_name, process_name, pid string) prometheus.Labels { return map[string]string{ "container_id": container_id, "ns": ns, "pod_name": pod_name, "process_name": process_name, "pid": pid, } } func setK8sTag(c *Container, tag map[string]string, pid uint32) { sPid := fmt.Sprintf("%d", pid) c.K8sContainer.ns = tag[Namespace] c.K8sContainer.podName = tag[PodName] c.K8sContainer.containerName = tag[ProcessName] c.K8sContainer.pid = sPid } func saveAppInfo(runtimeApps map[uint32]modelse.AppStatusInfo) { appStr, _ := json.Marshal(runtimeApps) dumpPath := path.Join(utils.GetDefaultLogPath(), "memdump") err := os.MkdirAll(dumpPath, 0755) if err != nil { logrus.Error(err) } fileName := fmt.Sprintf("%s.snap", "app") metricsFileName := path.Join(dumpPath, fileName) err = os.WriteFile(metricsFileName, appStr, 0644) if err != nil { logrus.Error(err) } }