@promster/metrics 7.0.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -70,6 +70,8 @@ const shouldObserveHttpRequestsAsHistogram = options => options.metricTypes.incl
|
|
|
70
70
|
|
|
71
71
|
const shouldObserveHttpRequestsAsCounter = options => options.metricTypes.includes('httpRequestsTotal');
|
|
72
72
|
|
|
73
|
+
const shouldObserveHttpContentLengthAsHistogram = options => options.metricTypes.includes('httpContentLengthHistogram');
|
|
74
|
+
|
|
73
75
|
const defaultOptions$1 = {
|
|
74
76
|
getLabelValues: () => ({}),
|
|
75
77
|
labels: [],
|
|
@@ -111,13 +113,13 @@ const getDefaultMetrics = options => ({
|
|
|
111
113
|
help: 'Total number of bytes reclaimed by GC.',
|
|
112
114
|
labelNames: defaultGcLabels
|
|
113
115
|
})),
|
|
114
|
-
httpRequestContentLengthInBytes: asArray(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
116
|
+
httpRequestContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) && asArray(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
115
117
|
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
|
|
116
118
|
help: 'The HTTP request content length in bytes.',
|
|
117
119
|
labelNames: defaultRequestLabels.concat(options.labels).sort(),
|
|
118
120
|
buckets: options.buckets || defaultHttpContentLengthInBytes
|
|
119
121
|
})),
|
|
120
|
-
httpResponseContentLengthInBytes: asArray(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
122
|
+
httpResponseContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) && asArray(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
121
123
|
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
|
|
122
124
|
help: 'The HTTP response content length in bytes.',
|
|
123
125
|
labelNames: defaultRequestLabels.concat(options.labels).sort(),
|
|
@@ -234,6 +236,8 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
234
236
|
const shouldObserveInSummary = shouldObserveMetricType('httpRequestsSummary')(defaultedRecorderOptions);
|
|
235
237
|
const shouldObserveInHistogram = shouldObserveMetricType('httpRequestsHistogram')(defaultedRecorderOptions);
|
|
236
238
|
const shouldObserveInCounter = shouldObserveMetricType('httpRequestsTotal')(defaultedRecorderOptions);
|
|
239
|
+
const shouldObserveContentLengthInHistogram = shouldObserveMetricType('httpContentLengthHistogram')(defaultedRecorderOptions); // eslint-disable-next-line complexity
|
|
240
|
+
|
|
237
241
|
return (start, recordingOptions) => {
|
|
238
242
|
const {
|
|
239
243
|
durationMs,
|
|
@@ -271,14 +275,14 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
271
275
|
});
|
|
272
276
|
}
|
|
273
277
|
|
|
274
|
-
if (
|
|
278
|
+
if (!shouldSkipMetricsByEnvironment && shouldObserveContentLengthInHistogram && recordingOptions.requestContentLength) {
|
|
275
279
|
metricTypes.httpRequestContentLengthInBytes.forEach(httpRequestContentLengthInBytesMetricType => {
|
|
276
280
|
httpRequestContentLengthInBytesMetricType.observe(labels, // @ts-expect-error
|
|
277
281
|
recordingOptions.requestContentLength);
|
|
278
282
|
});
|
|
279
283
|
}
|
|
280
284
|
|
|
281
|
-
if (
|
|
285
|
+
if (!shouldSkipMetricsByEnvironment && shouldObserveContentLengthInHistogram && recordingOptions.responseContentLength) {
|
|
282
286
|
metricTypes.httpResponseContentLengthInBytes.forEach(httpResponseContentLengthInBytesMetricType => {
|
|
283
287
|
httpResponseContentLengthInBytesMetricType.observe(labels, // @ts-expect-error
|
|
284
288
|
recordingOptions.responseContentLength);
|
|
@@ -70,6 +70,8 @@ const shouldObserveHttpRequestsAsHistogram = options => options.metricTypes.incl
|
|
|
70
70
|
|
|
71
71
|
const shouldObserveHttpRequestsAsCounter = options => options.metricTypes.includes('httpRequestsTotal');
|
|
72
72
|
|
|
73
|
+
const shouldObserveHttpContentLengthAsHistogram = options => options.metricTypes.includes('httpContentLengthHistogram');
|
|
74
|
+
|
|
73
75
|
const defaultOptions$1 = {
|
|
74
76
|
getLabelValues: () => ({}),
|
|
75
77
|
labels: [],
|
|
@@ -111,13 +113,13 @@ const getDefaultMetrics = options => ({
|
|
|
111
113
|
help: 'Total number of bytes reclaimed by GC.',
|
|
112
114
|
labelNames: defaultGcLabels
|
|
113
115
|
})),
|
|
114
|
-
httpRequestContentLengthInBytes: asArray(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
116
|
+
httpRequestContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) && asArray(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
115
117
|
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
|
|
116
118
|
help: 'The HTTP request content length in bytes.',
|
|
117
119
|
labelNames: defaultRequestLabels.concat(options.labels).sort(),
|
|
118
120
|
buckets: options.buckets || defaultHttpContentLengthInBytes
|
|
119
121
|
})),
|
|
120
|
-
httpResponseContentLengthInBytes: asArray(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
122
|
+
httpResponseContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) && asArray(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
|
|
121
123
|
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
|
|
122
124
|
help: 'The HTTP response content length in bytes.',
|
|
123
125
|
labelNames: defaultRequestLabels.concat(options.labels).sort(),
|
|
@@ -234,6 +236,8 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
234
236
|
const shouldObserveInSummary = shouldObserveMetricType('httpRequestsSummary')(defaultedRecorderOptions);
|
|
235
237
|
const shouldObserveInHistogram = shouldObserveMetricType('httpRequestsHistogram')(defaultedRecorderOptions);
|
|
236
238
|
const shouldObserveInCounter = shouldObserveMetricType('httpRequestsTotal')(defaultedRecorderOptions);
|
|
239
|
+
const shouldObserveContentLengthInHistogram = shouldObserveMetricType('httpContentLengthHistogram')(defaultedRecorderOptions); // eslint-disable-next-line complexity
|
|
240
|
+
|
|
237
241
|
return (start, recordingOptions) => {
|
|
238
242
|
const {
|
|
239
243
|
durationMs,
|
|
@@ -271,14 +275,14 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
271
275
|
});
|
|
272
276
|
}
|
|
273
277
|
|
|
274
|
-
if (
|
|
278
|
+
if (!shouldSkipMetricsByEnvironment && shouldObserveContentLengthInHistogram && recordingOptions.requestContentLength) {
|
|
275
279
|
metricTypes.httpRequestContentLengthInBytes.forEach(httpRequestContentLengthInBytesMetricType => {
|
|
276
280
|
httpRequestContentLengthInBytesMetricType.observe(labels, // @ts-expect-error
|
|
277
281
|
recordingOptions.requestContentLength);
|
|
278
282
|
});
|
|
279
283
|
}
|
|
280
284
|
|
|
281
|
-
if (
|
|
285
|
+
if (!shouldSkipMetricsByEnvironment && shouldObserveContentLengthInHistogram && recordingOptions.responseContentLength) {
|
|
282
286
|
metricTypes.httpResponseContentLengthInBytes.forEach(httpResponseContentLengthInBytesMetricType => {
|
|
283
287
|
httpResponseContentLengthInBytesMetricType.observe(labels, // @ts-expect-error
|
|
284
288
|
recordingOptions.responseContentLength);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promster/metrics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Metrics utilities used by all other server integrations",
|
|
5
5
|
"main": "dist/promster-metrics.cjs.js",
|
|
6
6
|
"typings": "dist/promster-metrics.cjs.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
21
|
-
"npm": ">=
|
|
20
|
+
"node": ">=14",
|
|
21
|
+
"npm": ">=6"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -40,20 +40,21 @@
|
|
|
40
40
|
"lodash.once": "4.1.1",
|
|
41
41
|
"merge-options": "3.0.4",
|
|
42
42
|
"optional": "0.1.4",
|
|
43
|
-
"ts-essentials": "
|
|
43
|
+
"ts-essentials": "9.0.0",
|
|
44
44
|
"tslib": "2.3.1",
|
|
45
45
|
"url": "0.11.0",
|
|
46
46
|
"url-value-parser": "2.0.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@promster/types": "^3.1.
|
|
50
|
-
"@types/lodash": "4.14.
|
|
51
|
-
"prom-client": "
|
|
49
|
+
"@promster/types": "^3.1.5",
|
|
50
|
+
"@types/lodash": "4.14.176",
|
|
51
|
+
"prom-client": "14.0.0",
|
|
52
|
+
"typescript": "4.4.4"
|
|
52
53
|
},
|
|
53
54
|
"optionalDependencies": {
|
|
54
|
-
"@sematext/gc-stats": "1.5.
|
|
55
|
+
"@sematext/gc-stats": "1.5.5"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
|
-
"prom-client": "13.x.x"
|
|
58
|
+
"prom-client": "13.x.x || 14.x"
|
|
58
59
|
}
|
|
59
60
|
}
|