axios-prometheus-adapter 0.0.3 → 0.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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
|
-
import
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
import type { Registry } from 'prom-client';
|
|
3
3
|
export type AxiosPrometheusAdapterConfig = {
|
|
4
4
|
name: string;
|
|
5
5
|
help: string;
|
|
6
6
|
labelNames: string[];
|
|
7
7
|
};
|
|
8
|
-
export declare const createAxiosPrometheusMiddleware: (axiosInstance: AxiosInstance, registry:
|
|
8
|
+
export declare const createAxiosPrometheusMiddleware: (axiosInstance: AxiosInstance, registry: Registry, config?: AxiosPrometheusAdapterConfig) => void;
|
|
@@ -7,8 +7,8 @@ exports.createAxiosPrometheusMiddleware = void 0;
|
|
|
7
7
|
const prom_client_1 = __importDefault(require("prom-client"));
|
|
8
8
|
const createAxiosPrometheusMiddleware = (axiosInstance, registry, config) => {
|
|
9
9
|
const clientRequestDuration = new prom_client_1.default.Histogram({
|
|
10
|
-
name: '
|
|
11
|
-
help: '
|
|
10
|
+
name: 'http_client_requests_seconds',
|
|
11
|
+
help: 'Outgoing requests metrics',
|
|
12
12
|
labelNames: ['status_code', 'method', 'protocol', 'host', 'path'],
|
|
13
13
|
...config,
|
|
14
14
|
});
|
|
@@ -26,7 +26,7 @@ const createAxiosPrometheusMiddleware = (axiosInstance, registry, config) => {
|
|
|
26
26
|
method: response.request.method,
|
|
27
27
|
protocol: response.request.protocol,
|
|
28
28
|
host: response.request.host,
|
|
29
|
-
path: response.request.path,
|
|
29
|
+
path: response.request.path.split('?')[0],
|
|
30
30
|
};
|
|
31
31
|
response.config.metadata.endTimer(labels);
|
|
32
32
|
return response;
|
|
@@ -36,7 +36,7 @@ const createAxiosPrometheusMiddleware = (axiosInstance, registry, config) => {
|
|
|
36
36
|
method: error.response.request.method,
|
|
37
37
|
protocol: error.response.request.protocol,
|
|
38
38
|
host: error.response.request.host,
|
|
39
|
-
path: error.response.request.path,
|
|
39
|
+
path: error.response.request.path.split('?')[0],
|
|
40
40
|
};
|
|
41
41
|
error.config.metadata.endTimer(labels);
|
|
42
42
|
return Promise.reject(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosPrometheusAdapter.js","sourceRoot":"","sources":["../../lib/AxiosPrometheusAdapter.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"AxiosPrometheusAdapter.js","sourceRoot":"","sources":["../../lib/AxiosPrometheusAdapter.ts"],"names":[],"mappings":";;;;;;AAEA,8DAAiC;AAQ1B,MAAM,+BAA+B,GAAG,CAC7C,aAA4B,EAC5B,QAAkB,EAClB,MAAqC,EAC/B,EAAE;IACR,MAAM,qBAAqB,GAAG,IAAI,qBAAM,CAAC,SAAS,CAAC;QACjD,IAAI,EAAE,8BAA8B;QACpC,IAAI,EAAE,2BAA2B;QACjC,UAAU,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC;QACjE,GAAG,MAAM;KACV,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;IAE/C,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE;QACrD,MAAM,GAAG,GAAG,qBAAqB,CAAC,UAAU,EAAE,CAAC;QAE/C,MAAM,CAAC,QAAQ,GAAG;YAChB,QAAQ,EAAE,GAAG;SACd,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE;QACxD,MAAM,MAAM,GAAG;YACb,WAAW,EAAE,QAAQ,CAAC,MAAM;YAC5B,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;YAC/B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ;YACnC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI;YAC3B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC1C,CAAC;QACF,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,QAAQ,CAAC;IAClB,CAAC,EAAE,KAAK,CAAC,EAAE;QACT,MAAM,MAAM,GAAG;YACb,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM;YAClC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM;YACrC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ;YACzC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI;YACjC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAChD,CAAC;QACF,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA5CW,QAAA,+BAA+B,mCA4C1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axios-prometheus-adapter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Provides prometheus metrics for outgoing axios requests",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"package.json"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "tsc",
|
|
13
|
+
"build": "tsc -p tsconfig.prod.json",
|
|
14
14
|
"start": "ts-node-dev examples/index.ts",
|
|
15
15
|
"test": "jest"
|
|
16
16
|
},
|