@tramvai/module-metrics 1.58.1 → 1.59.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.
package/lib/server.es.js CHANGED
@@ -16,6 +16,15 @@ import { createPapiMethod } from '@tramvai/papi';
16
16
  import fromPairs from '@tinkoff/utils/object/fromPairs';
17
17
  import { createEvent, createReducer } from '@tramvai/state';
18
18
 
19
+ // https://nodejs.org/api/errors.html#nodejs-error-codes - Common system errors possible for net/http/dns
20
+ const POSSIBLE_ERRORS = [
21
+ 'EADDRINUSE',
22
+ 'ECONNREFUSED',
23
+ 'ECONNRESET',
24
+ 'ENOTFOUND',
25
+ 'EPIPE',
26
+ 'ETIMEDOUT',
27
+ ];
19
28
  const getUrlAndOptions = (args) => {
20
29
  let url;
21
30
  let options;
@@ -77,7 +86,10 @@ const createRequestWithMetrics = ({ metricsInstances: { requestsTotal, requestsE
77
86
  requestsTotal.inc(labelsValues);
78
87
  timerDone(labelsValues);
79
88
  });
80
- req.on('error', () => {
89
+ req.on('error', (e) => {
90
+ if (POSSIBLE_ERRORS.includes(e === null || e === void 0 ? void 0 : e.code)) {
91
+ labelsValues.status = e.code;
92
+ }
81
93
  requestsTotal.inc(labelsValues);
82
94
  requestsErrors.inc(labelsValues);
83
95
  timerDone(labelsValues);
package/lib/server.js CHANGED
@@ -30,6 +30,15 @@ var monkeypatch__default = /*#__PURE__*/_interopDefaultLegacy(monkeypatch);
30
30
  var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
31
31
  var fromPairs__default = /*#__PURE__*/_interopDefaultLegacy(fromPairs);
32
32
 
33
+ // https://nodejs.org/api/errors.html#nodejs-error-codes - Common system errors possible for net/http/dns
34
+ const POSSIBLE_ERRORS = [
35
+ 'EADDRINUSE',
36
+ 'ECONNREFUSED',
37
+ 'ECONNRESET',
38
+ 'ENOTFOUND',
39
+ 'EPIPE',
40
+ 'ETIMEDOUT',
41
+ ];
33
42
  const getUrlAndOptions = (args) => {
34
43
  let url$1;
35
44
  let options;
@@ -91,7 +100,10 @@ const createRequestWithMetrics = ({ metricsInstances: { requestsTotal, requestsE
91
100
  requestsTotal.inc(labelsValues);
92
101
  timerDone(labelsValues);
93
102
  });
94
- req.on('error', () => {
103
+ req.on('error', (e) => {
104
+ if (POSSIBLE_ERRORS.includes(e === null || e === void 0 ? void 0 : e.code)) {
105
+ labelsValues.status = e.code;
106
+ }
95
107
  requestsTotal.inc(labelsValues);
96
108
  requestsErrors.inc(labelsValues);
97
109
  timerDone(labelsValues);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-metrics",
3
- "version": "1.58.1",
3
+ "version": "1.59.0",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -19,13 +19,13 @@
19
19
  "build-for-publish": "true"
20
20
  },
21
21
  "dependencies": {
22
- "@tramvai/core": "1.58.1",
23
- "@tramvai/tokens-server": "1.58.1",
24
- "@tramvai/tokens-metrics": "1.58.1",
25
- "@tramvai/module-common": "1.58.1",
26
- "@tramvai/tokens-http-client": "1.58.1",
27
- "@tramvai/state": "1.58.1",
28
- "@tramvai/papi": "1.58.1",
22
+ "@tramvai/core": "1.59.0",
23
+ "@tramvai/tokens-server": "1.59.0",
24
+ "@tramvai/tokens-metrics": "1.59.0",
25
+ "@tramvai/module-common": "1.59.0",
26
+ "@tramvai/tokens-http-client": "1.59.0",
27
+ "@tramvai/state": "1.59.0",
28
+ "@tramvai/papi": "1.59.0",
29
29
  "@tinkoff/measure-express-requests": "1.4.2",
30
30
  "@tinkoff/monkeypatch": "1.3.3",
31
31
  "@tinkoff/url": "0.7.37",