Compare commits
5 Commits
developmen
...
w/upgrade-
Author | SHA1 | Date |
---|---|---|
Naren | 30e03aa0f4 | |
Naren | 662c891b88 | |
Naren | 5c71ce1f93 | |
Naren | 38786a959b | |
Naren | c01d26b55e |
|
@ -1,26 +1,19 @@
|
|||
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) {
|
||||
static createCounter(params: promClient.CounterConfiguration<string>) {
|
||||
return new promClient.Counter(params);
|
||||
}
|
||||
|
||||
static createGauge(params: promClient.GaugeConfiguration) {
|
||||
static createGauge(params: promClient.GaugeConfiguration<string>) {
|
||||
return new promClient.Gauge(params);
|
||||
}
|
||||
|
||||
static createHistogram(params: promClient.HistogramConfiguration) {
|
||||
static createHistogram(params: promClient.HistogramConfiguration<string>) {
|
||||
return new promClient.Histogram(params);
|
||||
}
|
||||
|
||||
static createSummary(params: promClient.SummaryConfiguration) {
|
||||
static createSummary(params: promClient.SummaryConfiguration<string>) {
|
||||
return new promClient.Summary(params);
|
||||
}
|
||||
|
||||
|
@ -28,11 +21,15 @@ export default class ZenkoMetrics {
|
|||
return promClient.register.getSingleMetric(name);
|
||||
}
|
||||
|
||||
static asPrometheus() {
|
||||
static async asPrometheus() {
|
||||
return promClient.register.metrics();
|
||||
}
|
||||
|
||||
static asPrometheusContentType() {
|
||||
return promClient.register.contentType;
|
||||
}
|
||||
|
||||
static collectDefaultMetrics() {
|
||||
promClient.collectDefaultMetrics();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
"level-sublevel": "~6.6.5",
|
||||
"mongodb": "^3.0.1",
|
||||
"node-forge": "^0.7.1",
|
||||
"prom-client": "10.2.3",
|
||||
"prom-client": "14.2.0",
|
||||
"simple-glob": "^0.2",
|
||||
"socket.io": "~2.3.0",
|
||||
"socket.io-client": "~2.3.0",
|
||||
|
|
|
@ -65,7 +65,7 @@ describe('ZenkoMetrics', () => {
|
|||
assert.strictEqual(ZenkoMetrics.getMetric('does_not_exist'), undefined);
|
||||
});
|
||||
|
||||
it('should export metrics in prometheus format', () => {
|
||||
it('should export metrics in prometheus format', async () => {
|
||||
const expectedLines = [
|
||||
'# HELP gizmo_counter Count gizmos',
|
||||
'# TYPE gizmo_counter counter',
|
||||
|
@ -94,8 +94,9 @@ describe('ZenkoMetrics', () => {
|
|||
'pet_counter{type="puppy"} 2',
|
||||
];
|
||||
const lines = {};
|
||||
ZenkoMetrics.asPrometheus().split('\n').forEach(line => {
|
||||
lines[line.trimRight()] = true;
|
||||
const metrics = await ZenkoMetrics.asPrometheus();
|
||||
metrics.split('\n').forEach(line => {
|
||||
lines[line.trimEnd()] = true;
|
||||
});
|
||||
expectedLines.forEach(expectedLine => {
|
||||
assert.notStrictEqual(
|
||||
|
|
|
@ -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@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==
|
||||
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==
|
||||
dependencies:
|
||||
tdigest "^0.1.1"
|
||||
|
||||
|
|
Loading…
Reference in New Issue