Fix symbol name conflict
This commit is contained in:
parent
f45df5d422
commit
d25207923c
1 changed files with 5 additions and 5 deletions
|
@ -47,7 +47,7 @@ const textContentType = 'text/plain; charset=utf-8'
|
||||||
const prometheusSpecVersion = '0.0.4'
|
const prometheusSpecVersion = '0.0.4'
|
||||||
const metricsContentType = `${textContentType}; version=${prometheusSpecVersion}`
|
const metricsContentType = `${textContentType}; version=${prometheusSpecVersion}`
|
||||||
|
|
||||||
function headers(contentType: string, headers: Record<string, string> = {}): Record<string, string> {
|
function withHeaders(contentType: string, headers: Record<string, string> = {}): Record<string, string> {
|
||||||
return { ...headers, 'Content-Type': contentType }
|
return { ...headers, 'Content-Type': contentType }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ export class PrometheusServer implements HttpServer {
|
||||||
if (!this.metricsDiscovered) {
|
if (!this.metricsDiscovered) {
|
||||||
return {
|
return {
|
||||||
statusCode: 503,
|
statusCode: 503,
|
||||||
headers: headers(textContentType, { 'Retry-After': String(retryAfterWhileDiscovery) }),
|
headers: withHeaders(textContentType, { 'Retry-After': String(retryAfterWhileDiscovery) }),
|
||||||
body: 'Metrics discovery pending',
|
body: 'Metrics discovery pending',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ export class PrometheusServer implements HttpServer {
|
||||||
onMetrics(): HttpResponse {
|
onMetrics(): HttpResponse {
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
headers: headers(metricsContentType),
|
headers: withHeaders(metricsContentType),
|
||||||
body: this.metricsResponse,
|
body: this.metricsResponse,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ export class PrometheusServer implements HttpServer {
|
||||||
onNotFound(): HttpResponse {
|
onNotFound(): HttpResponse {
|
||||||
return {
|
return {
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
headers: headers(textContentType),
|
headers: withHeaders(textContentType),
|
||||||
body: 'Not found. Try /metrics',
|
body: 'Not found. Try /metrics',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ export class PrometheusServer implements HttpServer {
|
||||||
onError(error: Error): HttpResponse {
|
onError(error: Error): HttpResponse {
|
||||||
this.log?.error('HTTP request error: %o', error)
|
this.log?.error('HTTP request error: %o', error)
|
||||||
return {
|
return {
|
||||||
headers: headers(textContentType),
|
headers: withHeaders(textContentType),
|
||||||
body: error.message,
|
body: error.message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue