MCPcopy Create free account
hub / github.com/deepflowio/deepflow / GetDebugCache

Function GetDebugCache

server/controller/prometheus/cache/cache.go:116–212  ·  view source on GitHub ↗
(t controller.PrometheusCacheType)

Source from the content-addressed store, hash-verified

114}
115
116func GetDebugCache(t controller.PrometheusCacheType) []byte {
117 tempCache, _ := GetCache(1) // TODO add org_id
118 content := make(map[string]interface{})
119
120 marshal := func(v any) string {
121 b, err := json.Marshal(v)
122 if err != nil {
123 log.Error(err)
124 }
125 return string(b)
126 }
127 getMetricName := func() {
128 temp := map[string]interface{}{
129 "name_to_id": make(map[string]interface{}),
130 }
131 for k, v := range tempCache.MetricName.GetNameToID() {
132 temp["name_to_id"].(map[string]interface{})[k] = v
133 }
134 if len(temp["name_to_id"].(map[string]interface{})) > 0 {
135 content["metric_name"] = temp
136 }
137 }
138 getLabelName := func() {
139 temp := map[string]interface{}{
140 "name_to_id": make(map[string]interface{}),
141 }
142 for k, v := range tempCache.LabelName.GetNameToID() {
143 temp["name_to_id"].(map[string]interface{})[k] = v
144 }
145 if len(temp["name_to_id"].(map[string]interface{})) > 0 {
146 content["label_name"] = temp
147 }
148 }
149 getLabelValue := func() {
150 temp := map[string]interface{}{
151 "value_to_id": make(map[string]interface{}),
152 }
153
154 for key, value := range tempCache.LabelValue.GetValueToID() {
155 temp["value_to_id"].(map[string]interface{})[key] = value
156 }
157
158 if len(temp["value_to_id"].(map[string]interface{})) > 0 {
159 content["label_value"] = temp
160 }
161 }
162 getMetricAndAppLabelLayout := func() {
163 temp := map[string]interface{}{
164 "layout_key_to_index": make(map[string]interface{}),
165 }
166 for k, v := range tempCache.MetricAndAPPLabelLayout.GetLayoutKeyToIndex() {
167 temp["layout_key_to_index"].(map[string]interface{})[marshal(k)] = v
168 }
169 if len(temp["layout_key_to_index"].(map[string]interface{})) > 0 {
170 content["metric_and_app_label_layout"] = temp
171 }
172 }
173 getLabel := func() {

Callers

nothing calls this directly

Calls 9

GetValueToIDMethod · 0.80
GetLayoutKeyToIndexMethod · 0.80
GetKeyToIDMethod · 0.80
GetCacheFunction · 0.70
ErrorMethod · 0.65
StringMethod · 0.65
MarshalMethod · 0.45
GetNameToIDMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected