upgrade prom-client to v6, add options: includeMethod, includePath, keepDefaultMetrics, bump 1.2.0

This commit is contained in:
Konstantin Pogorelov
2016-11-26 21:00:58 +01:00
parent 3675c516a9
commit 08d98b450c
9 changed files with 153 additions and 43 deletions

View File

@@ -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",

View File

@@ -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
View 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");
});
});