@spinajs/metrics 2.0.42
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/README.md +11 -0
- package/lib/config/metrics.d.ts +0 -0
- package/lib/config/metrics.js +7 -0
- package/lib/config/metrics.js.map +1 -0
- package/lib/controllers/metrics.d.ts +9 -0
- package/lib/controllers/metrics.js +50 -0
- package/lib/controllers/metrics.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +62 -0
- package/lib/index.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/config/metrics.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,qBAAqB;AACrB,YAAY;AACZ,uBAAuB;AACvB,OAAO;AACP,KAAK"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Bootstrapper } from '@spinajs/di';
|
|
2
|
+
import * as client from 'prom-client';
|
|
3
|
+
export declare const gauge: typeof client.Gauge;
|
|
4
|
+
export declare const histogram: typeof client.Histogram;
|
|
5
|
+
export declare const summary: typeof client.Summary;
|
|
6
|
+
export declare const counter: typeof client.Counter;
|
|
7
|
+
export declare class MetricsBootstrapper extends Bootstrapper {
|
|
8
|
+
bootstrap(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.MetricsBootstrapper = exports.counter = exports.summary = exports.histogram = exports.gauge = void 0;
|
|
33
|
+
const di_1 = require("@spinajs/di");
|
|
34
|
+
const client = __importStar(require("prom-client"));
|
|
35
|
+
exports.gauge = client.Gauge;
|
|
36
|
+
exports.histogram = client.Histogram;
|
|
37
|
+
exports.summary = client.Summary;
|
|
38
|
+
exports.counter = client.Counter;
|
|
39
|
+
let MetricsBootstrapper = class MetricsBootstrapper extends di_1.Bootstrapper {
|
|
40
|
+
bootstrap() {
|
|
41
|
+
client.collectDefaultMetrics({
|
|
42
|
+
labels: { NODE_APP_INSTANCE: process.env.NODE_APP_INSTANCE },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
MetricsBootstrapper = __decorate([
|
|
47
|
+
(0, di_1.Injectable)(di_1.Bootstrapper)
|
|
48
|
+
], MetricsBootstrapper);
|
|
49
|
+
exports.MetricsBootstrapper = MetricsBootstrapper;
|
|
50
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/controllers/metrics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAuD;AACvD,oDAAsC;AAEzB,QAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACrB,QAAA,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;AAC7B,QAAA,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;AACzB,QAAA,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;AAEtC,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,iBAAY;IAC5C,SAAS;QACd,MAAM,CAAC,qBAAqB,CAAC;YAC3B,MAAM,EAAE,EAAE,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;SAC7D,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AANY,mBAAmB;IAD/B,IAAA,eAAU,EAAC,iBAAY,CAAC;GACZ,mBAAmB,CAM/B;AANY,kDAAmB"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseController, Response } from '@spinajs/http';
|
|
2
|
+
import * as express from 'express';
|
|
3
|
+
declare class PrometheusResponse extends Response {
|
|
4
|
+
constructor();
|
|
5
|
+
execute(_req: express.Request, res: express.Response): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare class Metrics extends BaseController {
|
|
8
|
+
getMetrics(): Promise<PrometheusResponse>;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.Metrics = void 0;
|
|
36
|
+
const http_1 = require("@spinajs/http");
|
|
37
|
+
const client = __importStar(require("prom-client"));
|
|
38
|
+
class PrometheusResponse extends http_1.Response {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(null);
|
|
41
|
+
}
|
|
42
|
+
async execute(_req, res) {
|
|
43
|
+
res.contentType(client.register.contentType);
|
|
44
|
+
res.end(client.register.metrics());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let Metrics = class Metrics extends http_1.BaseController {
|
|
48
|
+
async getMetrics() {
|
|
49
|
+
return new PrometheusResponse();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, http_1.Get)(),
|
|
54
|
+
__metadata("design:type", Function),
|
|
55
|
+
__metadata("design:paramtypes", []),
|
|
56
|
+
__metadata("design:returntype", Promise)
|
|
57
|
+
], Metrics.prototype, "getMetrics", null);
|
|
58
|
+
Metrics = __decorate([
|
|
59
|
+
(0, http_1.BasePath)('metrics')
|
|
60
|
+
], Metrics);
|
|
61
|
+
exports.Metrics = Metrics;
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAwE;AACxE,oDAAsC;AAGtC,MAAM,kBAAmB,SAAQ,eAAQ;IACvC;QACE,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,GAAqB;QAC/D,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC7C,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AAGD,IAAa,OAAO,GAApB,MAAa,OAAQ,SAAQ,qBAAc;IAElC,KAAK,CAAC,UAAU;QACrB,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;CACF,CAAA;AAHC;IADC,IAAA,UAAG,GAAE;;;;yCAGL;AAJU,OAAO;IADnB,IAAA,eAAQ,EAAC,SAAS,CAAC;GACP,OAAO,CAKnB;AALY,0BAAO"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spinajs/metrics",
|
|
3
|
+
"version": "2.0.42",
|
|
4
|
+
"description": "metrics integration for spinajs using prometheus",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"private": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run clean && npm run compile",
|
|
9
|
+
"compile": "tsc -p tsconfig.build.json",
|
|
10
|
+
"clean": "",
|
|
11
|
+
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
|
|
12
|
+
"coverage": "nyc npm run test",
|
|
13
|
+
"build-docs": "rimraf docs && typedoc --options typedoc.json src/",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
16
|
+
"lint": "eslint -c .eslintrc.js --ext .ts src --fix",
|
|
17
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
18
|
+
"preversion": "npm run lint",
|
|
19
|
+
"version": "npm run format && git add -A src",
|
|
20
|
+
"postversion": "git push && git push --tags"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"lib/**/*"
|
|
24
|
+
],
|
|
25
|
+
"types": "lib",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/spinajs/main.git"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"spinajs",
|
|
32
|
+
"intl"
|
|
33
|
+
],
|
|
34
|
+
"author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/main)",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/spinajs/main/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/spinajs/main#readme",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@spinajs/di": "^2.0.39",
|
|
42
|
+
"@spinajs/exceptions": "^2.0.39",
|
|
43
|
+
"@spinajs/http": "^2.0.40",
|
|
44
|
+
"express-prom-bundle": "^6.6.0",
|
|
45
|
+
"prom-client": "^14.1.0"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "7fc83eae6c8ee64caf808938c816a9b2b38d3be6"
|
|
48
|
+
}
|