mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-03-18 21:30:38 +01:00
When trying to register a second instance with the same name, then just take the old one. Upgrade prom-client to 6.2.x. Bump 1.2.3
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "express-prom-bundle",
|
||||
"version": "1.2.2",
|
||||
"version": "1.2.3",
|
||||
"description": "express middleware with popular prometheus metrics in one bundle",
|
||||
"main": "src/index.js",
|
||||
"keywords": [
|
||||
@@ -16,7 +16,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"on-finished": "^2.3.0",
|
||||
"prom-client": "^6.1.2",
|
||||
"prom-client": "^6.2.0",
|
||||
"url-value-parser": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -49,5 +49,17 @@ describe("PromFactory", () => {
|
||||
expect(metric.help).toBe("help for test4");
|
||||
expect(metric.percentiles).toEqual([0.1, 0.5]);
|
||||
});
|
||||
|
||||
it("when regsitered with same name, just return old instance", () => {
|
||||
const metric1 = factory.newSummary(
|
||||
"test4",
|
||||
"help for test4",
|
||||
{percentiles: [0.1, 0.5]}
|
||||
);
|
||||
const metric2 = factory.newSummary(
|
||||
"test4",
|
||||
"help for test4",
|
||||
{percentiles: [0.1, 0.5]}
|
||||
);
|
||||
expect(metric1).toBe(metric2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,12 @@ module.exports = class {
|
||||
const applyParams = Array.prototype.slice.call(args);
|
||||
const name = applyParams[0];
|
||||
const realName = this.makeRealName(name);
|
||||
|
||||
const existing = this.promClient.register.getSingleMetric(realName);
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
applyParams[0] = realName;
|
||||
applyParams.unshift(null); // add some dummy context for apply
|
||||
|
||||
|
||||
Reference in New Issue
Block a user