diff --git a/src/prometheus.ts b/src/prometheus.ts index 94790c7..60d9d6c 100644 --- a/src/prometheus.ts +++ b/src/prometheus.ts @@ -26,12 +26,14 @@ export class MetricsRenderer { private metricName(name: string): string { name = name.replace(/^(.*_)?(total)_(.*)$/, '$1$3_$2') - return sanitizePrometheusMetricName( - this.prefix.split('').reverse().join('').replace(/^_+/, '').split('').reverse().join('') + '_' + name, - ) + return sanitizePrometheusMetricName(stringReverse(stringReverse(this.prefix).replace(/^_+/, '')) + '_' + name) } } +function stringReverse(str: string): string { + return str.split('').reverse().join('') +} + const retryAfterWhileDiscovery = 15 const textContentType = 'text/plain; charset=utf-8' const prometheusSpecVersion = '0.0.4'