Move exposition content type to its own var

Remove anti-pattern of setting properties on Function object that is
difficult to document.
This commit is contained in:
Hornwitser committed 2023-11-19 04:50:07 +01:00
1 parent 80e1904175
commit b66138587b
2 files changed
+6 -5

No files matched your search

+1 -1
View File
@@ -95,7 +95,7 @@ async function getMetrics(req: Request, res: Response, next: any) {
// Should wrap results into a Generator functions ?
// @ts-ignore
let text = await lib.exposition(results);
res.set("Content-Type", lib.exposition.contentType);
res.set("Content-Type", lib.expositionContentType);
res.send(text);
}
+5 -4
View File
@@ -1664,9 +1664,6 @@ async function* expositionLines(resultsIterator: AsyncIterable<CollectorResult>)
* exposition for. Defaults to collecting results from {@link
* defaultRegistry}.
* @returns Prometheus exposition.
*
* @property exposition.contentType
* HTTP Content-Type for the exposition format that's implemented
*/
export async function exposition(resultsIterator = defaultRegistry.collect()) {
let lines = "";
@@ -1675,7 +1672,11 @@ export async function exposition(resultsIterator = defaultRegistry.collect()) {
}
return lines;
}
exposition.contentType = "text/plain; version=0.0.4";
/**
* HTTP Content-Type for the exposition format that's implemented by {@link
* exposition}.
*/
export const expositionContentType = "text/plain; version=0.0.4";
/**
* Serialize CollectorResult into a plain object