@promster/metrics 15.5.0 → 15.5.2

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.
Files changed (42) hide show
  1. package/dist/index.cjs +385 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +144 -0
  4. package/dist/index.d.ts +144 -0
  5. package/dist/index.js +336 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +30 -10
  8. package/dist/declarations/src/client/client.d.ts +0 -9
  9. package/dist/declarations/src/client/index.d.ts +0 -2
  10. package/dist/declarations/src/create-gc-metrics/create-gc-metrics.d.ts +0 -14
  11. package/dist/declarations/src/create-gc-metrics/index.d.ts +0 -2
  12. package/dist/declarations/src/create-gc-observer/create-gc-observer.d.ts +0 -3
  13. package/dist/declarations/src/create-gc-observer/index.d.ts +0 -2
  14. package/dist/declarations/src/create-graphql-metrics/create-graphql-metrics.d.ts +0 -25
  15. package/dist/declarations/src/create-graphql-metrics/index.d.ts +0 -2
  16. package/dist/declarations/src/create-http-metrics/create-http-metrics.d.ts +0 -26
  17. package/dist/declarations/src/create-http-metrics/index.d.ts +0 -2
  18. package/dist/declarations/src/create-request-recorder/create-request-recorder.d.ts +0 -16
  19. package/dist/declarations/src/create-request-recorder/index.d.ts +0 -3
  20. package/dist/declarations/src/end-measurement-from/end-measurement-from.d.ts +0 -4
  21. package/dist/declarations/src/end-measurement-from/index.d.ts +0 -2
  22. package/dist/declarations/src/environment/index.d.ts +0 -3
  23. package/dist/declarations/src/environment/kubernetes.d.ts +0 -2
  24. package/dist/declarations/src/environment/skip-metrics-in-environment.d.ts +0 -6
  25. package/dist/declarations/src/index.d.ts +0 -16
  26. package/dist/declarations/src/normalizers/index.d.ts +0 -9
  27. package/dist/declarations/src/normalizers/method/index.d.ts +0 -2
  28. package/dist/declarations/src/normalizers/method/method.d.ts +0 -2
  29. package/dist/declarations/src/normalizers/path/index.d.ts +0 -2
  30. package/dist/declarations/src/normalizers/path/path.d.ts +0 -2
  31. package/dist/declarations/src/normalizers/status-code/index.d.ts +0 -2
  32. package/dist/declarations/src/normalizers/status-code/status-code.d.ts +0 -2
  33. package/dist/declarations/src/sort-labels/index.d.ts +0 -2
  34. package/dist/declarations/src/sort-labels/sort-labels.d.ts +0 -3
  35. package/dist/declarations/src/summary/index.d.ts +0 -2
  36. package/dist/declarations/src/summary/summary.d.ts +0 -3
  37. package/dist/declarations/src/timing/index.d.ts +0 -2
  38. package/dist/declarations/src/timing/timing.d.ts +0 -17
  39. package/dist/promster-metrics.cjs.d.ts +0 -2
  40. package/dist/promster-metrics.cjs.dev.js +0 -410
  41. package/dist/promster-metrics.cjs.js +0 -7
  42. package/dist/promster-metrics.cjs.prod.js +0 -410
@@ -1,410 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var once = require('lodash.once');
6
- var Prometheus = require('prom-client');
7
- var merge = require('merge-options');
8
- var prometheusGcStats = require('@chainsafe/prometheus-gc-stats');
9
- var url = require('node:url');
10
- var UrlValueParser = require('url-value-parser');
11
-
12
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
13
-
14
- function _interopNamespace(e) {
15
- if (e && e.__esModule) return e;
16
- var n = Object.create(null);
17
- if (e) {
18
- Object.keys(e).forEach(function (k) {
19
- if (k !== 'default') {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
21
- Object.defineProperty(n, k, d.get ? d : {
22
- enumerable: true,
23
- get: function () { return e[k]; }
24
- });
25
- }
26
- });
27
- }
28
- n["default"] = e;
29
- return Object.freeze(n);
30
- }
31
-
32
- var once__default = /*#__PURE__*/_interopDefault(once);
33
- var Prometheus__namespace = /*#__PURE__*/_interopNamespace(Prometheus);
34
- var merge__default = /*#__PURE__*/_interopDefault(merge);
35
- var url__default = /*#__PURE__*/_interopDefault(url);
36
- var UrlValueParser__default = /*#__PURE__*/_interopDefault(UrlValueParser);
37
-
38
- const isRunningInKubernetes = () => Boolean(process.env.KUBERNETES_SERVICE_HOST);
39
-
40
- const skipMetricsInEnvironment = options => options.detectKubernetes === true && !isRunningInKubernetes();
41
-
42
- // NOTE:
43
- // This is the `globalRegistry` provided by the `prom-client`
44
- // We could create multiple registries with `new Prometheus.registry()`.
45
- const defaultRegister = Prometheus__namespace.register;
46
- const configure = once__default["default"](options => {
47
- const shouldSkipMetricsInEnvironment = skipMetricsInEnvironment(options);
48
- if (!shouldSkipMetricsInEnvironment) {
49
- Prometheus__namespace.collectDefaultMetrics(options);
50
- }
51
- });
52
-
53
- const asArray$2 = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
54
- const defaultOptions$4 = {
55
- getLabelValues: () => ({}),
56
- labels: [],
57
- metricPrefix: '',
58
- metricNames: {
59
- up: ['nodejs_up']
60
- },
61
- gcCollectionInterval: 6000
62
- };
63
- const getMetrics$2 = options => ({
64
- up: asArray$2(options.metricNames.up).map(nameOfUpMetric => new Prometheus__namespace.Gauge({
65
- name: `${options.metricPrefix}${nameOfUpMetric}`,
66
- help: '1 = nodejs server is up, 0 = nodejs server is not up'
67
- }))
68
- });
69
- const createGcMetrics = options => {
70
- const defaultedOptions = merge__default["default"](defaultOptions$4, options);
71
- configure({
72
- prefix: defaultedOptions.metricPrefix
73
- });
74
- const gcMetrics = getMetrics$2(defaultedOptions);
75
- return gcMetrics;
76
- };
77
- createGcMetrics.defaultOptions = defaultOptions$4;
78
-
79
- const defaultOptions$3 = {
80
- disableGcMetrics: false
81
- };
82
- const createGcObserver = once__default["default"]((_metrics, options) => () => {
83
- prometheusGcStats.gcStats(defaultRegister, {
84
- collectionInterval: options.gcCollectionInterval,
85
- prefix: options.metricPrefix
86
- });
87
- });
88
-
89
- // @ts-expect-error
90
- createGcObserver.defaultOptions = defaultOptions$3;
91
-
92
- const defaultGraphQlPercentiles = [0.5, 0.9, 0.95, 0.98, 0.99];
93
- const defaultLabels$1 = ['operation_name'];
94
- const asArray$1 = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
95
- const shouldObserveGraphQlParseDurationAsHistogram = options => options.metricTypes.includes('graphQlParseDurationHistogram');
96
- const shouldObserveGraphQlValidationDurationAsHistogram = options => options.metricTypes.includes('graphQlValidationDurationHistogram');
97
- const shouldObserveGraphQlResolveFieldDurationAsHistogram = options => options.metricTypes.includes('graphQlResolveFieldDurationHistogram');
98
- const shouldObserveGraphQlRequestDurationAsHistogram = options => options.metricTypes.includes('graphQlRequestDurationHistogram');
99
- const shouldObserveGraphQlErrorsTotalAsCounter = options => options.metricTypes.includes('graphQlErrorsTotal');
100
- const defaultOptions$2 = {
101
- getLabelValues: () => ({}),
102
- labels: [],
103
- metricPrefix: '',
104
- metricTypes: ['graphQlParseDurationHistogram', 'graphQlValidationDurationHistogram', 'graphQlResolveFieldDurationHistogram', 'graphQlRequestDurationHistogram', 'graphQlErrorsTotal'],
105
- metricNames: {
106
- graphQlParseDuration: ['graphql_parse_duration_seconds'],
107
- graphQlValidationDuration: ['graphql_validation_duration_seconds'],
108
- graphQlResolveFieldDuration: ['graphql_resolve_field_duration_seconds'],
109
- graphQlRequestDuration: ['graphql_request_duration_seconds'],
110
- graphQlErrorsTotal: ['graphql_errors_total']
111
- },
112
- metricPercentiles: {
113
- graphQlParseDuration: defaultGraphQlPercentiles,
114
- graphQlValidationDuration: defaultGraphQlPercentiles,
115
- graphQlResolveFieldDuration: defaultGraphQlPercentiles,
116
- graphQlRequestDuration: defaultGraphQlPercentiles,
117
- graphQlErrorsTotal: defaultGraphQlPercentiles
118
- }
119
- };
120
- const getMetrics$1 = options => ({
121
- graphQlParseDuration: shouldObserveGraphQlParseDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlParseDuration).map(nameOfGraphQlParseDuration => {
122
- var _options$metricPercen;
123
- return new Prometheus__namespace.Histogram({
124
- name: `${options.metricPrefix}${nameOfGraphQlParseDuration}`,
125
- help: 'The GraphQL request parse time in seconds.',
126
- labelNames: defaultLabels$1.concat(options.labels).toSorted(),
127
- buckets: ((_options$metricPercen = options.metricPercentiles) === null || _options$metricPercen === void 0 ? void 0 : _options$metricPercen.graphQlParseDuration) || defaultGraphQlPercentiles
128
- });
129
- }) : undefined,
130
- graphQlValidationDuration: shouldObserveGraphQlValidationDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlValidationDuration).map(nameOfGraphQlValidationDuration => {
131
- var _options$metricPercen2;
132
- return new Prometheus__namespace.Histogram({
133
- name: `${options.metricPrefix}${nameOfGraphQlValidationDuration}`,
134
- help: 'The GraphQL request validation time in seconds.',
135
- labelNames: defaultLabels$1.concat(options.labels).toSorted(),
136
- buckets: ((_options$metricPercen2 = options.metricPercentiles) === null || _options$metricPercen2 === void 0 ? void 0 : _options$metricPercen2.graphQlValidationDuration) || defaultGraphQlPercentiles
137
- });
138
- }) : undefined,
139
- graphQlResolveFieldDuration: shouldObserveGraphQlResolveFieldDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlResolveFieldDuration).map(nameOfGraphQlResolveFieldDuration => {
140
- var _options$metricPercen3;
141
- return new Prometheus__namespace.Histogram({
142
- name: `${options.metricPrefix}${nameOfGraphQlResolveFieldDuration}`,
143
- help: 'The GraphQL field resolving time in seconds.',
144
- labelNames: defaultLabels$1.concat(['field_name']).concat(options.labels).toSorted(),
145
- buckets: ((_options$metricPercen3 = options.metricPercentiles) === null || _options$metricPercen3 === void 0 ? void 0 : _options$metricPercen3.graphQlResolveFieldDuration) || defaultGraphQlPercentiles
146
- });
147
- }) : undefined,
148
- graphQlRequestDuration: shouldObserveGraphQlRequestDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlRequestDuration).map(nameOfGraphQlRequestDuration => {
149
- var _options$metricPercen4;
150
- return new Prometheus__namespace.Histogram({
151
- name: `${options.metricPrefix}${nameOfGraphQlRequestDuration}`,
152
- help: 'The GraphQL request duration time in seconds.',
153
- labelNames: defaultLabels$1.concat(options.labels).toSorted(),
154
- buckets: ((_options$metricPercen4 = options.metricPercentiles) === null || _options$metricPercen4 === void 0 ? void 0 : _options$metricPercen4.graphQlRequestDuration) || defaultGraphQlPercentiles
155
- });
156
- }) : undefined,
157
- graphQlErrorsTotal: shouldObserveGraphQlErrorsTotalAsCounter(options) ? asArray$1(options.metricNames.graphQlErrorsTotal).map(nameOfGraphQlErrorsCount => new Prometheus__namespace.Counter({
158
- name: `${options.metricPrefix}${nameOfGraphQlErrorsCount}`,
159
- help: 'Count of errors while parsing, validating, or executing a GraphQL operation.',
160
- labelNames: defaultLabels$1.concat(['phase']).concat(options.labels).toSorted()
161
- })) : undefined
162
- });
163
- const createGraphQlMetrics = options => {
164
- const defaultedOptions = merge__default["default"](defaultOptions$2, options);
165
- configure({
166
- prefix: defaultedOptions.metricPrefix
167
- });
168
- const metrics = getMetrics$1(defaultedOptions);
169
- return metrics;
170
- };
171
- createGraphQlMetrics.defaultOptions = defaultOptions$2;
172
-
173
- const defaultHttpRequestDurationPercentileInSeconds = [0.5, 0.9, 0.95, 0.98, 0.99];
174
- const defaultHttpRequestDurationInSeconds = [0.05, 0.1, 0.3, 0.5, 0.8, 1, 1.5, 2, 3, 10];
175
- const defaultHttpContentLengthInBytes = [100000, 200000, 500000, 1000000, 1500000, 2000000, 3000000, 5000000, 10000000];
176
- const defaultLabels = ['path', 'status_code', 'method'];
177
- const asArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
178
- const shouldObserveHttpRequestsAsSummary = options => options.metricTypes.includes('httpRequestsSummary');
179
- const shouldObserveHttpRequestsAsHistogram = options => options.metricTypes.includes('httpRequestsHistogram');
180
- const shouldObserveHttpRequestsAsCounter = options => options.metricTypes.includes('httpRequestsTotal');
181
- const shouldObserveHttpContentLengthAsHistogram = options => options.metricTypes.includes('httpContentLengthHistogram');
182
- const defaultOptions$1 = {
183
- getLabelValues: () => ({}),
184
- labels: [],
185
- metricPrefix: '',
186
- metricTypes: ['httpRequestsTotal', 'httpRequestsHistogram'],
187
- metricNames: {
188
- httpRequestsTotal: ['http_requests_total'],
189
- httpRequestDurationPerPercentileInSeconds: ['http_request_duration_per_percentile_seconds'],
190
- httpRequestDurationInSeconds: ['http_request_duration_seconds'],
191
- httpRequestContentLengthInBytes: ['http_request_content_length_bytes'],
192
- httpResponseContentLengthInBytes: ['http_response_content_length_bytes']
193
- },
194
- metricBuckets: {
195
- httpRequestContentLengthInBytes: defaultHttpContentLengthInBytes,
196
- httpRequestDurationInSeconds: defaultHttpRequestDurationInSeconds
197
- },
198
- metricPercentiles: {
199
- httpRequestDurationPerPercentileInSeconds: defaultHttpRequestDurationPercentileInSeconds,
200
- httpResponseContentLengthInBytes: defaultHttpContentLengthInBytes
201
- }
202
- };
203
- const getMetrics = options => ({
204
- httpRequestContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => {
205
- var _options$metricBucket;
206
- return new Prometheus__namespace.Histogram({
207
- name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
208
- help: 'The HTTP request content length in bytes.',
209
- labelNames: defaultLabels.concat(options.labels).toSorted(),
210
- buckets: ((_options$metricBucket = options.metricBuckets) === null || _options$metricBucket === void 0 ? void 0 : _options$metricBucket.httpRequestContentLengthInBytes) || defaultHttpContentLengthInBytes
211
- });
212
- }) : undefined,
213
- httpResponseContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => {
214
- var _options$metricBucket2;
215
- return new Prometheus__namespace.Histogram({
216
- name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
217
- help: 'The HTTP response content length in bytes.',
218
- labelNames: defaultLabels.concat(options.labels).toSorted(),
219
- buckets: ((_options$metricBucket2 = options.metricBuckets) === null || _options$metricBucket2 === void 0 ? void 0 : _options$metricBucket2.httpResponseContentLengthInBytes) || defaultHttpContentLengthInBytes
220
- });
221
- }) : undefined
222
- });
223
- const getHttpRequestLatencyMetricsInSeconds = options => ({
224
- httpRequestDurationPerPercentileInSeconds: shouldObserveHttpRequestsAsSummary(options) ? asArray(options.metricNames.httpRequestDurationPerPercentileInSeconds).map(nameOfHttpRequestDurationPerPercentileInSeconds => {
225
- var _options$metricPercen;
226
- return new Prometheus__namespace.Summary({
227
- name: `${options.metricPrefix}${nameOfHttpRequestDurationPerPercentileInSeconds}`,
228
- help: 'The HTTP request latencies in seconds.',
229
- labelNames: defaultLabels.concat(options.labels).toSorted(),
230
- percentiles: ((_options$metricPercen = options.metricPercentiles) === null || _options$metricPercen === void 0 ? void 0 : _options$metricPercen.httpRequestDurationPerPercentileInSeconds) || defaultHttpRequestDurationPercentileInSeconds
231
- });
232
- }) : undefined,
233
- httpRequestDurationInSeconds: shouldObserveHttpRequestsAsHistogram(options) ? asArray(options.metricNames.httpRequestDurationInSeconds).map(nameOfHttpRequestDurationInSecondsMetric => {
234
- var _options$metricBucket3;
235
- return new Prometheus__namespace.Histogram({
236
- name: `${options.metricPrefix}${nameOfHttpRequestDurationInSecondsMetric}`,
237
- help: 'The HTTP request latencies in seconds.',
238
- labelNames: defaultLabels.concat(options.labels).toSorted(),
239
- buckets: ((_options$metricBucket3 = options.metricBuckets) === null || _options$metricBucket3 === void 0 ? void 0 : _options$metricBucket3.httpRequestDurationInSeconds) || defaultHttpRequestDurationInSeconds
240
- });
241
- }) : undefined
242
- });
243
- const getHttpRequestCounterMetric = options => ({
244
- httpRequestsTotal: shouldObserveHttpRequestsAsCounter(options) ? asArray(options.metricNames.httpRequestsTotal).map(nameOfHttpRequestsTotalMetric => new Prometheus__namespace.Counter({
245
- name: `${options.metricPrefix}${nameOfHttpRequestsTotalMetric}`,
246
- help: 'The total HTTP requests.',
247
- labelNames: defaultLabels.concat(options.labels).toSorted()
248
- })) : undefined
249
- });
250
- const createHttpMetrics = options => {
251
- const defaultedOptions = merge__default["default"](defaultOptions$1, options);
252
- configure({
253
- prefix: defaultedOptions.metricPrefix
254
- });
255
- const metrics = getMetrics(defaultedOptions);
256
- const httpRequestLatencyMetricsInSeconds = getHttpRequestLatencyMetricsInSeconds(defaultedOptions);
257
- const httpRequestCounterMetric = getHttpRequestCounterMetric(defaultedOptions);
258
- return Object.assign({}, metrics, httpRequestLatencyMetricsInSeconds, httpRequestCounterMetric);
259
- };
260
- createHttpMetrics.defaultOptions = defaultOptions$1;
261
-
262
- const NS_PER_SEC = 1e9;
263
- function endMeasurementFrom(start) {
264
- const [seconds, nanoseconds] = process.hrtime(start);
265
- return {
266
- durationS: (seconds * NS_PER_SEC + nanoseconds) / NS_PER_SEC
267
- };
268
- }
269
-
270
- function sortLabels(unsortedLabels) {
271
- return Object.keys(unsortedLabels).toSorted((a, b) => {
272
- if (a < b) {
273
- return -1;
274
- }
275
- if (a > b) {
276
- return 1;
277
- }
278
- return 0;
279
- }).reduce((sortedLabels, labelName) => {
280
- sortedLabels[labelName] = unsortedLabels[labelName];
281
- return sortedLabels;
282
- }, {});
283
- }
284
-
285
- const defaultOptions = {
286
- detectKubernetes: false
287
- };
288
- function isTiming(timing) {
289
- return !Array.isArray(timing);
290
- }
291
- const createRequestRecorder = (metrics, options = defaultOptions) => {
292
- const defaultedRecorderOptions = merge__default["default"](defaultOptions, options);
293
- const shouldSkipMetricsByEnvironment = skipMetricsInEnvironment(defaultedRecorderOptions);
294
- return (timing, recordingOptions) => {
295
- const durationS = isTiming(timing) ? timing.end().value().seconds : endMeasurementFrom(timing).durationS;
296
- const labels = sortLabels(recordingOptions.labels);
297
- if (!shouldSkipMetricsByEnvironment && durationS !== undefined) {
298
- if (metrics.httpRequestDurationInSeconds) {
299
- for (const httpRequestDurationInSecondsMetricType of metrics.httpRequestDurationInSeconds) {
300
- httpRequestDurationInSecondsMetricType.observe(labels, durationS);
301
- }
302
- }
303
- }
304
- if (!shouldSkipMetricsByEnvironment && durationS !== undefined) {
305
- if (metrics.httpRequestDurationPerPercentileInSeconds) {
306
- for (const httpRequestDurationPerPercentileInSecondsMetricType of metrics.httpRequestDurationPerPercentileInSeconds) {
307
- httpRequestDurationPerPercentileInSecondsMetricType.observe(labels, durationS);
308
- }
309
- }
310
- }
311
- if (!shouldSkipMetricsByEnvironment && durationS !== undefined) {
312
- if (metrics.httpRequestsTotal) {
313
- for (const httpRequestsTotalMetricType of metrics.httpRequestsTotal) {
314
- httpRequestsTotalMetricType.inc(labels);
315
- }
316
- }
317
- }
318
- if (recordingOptions.requestContentLength) {
319
- if (metrics.httpRequestContentLengthInBytes) {
320
- for (const httpRequestContentLengthInBytesMetricType of metrics.httpRequestContentLengthInBytes) {
321
- httpRequestContentLengthInBytesMetricType.observe(labels, recordingOptions.requestContentLength);
322
- }
323
- }
324
- }
325
- if (recordingOptions.responseContentLength) {
326
- if (metrics.httpResponseContentLengthInBytes) {
327
- for (const httpResponseContentLengthInBytesMetricType of metrics.httpResponseContentLengthInBytes) {
328
- httpResponseContentLengthInBytesMetricType.observe(labels, recordingOptions.responseContentLength);
329
- }
330
- }
331
- }
332
- };
333
- };
334
- createRequestRecorder.defaultOptions = defaultOptions;
335
-
336
- const normalizeMethod = method => method.toLowerCase();
337
-
338
- const urlValueParser = new UrlValueParser__default["default"]();
339
- const normalizePath = path => {
340
- const parsedPathname = url__default["default"].parse(path).pathname;
341
- if (!parsedPathname) {
342
- return '';
343
- }
344
- return urlValueParser.replacePathValues(parsedPathname, '#val');
345
- };
346
-
347
- const normalizeStatusCode = statusCode => statusCode;
348
-
349
- const defaultNormalizers = {
350
- normalizeStatusCode,
351
- normalizePath,
352
- normalizeMethod
353
- };
354
-
355
- const getSummary = async () => defaultRegister.metrics();
356
- const getContentType = () => defaultRegister.contentType;
357
-
358
- class Timing {
359
- static NS_PER_SEC = BigInt(1e9);
360
- #startTime;
361
- #endTime;
362
- constructor() {
363
- this.reset();
364
- }
365
- value() {
366
- const startTime = this.#startTime;
367
- const endTime = this.#endTime;
368
- if (!endTime || !startTime) {
369
- return {
370
- seconds: undefined
371
- };
372
- }
373
- return {
374
- seconds: Number(endTime - startTime) / Number(Timing.NS_PER_SEC)
375
- };
376
- }
377
- reset() {
378
- this.#startTime = process.hrtime.bigint();
379
- this.#endTime = undefined;
380
- return this;
381
- }
382
- end() {
383
- this.#endTime = process.hrtime.bigint();
384
- return this;
385
- }
386
- }
387
- const timing = {
388
- start() {
389
- return new Timing();
390
- }
391
- };
392
-
393
- exports.Prometheus = Prometheus__namespace;
394
- exports.createGcMetrics = createGcMetrics;
395
- exports.createGcObserver = createGcObserver;
396
- exports.createGraphQlMetrics = createGraphQlMetrics;
397
- exports.createHttpMetrics = createHttpMetrics;
398
- exports.createRequestRecorder = createRequestRecorder;
399
- exports.defaultNormalizers = defaultNormalizers;
400
- exports.defaultRegister = defaultRegister;
401
- exports.endMeasurementFrom = endMeasurementFrom;
402
- exports.getContentType = getContentType;
403
- exports.getSummary = getSummary;
404
- exports.isRunningInKubernetes = isRunningInKubernetes;
405
- exports.normalizeMethod = normalizeMethod;
406
- exports.normalizePath = normalizePath;
407
- exports.normalizeStatusCode = normalizeStatusCode;
408
- exports.skipMetricsInEnvironment = skipMetricsInEnvironment;
409
- exports.sortLabels = sortLabels;
410
- exports.timing = timing;