Compare commits

..

No commits in common. "30e03aa0f428a7a48a5bd94eed22891c32c34dd5" and "acd13ff31b92b3d9469e8625c9a9f671d06a1ec2" have entirely different histories.

4 changed files with 20 additions and 18 deletions

View File

@ -1,19 +1,26 @@
import promClient from 'prom-client';
const collectDefaultMetricsIntervalMs =
process.env.COLLECT_DEFAULT_METRICS_INTERVAL_MS !== undefined ?
Number.parseInt(process.env.COLLECT_DEFAULT_METRICS_INTERVAL_MS, 10) :
10000;
promClient.collectDefaultMetrics({ timeout: collectDefaultMetricsIntervalMs });
export default class ZenkoMetrics {
static createCounter(params: promClient.CounterConfiguration<string>) {
static createCounter(params: promClient.CounterConfiguration) {
return new promClient.Counter(params);
}
static createGauge(params: promClient.GaugeConfiguration<string>) {
static createGauge(params: promClient.GaugeConfiguration) {
return new promClient.Gauge(params);
}
static createHistogram(params: promClient.HistogramConfiguration<string>) {
static createHistogram(params: promClient.HistogramConfiguration) {
return new promClient.Histogram(params);
}
static createSummary(params: promClient.SummaryConfiguration<string>) {
static createSummary(params: promClient.SummaryConfiguration) {
return new promClient.Summary(params);
}
@ -21,15 +28,11 @@ export default class ZenkoMetrics {
return promClient.register.getSingleMetric(name);
}
static async asPrometheus() {
static asPrometheus() {
return promClient.register.metrics();
}
static asPrometheusContentType() {
return promClient.register.contentType;
}
static collectDefaultMetrics() {
promClient.collectDefaultMetrics();
}
}

View File

@ -41,7 +41,7 @@
"level-sublevel": "~6.6.5",
"mongodb": "^3.0.1",
"node-forge": "^0.7.1",
"prom-client": "14.2.0",
"prom-client": "10.2.3",
"simple-glob": "^0.2",
"socket.io": "~2.3.0",
"socket.io-client": "~2.3.0",

View File

@ -65,7 +65,7 @@ describe('ZenkoMetrics', () => {
assert.strictEqual(ZenkoMetrics.getMetric('does_not_exist'), undefined);
});
it('should export metrics in prometheus format', async () => {
it('should export metrics in prometheus format', () => {
const expectedLines = [
'# HELP gizmo_counter Count gizmos',
'# TYPE gizmo_counter counter',
@ -94,9 +94,8 @@ describe('ZenkoMetrics', () => {
'pet_counter{type="puppy"} 2',
];
const lines = {};
const metrics = await ZenkoMetrics.asPrometheus();
metrics.split('\n').forEach(line => {
lines[line.trimEnd()] = true;
ZenkoMetrics.asPrometheus().split('\n').forEach(line => {
lines[line.trimRight()] = true;
});
expectedLines.forEach(expectedLine => {
assert.notStrictEqual(

View File

@ -5384,10 +5384,10 @@ process-nextick-args@~2.0.0:
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
prom-client@14.2.0:
version "14.2.0"
resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-14.2.0.tgz#ca94504e64156f6506574c25fb1c34df7812cf11"
integrity sha512-sF308EhTenb/pDRPakm+WgiN+VdM/T1RaHj1x+MvAuT8UiQP8JmOEbxVqtkbfR4LrvOg5n7ic01kRBDGXjYikA==
prom-client@10.2.3:
version "10.2.3"
resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-10.2.3.tgz#a51bf21c239c954a6c5be4b1361fdd380218bb41"
integrity sha512-Xboq5+TdUwuQtSSDRZRNnb5NprINlgQN999VqUjZxnLKydUNLeIPx6Eiahg6oJua3XBg2TGnh5Cth1s4I6+r7g==
dependencies:
tdigest "^0.1.1"