(threshold)
| 1195 | } |
| 1196 | |
| 1197 | function humanizeThreshold(threshold) { |
| 1198 | const metricName = threshold.metric || ""; |
| 1199 | const rawLabel = threshold.label || ""; |
| 1200 | const rule = rawLabel.startsWith(`${metricName} `) ? rawLabel.slice(metricName.length + 1) : rawLabel; |
| 1201 | const { baseMetric, tags } = parseMetricName(metricName); |
| 1202 | const metricLabel = humanizeMetricName(baseMetric); |
| 1203 | const ruleLabel = humanizeThresholdRule(rule, baseMetric); |
| 1204 | const tagLabel = humanizeMetricTags(tags); |
| 1205 | const cleanedRule = |
| 1206 | metricLabel.toLowerCase().endsWith("rate") && ruleLabel.startsWith("Rate ") |
| 1207 | ? ruleLabel.slice(5) |
| 1208 | : ruleLabel; |
| 1209 | return [metricLabel, cleanedRule, tagLabel ? `(${tagLabel})` : ""].filter(Boolean).join(" "); |
| 1210 | } |
| 1211 | |
| 1212 | function parseMetricName(metricName) { |
| 1213 | const match = metricName.match(/^([^{}]+)(?:\{([^}]+)\})?$/); |
no test coverage detected