* Parse a Prometheus label string into key-value pairs. * * @param {string} str - e.g. 'method="GET",status="200"' * @returns {Labels}
(str)
| 276 | * @returns {Labels} |
| 277 | */ |
| 278 | function parseLabels(str) { |
| 279 | /** @type {Labels} */ |
| 280 | const labels = {}; |
| 281 | if (!str) return labels; |
| 282 | const re = /(\w+)="([^"]*)"/g; |
| 283 | for (const m of str.matchAll(re)) { |
| 284 | labels[m[1]] = m[2]; |
| 285 | } |
| 286 | return labels; |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Extract the grouping prefix from a metric name. |
no outgoing calls
no test coverage detected