@promster/metrics 7.0.0 → 7.0.4
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.
- package/dist/declarations/src/client/client.d.ts +4 -4
- package/dist/declarations/src/client/index.d.ts +2 -2
- package/dist/declarations/src/create-gc-observer/create-gc-observer.d.ts +2 -2
- package/dist/declarations/src/create-gc-observer/index.d.ts +2 -2
- package/dist/declarations/src/create-metric-types/create-metric-types.d.ts +25 -25
- package/dist/declarations/src/create-metric-types/index.d.ts +2 -2
- package/dist/declarations/src/create-request-recorder/create-request-recorder.d.ts +18 -18
- package/dist/declarations/src/create-request-recorder/index.d.ts +3 -3
- package/dist/declarations/src/index.d.ts +9 -9
- package/dist/declarations/src/kubernetes/index.d.ts +2 -2
- package/dist/declarations/src/kubernetes/kubernetes.d.ts +2 -2
- package/dist/declarations/src/normalizers/index.d.ts +9 -9
- package/dist/declarations/src/normalizers/method/index.d.ts +2 -2
- package/dist/declarations/src/normalizers/method/method.d.ts +2 -2
- package/dist/declarations/src/normalizers/path/index.d.ts +2 -2
- package/dist/declarations/src/normalizers/path/path.d.ts +2 -2
- package/dist/declarations/src/normalizers/status-code/index.d.ts +2 -2
- package/dist/declarations/src/normalizers/status-code/status-code.d.ts +2 -2
- package/dist/declarations/src/summary/index.d.ts +2 -2
- package/dist/declarations/src/summary/summary.d.ts +3 -3
- package/dist/promster-metrics.cjs.dev.js +13 -15
- package/dist/promster-metrics.cjs.prod.js +13 -15
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as Prometheus from 'prom-client';
|
|
2
|
-
declare const defaultRegister: Prometheus.Registry;
|
|
3
|
-
declare const configure: any;
|
|
4
|
-
export { Prometheus, defaultRegister, configure };
|
|
1
|
+
import * as Prometheus from 'prom-client';
|
|
2
|
+
declare const defaultRegister: Prometheus.Registry;
|
|
3
|
+
declare const configure: any;
|
|
4
|
+
export { Prometheus, defaultRegister, configure };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Prometheus, defaultRegister, configure } from './client';
|
|
2
|
-
export { Prometheus, defaultRegister, configure };
|
|
1
|
+
import { Prometheus, defaultRegister, configure } from './client';
|
|
2
|
+
export { Prometheus, defaultRegister, configure };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const createGcObserver: any;
|
|
2
|
-
export { createGcObserver };
|
|
1
|
+
declare const createGcObserver: any;
|
|
2
|
+
export { createGcObserver };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { createGcObserver } from './create-gc-observer';
|
|
2
|
-
export { createGcObserver };
|
|
1
|
+
import { createGcObserver } from './create-gc-observer';
|
|
2
|
+
export { createGcObserver };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { TDefaultedPromsterOptions, TMetricTypes } from '@promster/types';
|
|
2
|
-
declare const createMetricTypes: {
|
|
3
|
-
(options: TDefaultedPromsterOptions): TMetricTypes;
|
|
4
|
-
defaultOptions: {
|
|
5
|
-
getLabelValues: () => {};
|
|
6
|
-
labels: never[];
|
|
7
|
-
accuracies: string[];
|
|
8
|
-
metricPrefix: string;
|
|
9
|
-
metricTypes: string[];
|
|
10
|
-
metricNames: {
|
|
11
|
-
up: string[];
|
|
12
|
-
countOfGcs: string[];
|
|
13
|
-
durationOfGc: string[];
|
|
14
|
-
reclaimedInGc: string[];
|
|
15
|
-
httpRequestsTotal: string[];
|
|
16
|
-
httpRequestDurationPerPercentileInMilliseconds: string[];
|
|
17
|
-
httpRequestDurationPerPercentileInSeconds: string[];
|
|
18
|
-
httpRequestDurationInSeconds: string[];
|
|
19
|
-
httpRequestDurationInMilliseconds: string[];
|
|
20
|
-
httpRequestContentLengthInBytes: string[];
|
|
21
|
-
httpResponseContentLengthInBytes: string[];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export { createMetricTypes };
|
|
1
|
+
import type { TDefaultedPromsterOptions, TMetricTypes } from '@promster/types';
|
|
2
|
+
declare const createMetricTypes: {
|
|
3
|
+
(options: TDefaultedPromsterOptions): TMetricTypes;
|
|
4
|
+
defaultOptions: {
|
|
5
|
+
getLabelValues: () => {};
|
|
6
|
+
labels: never[];
|
|
7
|
+
accuracies: string[];
|
|
8
|
+
metricPrefix: string;
|
|
9
|
+
metricTypes: string[];
|
|
10
|
+
metricNames: {
|
|
11
|
+
up: string[];
|
|
12
|
+
countOfGcs: string[];
|
|
13
|
+
durationOfGc: string[];
|
|
14
|
+
reclaimedInGc: string[];
|
|
15
|
+
httpRequestsTotal: string[];
|
|
16
|
+
httpRequestDurationPerPercentileInMilliseconds: string[];
|
|
17
|
+
httpRequestDurationPerPercentileInSeconds: string[];
|
|
18
|
+
httpRequestDurationInSeconds: string[];
|
|
19
|
+
httpRequestDurationInMilliseconds: string[];
|
|
20
|
+
httpRequestContentLengthInBytes: string[];
|
|
21
|
+
httpResponseContentLengthInBytes: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export { createMetricTypes };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { createMetricTypes } from './create-metric-types';
|
|
2
|
-
export { createMetricTypes };
|
|
1
|
+
import { createMetricTypes } from './create-metric-types';
|
|
2
|
+
export { createMetricTypes };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { TPromsterOptions, TLabelValues, TMetricTypes } from '@promster/types';
|
|
2
|
-
declare type TRecordingOptions = {
|
|
3
|
-
labels: TLabelValues;
|
|
4
|
-
requestContentLength?: number;
|
|
5
|
-
responseContentLength?: number;
|
|
6
|
-
};
|
|
7
|
-
declare type TRequestTiming = [number, number];
|
|
8
|
-
export declare type TRequestRecorder = (start: TRequestTiming, recordingOptions: TRecordingOptions) => void;
|
|
9
|
-
declare const sortLabels: (unsortedLabels: TLabelValues) => TLabelValues;
|
|
10
|
-
declare const
|
|
11
|
-
durationMs: number;
|
|
12
|
-
durationS: number;
|
|
13
|
-
};
|
|
14
|
-
declare const createRequestRecorder: {
|
|
15
|
-
(metricTypes: TMetricTypes, options?: TPromsterOptions): TRequestRecorder;
|
|
16
|
-
defaultOptions: TPromsterOptions;
|
|
17
|
-
};
|
|
18
|
-
export { createRequestRecorder, sortLabels,
|
|
1
|
+
import type { TPromsterOptions, TLabelValues, TMetricTypes } from '@promster/types';
|
|
2
|
+
declare type TRecordingOptions = {
|
|
3
|
+
labels: TLabelValues;
|
|
4
|
+
requestContentLength?: number;
|
|
5
|
+
responseContentLength?: number;
|
|
6
|
+
};
|
|
7
|
+
declare type TRequestTiming = [number, number];
|
|
8
|
+
export declare type TRequestRecorder = (start: TRequestTiming, recordingOptions: TRecordingOptions) => void;
|
|
9
|
+
declare const sortLabels: (unsortedLabels: TLabelValues) => TLabelValues;
|
|
10
|
+
declare const endMeasurementFrom: (start: TRequestTiming) => {
|
|
11
|
+
durationMs: number;
|
|
12
|
+
durationS: number;
|
|
13
|
+
};
|
|
14
|
+
declare const createRequestRecorder: {
|
|
15
|
+
(metricTypes: TMetricTypes, options?: TPromsterOptions): TRequestRecorder;
|
|
16
|
+
defaultOptions: TPromsterOptions;
|
|
17
|
+
};
|
|
18
|
+
export { createRequestRecorder, sortLabels, endMeasurementFrom };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createRequestRecorder } from './create-request-recorder';
|
|
2
|
-
export type { TRequestRecorder } from './create-request-recorder';
|
|
3
|
-
export { createRequestRecorder };
|
|
1
|
+
import { createRequestRecorder } from './create-request-recorder';
|
|
2
|
+
export type { TRequestRecorder } from './create-request-recorder';
|
|
3
|
+
export { createRequestRecorder };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Prometheus, defaultRegister } from './client';
|
|
2
|
-
import { createMetricTypes } from './create-metric-types';
|
|
3
|
-
import { getSummary, getContentType } from './summary';
|
|
4
|
-
import { createRequestRecorder } from './create-request-recorder';
|
|
5
|
-
import { createGcObserver } from './create-gc-observer';
|
|
6
|
-
import { defaultNormalizers, normalizeStatusCode, normalizePath, normalizeMethod } from './normalizers';
|
|
7
|
-
import { isRunningInKubernetes } from './kubernetes';
|
|
8
|
-
export type { TRequestRecorder } from './create-request-recorder';
|
|
9
|
-
export { Prometheus, defaultRegister, createMetricTypes, getSummary, getContentType, createRequestRecorder, createGcObserver, defaultNormalizers, normalizeStatusCode, normalizePath, normalizeMethod, isRunningInKubernetes, };
|
|
1
|
+
import { Prometheus, defaultRegister } from './client';
|
|
2
|
+
import { createMetricTypes } from './create-metric-types';
|
|
3
|
+
import { getSummary, getContentType } from './summary';
|
|
4
|
+
import { createRequestRecorder } from './create-request-recorder';
|
|
5
|
+
import { createGcObserver } from './create-gc-observer';
|
|
6
|
+
import { defaultNormalizers, normalizeStatusCode, normalizePath, normalizeMethod } from './normalizers';
|
|
7
|
+
import { isRunningInKubernetes } from './kubernetes';
|
|
8
|
+
export type { TRequestRecorder } from './create-request-recorder';
|
|
9
|
+
export { Prometheus, defaultRegister, createMetricTypes, getSummary, getContentType, createRequestRecorder, createGcObserver, defaultNormalizers, normalizeStatusCode, normalizePath, normalizeMethod, isRunningInKubernetes, };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { isRunningInKubernetes } from './kubernetes';
|
|
2
|
-
export { isRunningInKubernetes };
|
|
1
|
+
import { isRunningInKubernetes } from './kubernetes';
|
|
2
|
+
export { isRunningInKubernetes };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const isRunningInKubernetes: () => boolean;
|
|
2
|
-
export { isRunningInKubernetes };
|
|
1
|
+
declare const isRunningInKubernetes: () => boolean;
|
|
2
|
+
export { isRunningInKubernetes };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { normalizeStatusCode } from './status-code';
|
|
2
|
-
import { normalizePath } from './path';
|
|
3
|
-
import { normalizeMethod } from './method';
|
|
4
|
-
declare const defaultNormalizers: {
|
|
5
|
-
normalizeStatusCode: (statusCode: number) => number;
|
|
6
|
-
normalizePath: (path: string) => string;
|
|
7
|
-
normalizeMethod: (method: string) => string;
|
|
8
|
-
};
|
|
9
|
-
export { normalizeStatusCode, normalizePath, normalizeMethod, defaultNormalizers, };
|
|
1
|
+
import { normalizeStatusCode } from './status-code';
|
|
2
|
+
import { normalizePath } from './path';
|
|
3
|
+
import { normalizeMethod } from './method';
|
|
4
|
+
declare const defaultNormalizers: {
|
|
5
|
+
normalizeStatusCode: (statusCode: number) => number;
|
|
6
|
+
normalizePath: (path: string) => string;
|
|
7
|
+
normalizeMethod: (method: string) => string;
|
|
8
|
+
};
|
|
9
|
+
export { normalizeStatusCode, normalizePath, normalizeMethod, defaultNormalizers, };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { normalizeMethod } from './method';
|
|
2
|
-
export { normalizeMethod };
|
|
1
|
+
import { normalizeMethod } from './method';
|
|
2
|
+
export { normalizeMethod };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const normalizeMethod: (method: string) => string;
|
|
2
|
-
export { normalizeMethod };
|
|
1
|
+
declare const normalizeMethod: (method: string) => string;
|
|
2
|
+
export { normalizeMethod };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { normalizePath } from './path';
|
|
2
|
-
export { normalizePath };
|
|
1
|
+
import { normalizePath } from './path';
|
|
2
|
+
export { normalizePath };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const normalizePath: (path: string) => string;
|
|
2
|
-
export { normalizePath };
|
|
1
|
+
declare const normalizePath: (path: string) => string;
|
|
2
|
+
export { normalizePath };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { normalizeStatusCode } from './status-code';
|
|
2
|
-
export { normalizeStatusCode };
|
|
1
|
+
import { normalizeStatusCode } from './status-code';
|
|
2
|
+
export { normalizeStatusCode };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const normalizeStatusCode: (statusCode: number) => number;
|
|
2
|
-
export { normalizeStatusCode };
|
|
1
|
+
declare const normalizeStatusCode: (statusCode: number) => number;
|
|
2
|
+
export { normalizeStatusCode };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { getSummary, getContentType } from './summary';
|
|
2
|
-
export { getSummary, getContentType };
|
|
1
|
+
import { getSummary, getContentType } from './summary';
|
|
2
|
+
export { getSummary, getContentType };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const getSummary: () => Promise<string>;
|
|
2
|
-
declare const getContentType: () => string;
|
|
3
|
-
export { getSummary, getContentType };
|
|
1
|
+
declare const getSummary: () => Promise<string>;
|
|
2
|
+
declare const getContentType: () => string;
|
|
3
|
+
export { getSummary, getContentType };
|
|
@@ -20,14 +20,12 @@ function _interopNamespace(e) {
|
|
|
20
20
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
21
|
Object.defineProperty(n, k, d.get ? d : {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return e[k];
|
|
25
|
-
}
|
|
23
|
+
get: function () { return e[k]; }
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
|
-
n[
|
|
28
|
+
n["default"] = e;
|
|
31
29
|
return Object.freeze(n);
|
|
32
30
|
}
|
|
33
31
|
|
|
@@ -44,7 +42,7 @@ const isRunningInKubernetes = () => Boolean(process.env.KUBERNETES_SERVICE_HOST)
|
|
|
44
42
|
// We could create multiple registries with `new Prometheus.registry()`.
|
|
45
43
|
|
|
46
44
|
const defaultRegister = Prometheus__namespace.register;
|
|
47
|
-
const configure = once__default[
|
|
45
|
+
const configure = once__default["default"](options => {
|
|
48
46
|
const shouldSkipMetricsByEnvironment = options.detectKubernetes === true && !isRunningInKubernetes();
|
|
49
47
|
|
|
50
48
|
if (!shouldSkipMetricsByEnvironment) {
|
|
@@ -98,8 +96,8 @@ const getDefaultMetrics = options => ({
|
|
|
98
96
|
name: `${options.metricPrefix}${nameOfUpMetric}`,
|
|
99
97
|
help: '1 = up, 0 = not up'
|
|
100
98
|
})),
|
|
101
|
-
countOfGcs: asArray(options.metricNames.countOfGcs).map(
|
|
102
|
-
name: `${options.metricPrefix}${
|
|
99
|
+
countOfGcs: asArray(options.metricNames.countOfGcs).map(nameOfCountOfGcsMetric => new Prometheus__namespace.Counter({
|
|
100
|
+
name: `${options.metricPrefix}${nameOfCountOfGcsMetric}`,
|
|
103
101
|
help: 'Count of total garbage collections.',
|
|
104
102
|
labelNames: defaultGcLabels
|
|
105
103
|
})),
|
|
@@ -166,7 +164,7 @@ const getHttpRequestCounterMetric = options => ({
|
|
|
166
164
|
});
|
|
167
165
|
|
|
168
166
|
const createMetricTypes = options => {
|
|
169
|
-
const defaultedOptions = merge__default[
|
|
167
|
+
const defaultedOptions = merge__default["default"](defaultOptions$1, options);
|
|
170
168
|
configure({
|
|
171
169
|
prefix: defaultedOptions.metricPrefix
|
|
172
170
|
});
|
|
@@ -201,7 +199,7 @@ const sortLabels = unsortedLabels => Object.keys(unsortedLabels).sort((a, b) =>
|
|
|
201
199
|
return sortedLabels;
|
|
202
200
|
}, {});
|
|
203
201
|
|
|
204
|
-
const
|
|
202
|
+
const endMeasurementFrom = start => {
|
|
205
203
|
const [seconds, nanoseconds] = process.hrtime(start);
|
|
206
204
|
return {
|
|
207
205
|
durationMs: Math.round((seconds * NS_PER_SEC + nanoseconds) / NS_PER_MS),
|
|
@@ -229,7 +227,7 @@ const defaultOptions = {
|
|
|
229
227
|
};
|
|
230
228
|
|
|
231
229
|
const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
232
|
-
const defaultedRecorderOptions = merge__default[
|
|
230
|
+
const defaultedRecorderOptions = merge__default["default"](defaultOptions, options);
|
|
233
231
|
const shouldSkipMetricsByEnvironment = defaultedRecorderOptions.detectKubernetes && !isRunningInKubernetes();
|
|
234
232
|
const shouldObserveInSeconds = shouldObserveMetricAccuracy('s')(defaultedRecorderOptions);
|
|
235
233
|
const shouldObserveInMilliseconds = shouldObserveMetricAccuracy('ms')(defaultedRecorderOptions);
|
|
@@ -240,7 +238,7 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
240
238
|
const {
|
|
241
239
|
durationMs,
|
|
242
240
|
durationS
|
|
243
|
-
} =
|
|
241
|
+
} = endMeasurementFrom(start);
|
|
244
242
|
const labels = sortLabels(recordingOptions.labels);
|
|
245
243
|
|
|
246
244
|
if (shouldObserveInMilliseconds && shouldObserveInHistogram && !shouldSkipMetricsByEnvironment) {
|
|
@@ -291,7 +289,7 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
291
289
|
|
|
292
290
|
createRequestRecorder.defaultOptions = defaultOptions;
|
|
293
291
|
|
|
294
|
-
const gc = requireOptional__default[
|
|
292
|
+
const gc = requireOptional__default["default"]('@sematext/gc-stats');
|
|
295
293
|
const gcTypes = {
|
|
296
294
|
0: 'unknown',
|
|
297
295
|
1: 'scavenge',
|
|
@@ -301,7 +299,7 @@ const gcTypes = {
|
|
|
301
299
|
8: 'weak_phantom',
|
|
302
300
|
15: 'all'
|
|
303
301
|
};
|
|
304
|
-
const createGcObserver = once__default[
|
|
302
|
+
const createGcObserver = once__default["default"](metricTypes => () => {
|
|
305
303
|
if (typeof gc !== 'function') {
|
|
306
304
|
return;
|
|
307
305
|
}
|
|
@@ -325,9 +323,9 @@ const createGcObserver = once__default['default'](metricTypes => () => {
|
|
|
325
323
|
|
|
326
324
|
const normalizeStatusCode = statusCode => statusCode;
|
|
327
325
|
|
|
328
|
-
const urlValueParser = new UrlValueParser__default[
|
|
326
|
+
const urlValueParser = new UrlValueParser__default["default"]();
|
|
329
327
|
|
|
330
|
-
const normalizePath = path => urlValueParser.replacePathValues(url__default[
|
|
328
|
+
const normalizePath = path => urlValueParser.replacePathValues(url__default["default"].parse(path).pathname);
|
|
331
329
|
|
|
332
330
|
const normalizeMethod = method => method.toLowerCase();
|
|
333
331
|
|
|
@@ -20,14 +20,12 @@ function _interopNamespace(e) {
|
|
|
20
20
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
21
|
Object.defineProperty(n, k, d.get ? d : {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return e[k];
|
|
25
|
-
}
|
|
23
|
+
get: function () { return e[k]; }
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
|
-
n[
|
|
28
|
+
n["default"] = e;
|
|
31
29
|
return Object.freeze(n);
|
|
32
30
|
}
|
|
33
31
|
|
|
@@ -44,7 +42,7 @@ const isRunningInKubernetes = () => Boolean(process.env.KUBERNETES_SERVICE_HOST)
|
|
|
44
42
|
// We could create multiple registries with `new Prometheus.registry()`.
|
|
45
43
|
|
|
46
44
|
const defaultRegister = Prometheus__namespace.register;
|
|
47
|
-
const configure = once__default[
|
|
45
|
+
const configure = once__default["default"](options => {
|
|
48
46
|
const shouldSkipMetricsByEnvironment = options.detectKubernetes === true && !isRunningInKubernetes();
|
|
49
47
|
|
|
50
48
|
if (!shouldSkipMetricsByEnvironment) {
|
|
@@ -98,8 +96,8 @@ const getDefaultMetrics = options => ({
|
|
|
98
96
|
name: `${options.metricPrefix}${nameOfUpMetric}`,
|
|
99
97
|
help: '1 = up, 0 = not up'
|
|
100
98
|
})),
|
|
101
|
-
countOfGcs: asArray(options.metricNames.countOfGcs).map(
|
|
102
|
-
name: `${options.metricPrefix}${
|
|
99
|
+
countOfGcs: asArray(options.metricNames.countOfGcs).map(nameOfCountOfGcsMetric => new Prometheus__namespace.Counter({
|
|
100
|
+
name: `${options.metricPrefix}${nameOfCountOfGcsMetric}`,
|
|
103
101
|
help: 'Count of total garbage collections.',
|
|
104
102
|
labelNames: defaultGcLabels
|
|
105
103
|
})),
|
|
@@ -166,7 +164,7 @@ const getHttpRequestCounterMetric = options => ({
|
|
|
166
164
|
});
|
|
167
165
|
|
|
168
166
|
const createMetricTypes = options => {
|
|
169
|
-
const defaultedOptions = merge__default[
|
|
167
|
+
const defaultedOptions = merge__default["default"](defaultOptions$1, options);
|
|
170
168
|
configure({
|
|
171
169
|
prefix: defaultedOptions.metricPrefix
|
|
172
170
|
});
|
|
@@ -201,7 +199,7 @@ const sortLabels = unsortedLabels => Object.keys(unsortedLabels).sort((a, b) =>
|
|
|
201
199
|
return sortedLabels;
|
|
202
200
|
}, {});
|
|
203
201
|
|
|
204
|
-
const
|
|
202
|
+
const endMeasurementFrom = start => {
|
|
205
203
|
const [seconds, nanoseconds] = process.hrtime(start);
|
|
206
204
|
return {
|
|
207
205
|
durationMs: Math.round((seconds * NS_PER_SEC + nanoseconds) / NS_PER_MS),
|
|
@@ -229,7 +227,7 @@ const defaultOptions = {
|
|
|
229
227
|
};
|
|
230
228
|
|
|
231
229
|
const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
232
|
-
const defaultedRecorderOptions = merge__default[
|
|
230
|
+
const defaultedRecorderOptions = merge__default["default"](defaultOptions, options);
|
|
233
231
|
const shouldSkipMetricsByEnvironment = defaultedRecorderOptions.detectKubernetes && !isRunningInKubernetes();
|
|
234
232
|
const shouldObserveInSeconds = shouldObserveMetricAccuracy('s')(defaultedRecorderOptions);
|
|
235
233
|
const shouldObserveInMilliseconds = shouldObserveMetricAccuracy('ms')(defaultedRecorderOptions);
|
|
@@ -240,7 +238,7 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
240
238
|
const {
|
|
241
239
|
durationMs,
|
|
242
240
|
durationS
|
|
243
|
-
} =
|
|
241
|
+
} = endMeasurementFrom(start);
|
|
244
242
|
const labels = sortLabels(recordingOptions.labels);
|
|
245
243
|
|
|
246
244
|
if (shouldObserveInMilliseconds && shouldObserveInHistogram && !shouldSkipMetricsByEnvironment) {
|
|
@@ -291,7 +289,7 @@ const createRequestRecorder = (metricTypes, options = defaultOptions) => {
|
|
|
291
289
|
|
|
292
290
|
createRequestRecorder.defaultOptions = defaultOptions;
|
|
293
291
|
|
|
294
|
-
const gc = requireOptional__default[
|
|
292
|
+
const gc = requireOptional__default["default"]('@sematext/gc-stats');
|
|
295
293
|
const gcTypes = {
|
|
296
294
|
0: 'unknown',
|
|
297
295
|
1: 'scavenge',
|
|
@@ -301,7 +299,7 @@ const gcTypes = {
|
|
|
301
299
|
8: 'weak_phantom',
|
|
302
300
|
15: 'all'
|
|
303
301
|
};
|
|
304
|
-
const createGcObserver = once__default[
|
|
302
|
+
const createGcObserver = once__default["default"](metricTypes => () => {
|
|
305
303
|
if (typeof gc !== 'function') {
|
|
306
304
|
return;
|
|
307
305
|
}
|
|
@@ -325,9 +323,9 @@ const createGcObserver = once__default['default'](metricTypes => () => {
|
|
|
325
323
|
|
|
326
324
|
const normalizeStatusCode = statusCode => statusCode;
|
|
327
325
|
|
|
328
|
-
const urlValueParser = new UrlValueParser__default[
|
|
326
|
+
const urlValueParser = new UrlValueParser__default["default"]();
|
|
329
327
|
|
|
330
|
-
const normalizePath = path => urlValueParser.replacePathValues(url__default[
|
|
328
|
+
const normalizePath = path => urlValueParser.replacePathValues(url__default["default"].parse(path).pathname);
|
|
331
329
|
|
|
332
330
|
const normalizeMethod = method => method.toLowerCase();
|
|
333
331
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promster/metrics",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.4",
|
|
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",
|
|
@@ -40,20 +40,20 @@
|
|
|
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.4",
|
|
50
|
+
"@types/lodash": "4.14.175",
|
|
51
|
+
"prom-client": "14.0.0"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@sematext/gc-stats": "1.5.
|
|
54
|
+
"@sematext/gc-stats": "1.5.5"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"prom-client": "13.x.x"
|
|
57
|
+
"prom-client": "13.x.x || 14.x"
|
|
58
58
|
}
|
|
59
59
|
}
|