mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-01-18 16:27:28 +01:00
upgrade prom-client to v6, add options: includeMethod, includePath, keepDefaultMetrics, bump 1.2.0
This commit is contained in:
@@ -17,10 +17,6 @@ describe("PromFactory", () => {
|
||||
expect(metric.help).toBe("help for test1");
|
||||
expect(metric.labelNames).toEqual(["label1", "label2"]);
|
||||
});
|
||||
it("throws on duplicate names", () => {
|
||||
factory.newCounter("n","h");
|
||||
expect(() => factory.newCounter("n","h2")).toThrow();
|
||||
});
|
||||
it("creates Gauge", () => {
|
||||
const metric = factory.newGauge(
|
||||
"test2",
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
"use strict";
|
||||
/* eslint-env jasmine */
|
||||
|
||||
let express = require("express"),
|
||||
supertest = require("supertest"),
|
||||
bundle = require("../"),
|
||||
koa = require("koa"),
|
||||
c2k = require("koa-connect"),
|
||||
supertestKoa = require("supertest-koa-agent");
|
||||
const express = require("express");
|
||||
const supertest = require("supertest");
|
||||
const bundle = require("../");
|
||||
const koa = require("koa");
|
||||
const c2k = require("koa-connect");
|
||||
const supertestKoa = require("supertest-koa-agent");
|
||||
const promClient = require("prom-client");
|
||||
|
||||
describe("index", () => {
|
||||
beforeEach(() => {
|
||||
promClient.register.clear();
|
||||
});
|
||||
|
||||
it("metrics returns up=1", done => {
|
||||
const app = express();
|
||||
const bundled = bundle({
|
||||
@@ -141,6 +146,28 @@ describe("index", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("tolerates includePath, includeMethod and keepDefaultMetrics", done => {
|
||||
const app = express();
|
||||
const instance = bundle({
|
||||
includePath: true,
|
||||
includeMethod: true,
|
||||
keepDefaultMetrics: true
|
||||
});
|
||||
app.use(instance);
|
||||
app.use("/test", (req, res) => res.send("it worked"));
|
||||
const agent = supertest(app);
|
||||
agent
|
||||
.get("/test")
|
||||
.end(() => {
|
||||
agent
|
||||
.get("/metrics")
|
||||
.end((err, res) => {
|
||||
expect(res.status).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Koa: metrics returns up=1", done => {
|
||||
const app = koa();
|
||||
const bundled = bundle({
|
||||
|
||||
28
spec/normalizePathSpec.js
Normal file
28
spec/normalizePathSpec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
/* eslint-env jasmine */
|
||||
|
||||
const normalizePath = require("../src/normalizePath");
|
||||
|
||||
describe("normalizePath", () => {
|
||||
it("returns original if disabled in opts", () => {
|
||||
expect(
|
||||
normalizePath({path: "/a/12345"}, {normalizePath: false})
|
||||
).toBe("/a/12345");
|
||||
});
|
||||
|
||||
it("returns run callback if configured", () => {
|
||||
expect(
|
||||
normalizePath(
|
||||
{path: "/a/12345"},
|
||||
{
|
||||
normalizePath: req => req.path + "-ok"
|
||||
}
|
||||
)
|
||||
).toBe("/a/12345-ok");
|
||||
});
|
||||
|
||||
it("uses UrlValueParser by default", () => {
|
||||
expect(normalizePath({path: "/a/12345"}))
|
||||
.toBe("/a/#val");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user