@tramvai/module-metrics 1.84.2 → 1.90.1
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/lib/server.es.js +14 -10
- package/lib/server.js +13 -9
- package/package.json +11 -11
package/lib/server.es.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { createToken, Module, commandLineListTokens, Scope, provide } from '@tramvai/core';
|
|
3
|
-
import { SERVER_MODULE_PAPI_PUBLIC_ROUTE,
|
|
3
|
+
import { SERVER_MODULE_PAPI_PUBLIC_ROUTE, SPECIAL_SERVER_PATHS } from '@tramvai/tokens-server';
|
|
4
|
+
import { WEB_FASTIFY_APP_BEFORE_INIT_TOKEN, WEB_FASTIFY_APP_TOKEN } from '@tramvai/tokens-server-private';
|
|
4
5
|
import { METRICS_MODULE_TOKEN, METRICS_SERVICES_REGISTRY_TOKEN, REGISTER_INSTANT_METRIC_TOKEN } from '@tramvai/tokens-metrics';
|
|
5
6
|
import { measure } from '@tinkoff/measure-express-requests';
|
|
6
7
|
import { Registry, collectDefaultMetrics, Counter, Gauge, Histogram, Summary } from 'prom-client';
|
|
@@ -486,14 +487,14 @@ MetricsModule = __decorate([
|
|
|
486
487
|
},
|
|
487
488
|
}),
|
|
488
489
|
provide({
|
|
489
|
-
provide:
|
|
490
|
-
useFactory: ({
|
|
491
|
-
return () => {
|
|
492
|
-
app.
|
|
490
|
+
provide: WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
|
|
491
|
+
useFactory: ({ app, metrics, additionalLabelNamesList, getAdditionalLabelValuesList, httpRequestsDurationBuckets, metricsExcludePaths, registry, }) => {
|
|
492
|
+
return async () => {
|
|
493
|
+
app.all('/metrics', async (_, res) => {
|
|
493
494
|
res.type(registry.contentType);
|
|
494
|
-
|
|
495
|
+
return registry.metrics();
|
|
495
496
|
});
|
|
496
|
-
|
|
497
|
+
const measured = measure({
|
|
497
498
|
metrics,
|
|
498
499
|
metricsExcludePaths,
|
|
499
500
|
additionalLabelNames: flatten(additionalLabelNamesList || []),
|
|
@@ -507,12 +508,15 @@ MetricsModule = __decorate([
|
|
|
507
508
|
}), {});
|
|
508
509
|
},
|
|
509
510
|
httpRequestsDurationBuckets,
|
|
510
|
-
})
|
|
511
|
+
});
|
|
512
|
+
app.addHook('onRequest', (request, reply, next) => {
|
|
513
|
+
measured({ ...request.raw, path: request.url }, reply, next);
|
|
514
|
+
});
|
|
511
515
|
};
|
|
512
516
|
},
|
|
513
517
|
deps: {
|
|
514
518
|
metrics: METRICS_MODULE_TOKEN,
|
|
515
|
-
app:
|
|
519
|
+
app: WEB_FASTIFY_APP_TOKEN,
|
|
516
520
|
additionalLabelNamesList: {
|
|
517
521
|
token: 'additionalLabelNames',
|
|
518
522
|
multi: true,
|
|
@@ -533,7 +537,7 @@ MetricsModule = __decorate([
|
|
|
533
537
|
multi: true,
|
|
534
538
|
}),
|
|
535
539
|
provide({
|
|
536
|
-
provide:
|
|
540
|
+
provide: commandLineListTokens.listen,
|
|
537
541
|
useFactory: ({ metrics }) => {
|
|
538
542
|
return () => {
|
|
539
543
|
eventLoopMetrics(metrics);
|
package/lib/server.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var core = require('@tramvai/core');
|
|
7
7
|
var tokensServer = require('@tramvai/tokens-server');
|
|
8
|
+
var tokensServerPrivate = require('@tramvai/tokens-server-private');
|
|
8
9
|
var tokensMetrics = require('@tramvai/tokens-metrics');
|
|
9
10
|
var measureExpressRequests = require('@tinkoff/measure-express-requests');
|
|
10
11
|
var promClient = require('prom-client');
|
|
@@ -500,14 +501,14 @@ exports.MetricsModule = tslib.__decorate([
|
|
|
500
501
|
},
|
|
501
502
|
}),
|
|
502
503
|
core.provide({
|
|
503
|
-
provide:
|
|
504
|
-
useFactory: ({
|
|
505
|
-
return () => {
|
|
506
|
-
app.
|
|
504
|
+
provide: tokensServerPrivate.WEB_FASTIFY_APP_BEFORE_INIT_TOKEN,
|
|
505
|
+
useFactory: ({ app, metrics, additionalLabelNamesList, getAdditionalLabelValuesList, httpRequestsDurationBuckets, metricsExcludePaths, registry, }) => {
|
|
506
|
+
return async () => {
|
|
507
|
+
app.all('/metrics', async (_, res) => {
|
|
507
508
|
res.type(registry.contentType);
|
|
508
|
-
|
|
509
|
+
return registry.metrics();
|
|
509
510
|
});
|
|
510
|
-
|
|
511
|
+
const measured = measureExpressRequests.measure({
|
|
511
512
|
metrics,
|
|
512
513
|
metricsExcludePaths,
|
|
513
514
|
additionalLabelNames: flatten__default["default"](additionalLabelNamesList || []),
|
|
@@ -521,12 +522,15 @@ exports.MetricsModule = tslib.__decorate([
|
|
|
521
522
|
}), {});
|
|
522
523
|
},
|
|
523
524
|
httpRequestsDurationBuckets,
|
|
524
|
-
})
|
|
525
|
+
});
|
|
526
|
+
app.addHook('onRequest', (request, reply, next) => {
|
|
527
|
+
measured({ ...request.raw, path: request.url }, reply, next);
|
|
528
|
+
});
|
|
525
529
|
};
|
|
526
530
|
},
|
|
527
531
|
deps: {
|
|
528
532
|
metrics: tokensMetrics.METRICS_MODULE_TOKEN,
|
|
529
|
-
app:
|
|
533
|
+
app: tokensServerPrivate.WEB_FASTIFY_APP_TOKEN,
|
|
530
534
|
additionalLabelNamesList: {
|
|
531
535
|
token: 'additionalLabelNames',
|
|
532
536
|
multi: true,
|
|
@@ -547,7 +551,7 @@ exports.MetricsModule = tslib.__decorate([
|
|
|
547
551
|
multi: true,
|
|
548
552
|
}),
|
|
549
553
|
core.provide({
|
|
550
|
-
provide:
|
|
554
|
+
provide: core.commandLineListTokens.listen,
|
|
551
555
|
useFactory: ({ metrics }) => {
|
|
552
556
|
return () => {
|
|
553
557
|
eventLoopMetrics(metrics);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-metrics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.90.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -19,22 +19,22 @@
|
|
|
19
19
|
"build-for-publish": "true"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tramvai/core": "1.
|
|
23
|
-
"@tramvai/tokens-server": "1.
|
|
24
|
-
"@tramvai/tokens-
|
|
25
|
-
"@tramvai/
|
|
26
|
-
"@tramvai/
|
|
27
|
-
"@tramvai/
|
|
28
|
-
"@tramvai/
|
|
29
|
-
"@
|
|
22
|
+
"@tramvai/core": "1.90.1",
|
|
23
|
+
"@tramvai/tokens-server": "1.90.1",
|
|
24
|
+
"@tramvai/tokens-server-private": "1.90.1",
|
|
25
|
+
"@tramvai/tokens-metrics": "1.90.1",
|
|
26
|
+
"@tramvai/module-common": "1.90.1",
|
|
27
|
+
"@tramvai/tokens-http-client": "1.90.1",
|
|
28
|
+
"@tramvai/state": "1.90.1",
|
|
29
|
+
"@tramvai/papi": "1.90.1",
|
|
30
|
+
"@tinkoff/measure-express-requests": "1.5.1",
|
|
30
31
|
"@tinkoff/monkeypatch": "1.3.3",
|
|
31
32
|
"@tinkoff/url": "0.7.37",
|
|
32
33
|
"@tinkoff/utils": "^2.1.2",
|
|
33
34
|
"prom-client": "^12.0.0",
|
|
34
35
|
"@tinkoff/logger": "0.10.14",
|
|
35
36
|
"@tinkoff/metrics-noop": "1.0.2",
|
|
36
|
-
"@tinkoff/browser-timings": "0.9.4"
|
|
37
|
-
"express": "^4.17.1"
|
|
37
|
+
"@tinkoff/browser-timings": "0.9.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"tslib": "^2.0.3"
|