rename metricsType -> metricType, move corresponding readme block 2 paragraphs lower

This commit is contained in:
Konstantin Pogorelov
2018-12-23 16:45:38 +01:00
parent 0dd3116f23
commit e7d004f0cc
3 changed files with 13 additions and 15 deletions

View File

@@ -64,12 +64,6 @@ The code the master process runs will expose an API with a single endpoint `/clu
## Options
Metrics type:
* **metricsType**: two metrics type are supported for `http_request_duration_seconds` metric: [histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) and [summary](https://prometheus.io/docs/concepts/metric_types/#summary), default: **histogram**
Which labels to include in `http_request_duration_seconds` metric:
* **includeStatusCode**: HTTP status code (200, 400, 404 etc.), default: **true**
@@ -90,6 +84,10 @@ Extra transformation callbacks:
* **formatStatusCode**: `function(res)` producing final status code from express `res` object, e.g. you can combine `200`, `201` and `204` to just `2xx`.
* **transformLabels**: `function(labels, req, res)` transforms the **labels** object, e.g. setting dynamic values to **customLabels**
Metric type:
* **metricType**: two metric types are supported for `http_request_duration_seconds` metric: [histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) and [summary](https://prometheus.io/docs/concepts/metric_types/#summary), default: **histogram**
Other options:
* **buckets**: buckets used for `http_request_duration_seconds` histogram

View File

@@ -186,10 +186,10 @@ describe('index', () => {
});
});
it('metrics type summary works', done => {
it('metric type summary works', done => {
const app = express();
const bundled = bundle({
metricsType: 'summary',
metricType: 'summary',
percentiles: [0.5, 0.85, 0.99],
});
app.use(bundled);
@@ -207,10 +207,10 @@ describe('index', () => {
});
});
it('metrics type histogram works', done => {
it('metric type histogram works', done => {
const app = express();
const bundled = bundle({
metricsType: 'histogram',
metricType: 'histogram',
buckets: [10, 100],
});
app.use(bundled);
@@ -230,7 +230,7 @@ describe('index', () => {
it('throws on unknown metricType ', () => {
expect(() => {
bundle({metricsType: 'hello',});
bundle({metricType: 'hello'});
}).toThrow();
});

View File

@@ -62,7 +62,7 @@ function main(opts) {
includeStatusCode: true,
normalizePath: main.normalizePath,
formatStatusCode: main.normalizeStatusCode,
metricsType: 'histogram',
metricType: 'histogram',
promClient: {}
},
opts
@@ -108,14 +108,14 @@ function main(opts) {
labels.push.apply(labels, Object.keys(opts.customLabels));
}
if (opts.metricsType === 'summary') {
if (opts.metricType === 'summary') {
return new promClient.Summary({
name: httpMetricName,
help: 'duration summary of http responses labeled with: ' + labels.join(', '),
labelNames: labels,
percentiles: opts.percentiles || [0.5, 0.75, 0.95, 0.98, 0.99, 0.999]
});
} else if (opts.metricsType === 'histogram' || !opts.metricsType) {
} else if (opts.metricType === 'histogram' || !opts.metricType) {
return new promClient.Histogram({
name: httpMetricName,
help: 'duration histogram of http responses labeled with: ' + labels.join(', '),
@@ -123,7 +123,7 @@ function main(opts) {
buckets: opts.buckets || [0.003, 0.03, 0.1, 0.3, 1.5, 10]
});
} else {
throw new Error('metricsType option must be histogram or summary');
throw new Error('metricType option must be histogram or summary');
}
}
};