(t controller.PrometheusCacheType)
| 114 | } |
| 115 | |
| 116 | func 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() { |
nothing calls this directly
no test coverage detected