@midwayjs/prometheus 3.5.3 → 3.6.1-beta.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/dist/configuration.js +6 -6
- package/dist/decorator/master.js +3 -3
- package/dist/index.js +1 -5
- package/dist/service/dataService.d.ts +1 -0
- package/dist/service/dataService.js +13 -4
- package/package.json +7 -8
- package/LICENSE +0 -21
package/dist/configuration.js
CHANGED
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PrometheusConfiguration = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const PromClient = require("prom-client");
|
|
15
15
|
const utils_1 = require("./utils/utils");
|
|
16
16
|
const os = require("os");
|
|
@@ -23,7 +23,7 @@ const DefaultConfig = require("./config/config.default");
|
|
|
23
23
|
let PrometheusConfiguration = class PrometheusConfiguration {
|
|
24
24
|
async onReady() {
|
|
25
25
|
PromClient.collectDefaultMetrics(this.prometheusConfig);
|
|
26
|
-
const modules = (0,
|
|
26
|
+
const modules = (0, core_1.listModule)('prometheus:master');
|
|
27
27
|
const handlers = {};
|
|
28
28
|
let sockFile = path.join(os.tmpdir(), 'midway-master.sock');
|
|
29
29
|
if (process.platform === 'win32') {
|
|
@@ -47,7 +47,7 @@ let PrometheusConfiguration = class PrometheusConfiguration {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
for (const module of modules) {
|
|
50
|
-
const rules = (0,
|
|
50
|
+
const rules = (0, core_1.getClassMetadata)('prometheus:master:options', module);
|
|
51
51
|
for (const rule of rules) {
|
|
52
52
|
if ((0, utils_1.isMaster)()) {
|
|
53
53
|
handlers[rule.name] = async (...args) => {
|
|
@@ -92,15 +92,15 @@ let PrometheusConfiguration = class PrometheusConfiguration {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
__decorate([
|
|
95
|
-
(0,
|
|
95
|
+
(0, core_1.Config)('prometheus'),
|
|
96
96
|
__metadata("design:type", Object)
|
|
97
97
|
], PrometheusConfiguration.prototype, "prometheusConfig", void 0);
|
|
98
98
|
__decorate([
|
|
99
|
-
(0,
|
|
99
|
+
(0, core_1.App)(),
|
|
100
100
|
__metadata("design:type", Object)
|
|
101
101
|
], PrometheusConfiguration.prototype, "app", void 0);
|
|
102
102
|
PrometheusConfiguration = __decorate([
|
|
103
|
-
(0,
|
|
103
|
+
(0, core_1.Configuration)({
|
|
104
104
|
namespace: 'prometheus',
|
|
105
105
|
importConfigs: [
|
|
106
106
|
{
|
package/dist/decorator/master.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Master = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const request = require("request");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const os = require("os");
|
|
@@ -9,7 +9,7 @@ const utils_1 = require("../utils/utils");
|
|
|
9
9
|
const qs = require("querystring");
|
|
10
10
|
function Master() {
|
|
11
11
|
return function (target, propertyKey, descriptor) {
|
|
12
|
-
(0,
|
|
12
|
+
(0, core_1.saveModule)('prometheus:master', target.constructor);
|
|
13
13
|
const sockFile = path.join(os.tmpdir(), 'midway-master.sock');
|
|
14
14
|
if (!(0, utils_1.isMaster)()) {
|
|
15
15
|
descriptor.value = (...args) => {
|
|
@@ -26,7 +26,7 @@ function Master() {
|
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
(0,
|
|
29
|
+
(0, core_1.attachClassMetadata)('prometheus:master:options', {
|
|
30
30
|
name: `${target.constructor.name}_${propertyKey}`,
|
|
31
31
|
value: descriptor.value,
|
|
32
32
|
}, target.constructor);
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -10,6 +10,7 @@ export declare class DataService {
|
|
|
10
10
|
getUser(method: any, status: any, path: any, time: any): Promise<void>;
|
|
11
11
|
define(name: any, type: any, options: any): void;
|
|
12
12
|
inc(name: any, labels: any, value?: number): Promise<void>;
|
|
13
|
+
observe(name: any, labels: any, value: any): Promise<void>;
|
|
13
14
|
set(name: any, value: any): Promise<void>;
|
|
14
15
|
setDiff(name: any, diff: any): Promise<void>;
|
|
15
16
|
getData(): Promise<string>;
|
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.DataService = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const Client = require("prom-client");
|
|
15
15
|
const master_1 = require("../decorator/master");
|
|
16
16
|
const PromClient = require("prom-client");
|
|
@@ -63,6 +63,9 @@ let DataService = class DataService {
|
|
|
63
63
|
async inc(name, labels, value = 1) {
|
|
64
64
|
this.userDefinedMetrics[name].inc({ ...labels, ...this.prometheusConfig.labels }, value);
|
|
65
65
|
}
|
|
66
|
+
async observe(name, labels, value) {
|
|
67
|
+
this.userDefinedMetrics[name].labels(...labels, ...Object.values(this.prometheusConfig.labels)).observe(value);
|
|
68
|
+
}
|
|
66
69
|
async set(name, value) {
|
|
67
70
|
this.userDefinedMetrics[name].set({ ...this.prometheusConfig.labels }, value);
|
|
68
71
|
}
|
|
@@ -80,7 +83,7 @@ let DataService = class DataService {
|
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
__decorate([
|
|
83
|
-
(0,
|
|
86
|
+
(0, core_1.Config)('prometheus'),
|
|
84
87
|
__metadata("design:type", Object)
|
|
85
88
|
], DataService.prototype, "prometheusConfig", void 0);
|
|
86
89
|
__decorate([
|
|
@@ -95,6 +98,12 @@ __decorate([
|
|
|
95
98
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
96
99
|
__metadata("design:returntype", Promise)
|
|
97
100
|
], DataService.prototype, "inc", null);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, master_1.Master)(),
|
|
103
|
+
__metadata("design:type", Function),
|
|
104
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
105
|
+
__metadata("design:returntype", Promise)
|
|
106
|
+
], DataService.prototype, "observe", null);
|
|
98
107
|
__decorate([
|
|
99
108
|
(0, master_1.Master)(),
|
|
100
109
|
__metadata("design:type", Function),
|
|
@@ -114,8 +123,8 @@ __decorate([
|
|
|
114
123
|
__metadata("design:returntype", Promise)
|
|
115
124
|
], DataService.prototype, "getData", null);
|
|
116
125
|
DataService = __decorate([
|
|
117
|
-
(0,
|
|
118
|
-
(0,
|
|
126
|
+
(0, core_1.Provide)(),
|
|
127
|
+
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
|
119
128
|
], DataService);
|
|
120
129
|
exports.DataService = DataService;
|
|
121
130
|
//# sourceMappingURL=dataService.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/prometheus",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1-beta.0",
|
|
4
4
|
"description": "midway component for prometheus",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@midwayjs/core": "^3.
|
|
27
|
-
"@midwayjs/
|
|
28
|
-
"@midwayjs/
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
26
|
+
"@midwayjs/core": "^3.6.0",
|
|
27
|
+
"@midwayjs/koa": "^3.6.0",
|
|
28
|
+
"@midwayjs/mock": "^3.6.0",
|
|
29
|
+
"@types/request": "2.48.8",
|
|
30
|
+
"typescript": "4.5.4"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"prom-client": "^14.0.0",
|
|
@@ -35,6 +35,5 @@
|
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=12"
|
|
38
|
-
}
|
|
39
|
-
"gitHead": "32356484664846984f6d3d65a3a75dea015e8dcc"
|
|
38
|
+
}
|
|
40
39
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|