Extract stringReverse() function

This commit is contained in:
Lars Strojny 2022-11-24 19:24:00 +01:00
parent ccca32d7b2
commit 565f423dd9
No known key found for this signature in database
GPG key ID: 887416A2AD3B0CA9

View file

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