Skip to content

Commit

Permalink
chore: use trailing commas (siimon#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Mar 29, 2020
1 parent 9b2af56 commit 6151462
Show file tree
Hide file tree
Showing 55 changed files with 387 additions and 388 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Counters go up, and reset when the process restarts.
const client = require('prom-client');
const counter = new client.Counter({
name: 'metric_name',
help: 'metric_help'
help: 'metric_help',
});
counter.inc(); // Inc with 1
counter.inc(10); // Inc with 10
Expand All @@ -136,7 +136,7 @@ There are some utilities for common use cases:
gauge.setToCurrentTime(); // Sets value to current time

const end = gauge.startTimer();
xhrRequest(function(err, res) {
xhrRequest(function (err, res) {
end(); // Sets value to xhrRequests duration in seconds
});
```
Expand All @@ -155,7 +155,7 @@ const client = require('prom-client');
new client.Histogram({
name: 'metric_name',
help: 'metric_help',
buckets: [0.1, 5, 15, 50, 100, 500]
buckets: [0.1, 5, 15, 50, 100, 500],
});
```

Expand All @@ -167,7 +167,7 @@ new client.Histogram({
name: 'metric_name',
help: 'metric_help',
labelNames: ['status_code'],
buckets: [0.1, 5, 15, 50, 100, 500]
buckets: [0.1, 5, 15, 50, 100, 500],
});
```

Expand All @@ -177,7 +177,7 @@ Examples
const client = require('prom-client');
const histogram = new client.Histogram({
name: 'metric_name',
help: 'metric_help'
help: 'metric_help',
});
histogram.observe(10); // Observe value in histogram
```
Expand All @@ -186,7 +186,7 @@ Utility to observe request durations

```js
const end = histogram.startTimer();
xhrRequest(function(err, res) {
xhrRequest(function (err, res) {
const seconds = end(); // Observes and returns the value to xhrRequests duration in seconds
});
```
Expand All @@ -205,7 +205,7 @@ const client = require('prom-client');
new client.Summary({
name: 'metric_name',
help: 'metric_help',
percentiles: [0.01, 0.1, 0.9, 0.99]
percentiles: [0.01, 0.1, 0.9, 0.99],
});
```

Expand All @@ -218,7 +218,7 @@ new client.Summary({
name: 'metric_name',
help: 'metric_help',
maxAgeSeconds: 600,
ageBuckets: 5
ageBuckets: 5,
});
```

Expand All @@ -232,7 +232,7 @@ Usage example
const client = require('prom-client');
const summary = new client.Summary({
name: 'metric_name',
help: 'metric_help'
help: 'metric_help',
});
summary.observe(10);
```
Expand All @@ -241,7 +241,7 @@ Utility to observe request durations

```js
const end = summary.startTimer();
xhrRequest(function(err, res) {
xhrRequest(function (err, res) {
end(); // Observes the value to xhrRequests duration in seconds
});
```
Expand All @@ -257,7 +257,7 @@ const client = require('prom-client');
const gauge = new client.Gauge({
name: 'metric_name',
help: 'metric_help',
labelNames: ['method', 'statusCode']
labelNames: ['method', 'statusCode'],
});

gauge.set({ method: 'GET', statusCode: '200' }, 100); // 1st version, Set value 100 with method set to GET and statusCode to 200
Expand All @@ -269,7 +269,7 @@ is created:

```js
const end = startTimer({ method: 'GET' }); // Set method to GET, we don't know statusCode yet
xhrRequest(function(err, res) {
xhrRequest(function (err, res) {
if (err) {
end({ statusCode: '500' }); // Sets value to xhrRequest duration in seconds with statusCode 500
} else {
Expand Down Expand Up @@ -321,12 +321,12 @@ const registry = new client.Registry();
const counter = new client.Counter({
name: 'metric_name',
help: 'metric_help',
registers: [registry]
registers: [registry],
});
const histogram = new client.Histogram({
name: 'metric_name',
help: 'metric_help',
registers: []
registers: [],
});
registry.registerMetric(histogram);
counter.inc();
Expand Down Expand Up @@ -404,15 +404,15 @@ It is possible to push metrics via a
const client = require('prom-client');
let gateway = new client.Pushgateway('http://127.0.0.1:9091');

gateway.pushAdd({ jobName: 'test' }, function(err, resp, body) {}); //Add metric and overwrite old ones
gateway.push({ jobName: 'test' }, function(err, resp, body) {}); //Overwrite all metrics (use PUT)
gateway.delete({ jobName: 'test' }, function(err, resp, body) {}); //Delete all metrics for jobName
gateway.pushAdd({ jobName: 'test' }, function (err, resp, body) {}); //Add metric and overwrite old ones
gateway.push({ jobName: 'test' }, function (err, resp, body) {}); //Overwrite all metrics (use PUT)
gateway.delete({ jobName: 'test' }, function (err, resp, body) {}); //Delete all metrics for jobName

//All gateway requests can have groupings on it
gateway.pushAdd({ jobName: 'test', groupings: { key: 'value' } }, function(
gateway.pushAdd({ jobName: 'test', groupings: { key: 'value' } }, function (
err,
resp,
body
body,
) {});

//It's possible to extend the Pushgateway with request options from nodes core http/https library
Expand All @@ -429,13 +429,13 @@ const client = require('prom-client');
new client.Histogram({
name: 'metric_name',
help: 'metric_help',
buckets: client.linearBuckets(0, 10, 20) //Create 20 buckets, starting on 0 and a width of 10
buckets: client.linearBuckets(0, 10, 20), //Create 20 buckets, starting on 0 and a width of 10
});

new client.Histogram({
name: 'metric_name',
help: 'metric_help',
buckets: client.exponentialBuckets(1, 2, 5) //Create 5 buckets, starting on 1 and with a factor of 2
buckets: client.exponentialBuckets(1, 2, 5), //Create 5 buckets, starting on 1 and with a factor of 2
});
```

Expand Down
22 changes: 11 additions & 11 deletions benchmarks/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,42 @@ function setupHistogramSuite(suite) {
suite.add(
'observe#1 with 64',
labelCombinationFactory([64], (client, { histogram }, labels) =>
histogram.observe(labels, 1)
histogram.observe(labels, 1),
),
{ teardown, setup: setup(1) }
{ teardown, setup: setup(1) },
);

suite.add(
'observe#2 with 8',
labelCombinationFactory([8, 8], (client, { histogram }, labels) =>
histogram.observe(labels, 1)
histogram.observe(labels, 1),
),
{ teardown, setup: setup(2) }
{ teardown, setup: setup(2) },
);

suite.add(
'observe#2 with 4 and 2 with 2',
labelCombinationFactory([4, 4, 2, 2], (client, { histogram }, labels) =>
histogram.observe(labels, 1)
histogram.observe(labels, 1),
),
{ teardown, setup: setup(4) }
{ teardown, setup: setup(4) },
);

suite.add(
'observe#2 with 2 and 2 with 4',
labelCombinationFactory([2, 2, 4, 4], (client, { histogram }, labels) =>
histogram.observe(labels, 1)
histogram.observe(labels, 1),
),
{ teardown, setup: setup(4) }
{ teardown, setup: setup(4) },
);

suite.add(
'observe#6 with 2',
labelCombinationFactory(
[2, 2, 2, 2, 2, 2],
(client, { histogram }, labels) => histogram.observe(labels, 1)
(client, { histogram }, labels) => histogram.observe(labels, 1),
),
{ teardown, setup: setup(6) }
{ teardown, setup: setup(6) },
);
}

Expand All @@ -55,7 +55,7 @@ function setup(labelCount) {
name: 'histogram',
help: 'histogram',
labelNames: getLabelNames(labelCount),
registers: [registry]
registers: [registry],
});

return { registry, histogram };
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const createRegressionBenchmark = require('@clevernature/benchmark-regression');

const currentClient = require('..');
const benchmarks = createRegressionBenchmark(currentClient, [
'prom-client@latest'
'prom-client@latest',
]);

benchmarks.suite('registry', require('./registry'));
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ function setupRegistrySuite(suite) {
{ name: '2 with 8', counts: [8, 8] },
{ name: '2 with 4 and 2 with 2', counts: [4, 4, 2, 2] },
{ name: '2 with 2 and 2 with 4', counts: [2, 2, 4, 4] },
{ name: '6 with 2', counts: [2, 2, 2, 2, 2, 2] }
{ name: '6 with 2', counts: [2, 2, 2, 2, 2, 2] },
];

labelSetups.forEach(({ name, counts }) => {
suite.add(
`getMetricsAsJSON#${name}`,
(client, registry) => registry.getMetricsAsJSON(),
{ setup: setup(counts) }
{ setup: setup(counts) },
);
});

labelSetups.forEach(({ name, counts }) => {
suite.add(`metrics#${name}`, (client, registry) => registry.metrics(), {
setup: setup(counts)
setup: setup(counts),
});
});
}
Expand All @@ -36,7 +36,7 @@ function setup(labelCounts) {
name: 'histogram',
help: 'histogram',
labelNames: getLabelNames(labelCounts.length),
registers: [registry]
registers: [registry],
});

const labelCombinations = getLabelCombinations(labelCounts);
Expand Down
22 changes: 11 additions & 11 deletions benchmarks/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@ function setupSummarySuite(suite) {
suite.add(
'observe#1 with 64',
labelCombinationFactory([64], (client, { summary }, labels) =>
summary.observe(labels, 1)
summary.observe(labels, 1),
),
{ teardown, setup: setup(1) }
{ teardown, setup: setup(1) },
);

suite.add(
'observe#2 with 8',
labelCombinationFactory([8, 8], (client, { summary }, labels) =>
summary.observe(labels, 1)
summary.observe(labels, 1),
),
{ teardown, setup: setup(2) }
{ teardown, setup: setup(2) },
);

suite.add(
'observe#2 with 4 and 2 with 2',
labelCombinationFactory([4, 4, 2, 2], (client, { summary }, labels) =>
summary.observe(labels, 1)
summary.observe(labels, 1),
),
{ teardown, setup: setup(4) }
{ teardown, setup: setup(4) },
);

suite.add(
'observe#2 with 2 and 2 with 4',
labelCombinationFactory([2, 2, 4, 4], (client, { summary }, labels) =>
summary.observe(labels, 1)
summary.observe(labels, 1),
),
{ teardown, setup: setup(4) }
{ teardown, setup: setup(4) },
);

suite.add(
'observe#6 with 2',
labelCombinationFactory([2, 2, 2, 2, 2, 2], (client, { summary }, labels) =>
summary.observe(labels, 1)
summary.observe(labels, 1),
),
{ teardown, setup: setup(6) }
{ teardown, setup: setup(6) },
);
}

Expand All @@ -54,7 +54,7 @@ function setup(labelCount) {
name: 'summary',
help: 'summary',
labelNames: getLabelNames(labelCount),
registers: [registry]
registers: [registry],
});

return { registry, summary };
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/utils/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const letters = 'abcdefghijklmnopqrstuvwxyz'.split('');
module.exports = {
getLabelNames,
getLabelCombinations,
labelCombinationFactory
labelCombinationFactory,
};

function getLabelNames(count) {
Expand All @@ -26,7 +26,7 @@ function getLabelCombinations(labelValues) {
labelNames.reduce((acc, label, i) => {
acc[label] = values[i];
return acc;
}, {})
}, {}),
);
}

Expand Down
2 changes: 1 addition & 1 deletion example/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (cluster.isMaster) {

metricsServer.listen(3001);
console.log(
'Cluster metrics server listening to 3001, metrics exposed on /cluster_metrics'
'Cluster metrics server listening to 3001, metrics exposed on /cluster_metrics',
);
} else {
require('./server.js');
Expand Down
10 changes: 5 additions & 5 deletions example/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ const Histogram = require('../').Histogram;
const h = new Histogram({
name: 'test_histogram',
help: 'Example of a histogram',
labelNames: ['code']
labelNames: ['code'],
});

const Counter = require('../').Counter;
const c = new Counter({
name: 'test_counter',
help: 'Example of a counter',
labelNames: ['code']
labelNames: ['code'],
});

const Gauge = require('../').Gauge;
const g = new Gauge({
name: 'test_gauge',
help: 'Example of a gauge',
labelNames: ['method', 'code']
labelNames: ['method', 'code'],
});

setTimeout(() => {
Expand Down Expand Up @@ -82,11 +82,11 @@ server.get('/metrics/counter', (req, res) => {
// Enable collection of default metrics
require('../').collectDefaultMetrics({
timeout: 10000,
gcDurationBuckets: [0.001, 0.01, 0.1, 1, 2, 5] // These are the default buckets.
gcDurationBuckets: [0.001, 0.01, 0.1, 1, 2, 5], // These are the default buckets.
});

const port = process.env.PORT || 3000;
console.log(
`Server listening to ${port}, metrics exposed on /metrics endpoint`
`Server listening to ${port}, metrics exposed on /metrics endpoint`,
);
server.listen(port);
Loading

0 comments on commit 6151462

Please sign in to comment.