axios-prometheus-adapter 0.0.5 → 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
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","sourceRoot":"","sources":["../../lib/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