axios-prometheus-adapter 0.0.4 → 0.0.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axios-prometheus-adapter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Provides prometheus metrics for outgoing axios requests",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,8 +18,14 @@
|
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "https://github.com/PauloPepp/axios-prometheus-adapter.git"
|
|
20
20
|
},
|
|
21
|
-
"author": "",
|
|
21
|
+
"author": "PauloPepp <tevesir@gmail.com>",
|
|
22
22
|
"license": "ISC",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"axios",
|
|
25
|
+
"prometheus",
|
|
26
|
+
"metrics",
|
|
27
|
+
"interceptor"
|
|
28
|
+
],
|
|
23
29
|
"jest": {
|
|
24
30
|
"testTimeout": 30000,
|
|
25
31
|
"testEnvironment": "node",
|
package/readme.md
CHANGED
|
@@ -63,34 +63,34 @@ Output:
|
|
|
63
63
|
...
|
|
64
64
|
# HELP http_client_requests_seconds_count http_client_requests_seconds_count
|
|
65
65
|
# TYPE http_client_requests_seconds_count histogram
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
66
|
+
http_client_requests_seconds_bucket{le="0.005",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 0
|
|
67
|
+
http_client_requests_seconds_bucket{le="0.01",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 0
|
|
68
|
+
http_client_requests_seconds_bucket{le="0.025",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 0
|
|
69
|
+
http_client_requests_seconds_bucket{le="0.05",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 0
|
|
70
|
+
http_client_requests_seconds_bucket{le="0.1",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 0
|
|
71
|
+
http_client_requests_seconds_bucket{le="0.25",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 0
|
|
72
|
+
http_client_requests_seconds_bucket{le="0.5",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 1
|
|
73
|
+
http_client_requests_seconds_bucket{le="1",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 1
|
|
74
|
+
http_client_requests_seconds_bucket{le="2.5",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 1
|
|
75
|
+
http_client_requests_seconds_bucket{le="5",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 1
|
|
76
|
+
http_client_requests_seconds_bucket{le="10",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 1
|
|
77
|
+
http_client_requests_seconds_bucket{le="+Inf",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 1
|
|
78
|
+
http_client_requests_seconds_sum{status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 0.257366432
|
|
79
|
+
http_client_requests_seconds_count{status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/1"} 1
|
|
80
|
+
http_client_requests_seconds_bucket{le="0.005",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 0
|
|
81
|
+
http_client_requests_seconds_bucket{le="0.01",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 0
|
|
82
|
+
http_client_requests_seconds_bucket{le="0.025",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 0
|
|
83
|
+
http_client_requests_seconds_bucket{le="0.05",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 0
|
|
84
|
+
http_client_requests_seconds_bucket{le="0.1",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 0
|
|
85
|
+
http_client_requests_seconds_bucket{le="0.25",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
86
|
+
http_client_requests_seconds_bucket{le="0.5",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
87
|
+
http_client_requests_seconds_bucket{le="1",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
88
|
+
http_client_requests_seconds_bucket{le="2.5",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
89
|
+
http_client_requests_seconds_bucket{le="5",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
90
|
+
http_client_requests_seconds_bucket{le="10",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
91
|
+
http_client_requests_seconds_bucket{le="+Inf",status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
92
|
+
http_client_requests_seconds_sum{status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 0.107517055
|
|
93
|
+
http_client_requests_seconds_count{status_code="200",method="GET",protocol="https:",host="jsonplaceholder.typicode.com",path="/posts/2"} 1
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
### Custom config
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AxiosPrometheusAdapterConfig, createAxiosPrometheusMiddleware } from './lib/AxiosPrometheusAdapter';
|
package/dist/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAxiosPrometheusMiddleware = void 0;
|
|
4
|
-
var AxiosPrometheusAdapter_1 = require("./lib/AxiosPrometheusAdapter");
|
|
5
|
-
Object.defineProperty(exports, "createAxiosPrometheusMiddleware", { enumerable: true, get: function () { return AxiosPrometheusAdapter_1.createAxiosPrometheusMiddleware; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,uEAA6G;AAAtE,yIAAA,+BAA+B,OAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from 'axios';
|
|
2
|
-
import type { Registry } from 'prom-client';
|
|
3
|
-
export type AxiosPrometheusAdapterConfig = {
|
|
4
|
-
name: string;
|
|
5
|
-
help: string;
|
|
6
|
-
labelNames: string[];
|
|
7
|
-
};
|
|
8
|
-
export declare const createAxiosPrometheusMiddleware: (axiosInstance: AxiosInstance, registry: Registry, config?: AxiosPrometheusAdapterConfig) => void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createAxiosPrometheusMiddleware = void 0;
|
|
7
|
-
const prom_client_1 = __importDefault(require("prom-client"));
|
|
8
|
-
const createAxiosPrometheusMiddleware = (axiosInstance, registry, config) => {
|
|
9
|
-
const clientRequestDuration = new prom_client_1.default.Histogram({
|
|
10
|
-
name: 'http_client_requests_seconds',
|
|
11
|
-
help: 'Outgoing requests metrics',
|
|
12
|
-
labelNames: ['status_code', 'method', 'protocol', 'host', 'path'],
|
|
13
|
-
...config,
|
|
14
|
-
});
|
|
15
|
-
registry.registerMetric(clientRequestDuration);
|
|
16
|
-
axiosInstance.interceptors.request.use((config) => {
|
|
17
|
-
const end = clientRequestDuration.startTimer();
|
|
18
|
-
config.metadata = {
|
|
19
|
-
endTimer: end,
|
|
20
|
-
};
|
|
21
|
-
return config;
|
|
22
|
-
});
|
|
23
|
-
axiosInstance.interceptors.response.use((response) => {
|
|
24
|
-
const labels = {
|
|
25
|
-
status_code: response.status,
|
|
26
|
-
method: response.request.method,
|
|
27
|
-
protocol: response.request.protocol,
|
|
28
|
-
host: response.request.host,
|
|
29
|
-
path: response.request.path.split('?')[0],
|
|
30
|
-
};
|
|
31
|
-
response.config.metadata.endTimer(labels);
|
|
32
|
-
return response;
|
|
33
|
-
}, error => {
|
|
34
|
-
const labels = {
|
|
35
|
-
status_code: error.response.status,
|
|
36
|
-
method: error.response.request.method,
|
|
37
|
-
protocol: error.response.request.protocol,
|
|
38
|
-
host: error.response.request.host,
|
|
39
|
-
path: error.response.request.path.split('?')[0],
|
|
40
|
-
};
|
|
41
|
-
error.config.metadata.endTimer(labels);
|
|
42
|
-
return Promise.reject(error);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
exports.createAxiosPrometheusMiddleware = createAxiosPrometheusMiddleware;
|
|
46
|
-
//# sourceMappingURL=AxiosPrometheusAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosPrometheusAdapter.js","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