@theia/metrics 1.34.1 → 1.34.3
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/LICENSE +641 -641
- package/README.md +30 -30
- package/lib/node/extensions-metrics-contribution.d.ts +8 -8
- package/lib/node/extensions-metrics-contribution.js +62 -62
- package/lib/node/index.d.ts +5 -5
- package/lib/node/index.js +32 -32
- package/lib/node/metrics-backend-application-contribution.d.ts +15 -15
- package/lib/node/metrics-backend-application-contribution.js +59 -59
- package/lib/node/metrics-backend-module.d.ts +3 -3
- package/lib/node/metrics-backend-module.js +30 -30
- package/lib/node/metrics-contribution.d.ts +5 -5
- package/lib/node/metrics-contribution.js +19 -19
- package/lib/node/node-metrics-contribution.d.ts +5 -5
- package/lib/node/node-metrics-contribution.js +40 -40
- package/lib/node/prometheus.d.ts +2 -2
- package/lib/node/prometheus.js +27 -27
- package/lib/node/prometheus.spec.d.ts +1 -1
- package/lib/node/prometheus.spec.js +40 -40
- package/package.json +4 -4
- package/src/node/extensions-metrics-contribution.ts +51 -51
- package/src/node/index.ts +21 -21
- package/src/node/metrics-backend-application-contribution.ts +50 -50
- package/src/node/metrics-backend-module.ts +32 -32
- package/src/node/metrics-contribution.ts +20 -20
- package/src/node/node-metrics-contribution.ts +33 -33
- package/src/node/prometheus.spec.ts +49 -49
- package/src/node/prometheus.ts +25 -25
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
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;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.NodeMetricsContribution = void 0;
|
|
25
|
-
const prom = require("prom-client");
|
|
26
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
27
|
-
let NodeMetricsContribution = class NodeMetricsContribution {
|
|
28
|
-
getMetrics() {
|
|
29
|
-
return prom.register.metrics().toString();
|
|
30
|
-
}
|
|
31
|
-
startCollecting() {
|
|
32
|
-
const collectDefaultMetrics = prom.collectDefaultMetrics;
|
|
33
|
-
// Probe every 5th second.
|
|
34
|
-
collectDefaultMetrics({ timeout: 5000 });
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
NodeMetricsContribution = __decorate([
|
|
38
|
-
(0, inversify_1.injectable)()
|
|
39
|
-
], NodeMetricsContribution);
|
|
40
|
-
exports.NodeMetricsContribution = NodeMetricsContribution;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
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;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.NodeMetricsContribution = void 0;
|
|
25
|
+
const prom = require("prom-client");
|
|
26
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
27
|
+
let NodeMetricsContribution = class NodeMetricsContribution {
|
|
28
|
+
getMetrics() {
|
|
29
|
+
return prom.register.metrics().toString();
|
|
30
|
+
}
|
|
31
|
+
startCollecting() {
|
|
32
|
+
const collectDefaultMetrics = prom.collectDefaultMetrics;
|
|
33
|
+
// Probe every 5th second.
|
|
34
|
+
collectDefaultMetrics({ timeout: 5000 });
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
NodeMetricsContribution = __decorate([
|
|
38
|
+
(0, inversify_1.injectable)()
|
|
39
|
+
], NodeMetricsContribution);
|
|
40
|
+
exports.NodeMetricsContribution = NodeMetricsContribution;
|
|
41
41
|
//# sourceMappingURL=node-metrics-contribution.js.map
|
package/lib/node/prometheus.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function toPrometheusValidName(name: string): string;
|
|
2
|
-
export declare const PROMETHEUS_REGEXP: RegExp;
|
|
1
|
+
export declare function toPrometheusValidName(name: string): string;
|
|
2
|
+
export declare const PROMETHEUS_REGEXP: RegExp;
|
|
3
3
|
//# sourceMappingURL=prometheus.d.ts.map
|
package/lib/node/prometheus.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.PROMETHEUS_REGEXP = exports.toPrometheusValidName = void 0;
|
|
19
|
-
function toPrometheusValidName(name) {
|
|
20
|
-
/* Make sure that start of name is valid and respect [a-zA-Z_:] */
|
|
21
|
-
const validFirstCharString = name.replace(/(^[^a-zA-Z_:]+)/gi, '');
|
|
22
|
-
/* Make sure that rest of the name respect [a-zA-Z0-9_:]* */
|
|
23
|
-
const validPrometheusName = validFirstCharString.replace(/([^a-zA-Z0-9_:])/gi, '_');
|
|
24
|
-
return validPrometheusName;
|
|
25
|
-
}
|
|
26
|
-
exports.toPrometheusValidName = toPrometheusValidName;
|
|
27
|
-
exports.PROMETHEUS_REGEXP = /^[a-zA-Z_:][a-zA-Z0-9_:]*/;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PROMETHEUS_REGEXP = exports.toPrometheusValidName = void 0;
|
|
19
|
+
function toPrometheusValidName(name) {
|
|
20
|
+
/* Make sure that start of name is valid and respect [a-zA-Z_:] */
|
|
21
|
+
const validFirstCharString = name.replace(/(^[^a-zA-Z_:]+)/gi, '');
|
|
22
|
+
/* Make sure that rest of the name respect [a-zA-Z0-9_:]* */
|
|
23
|
+
const validPrometheusName = validFirstCharString.replace(/([^a-zA-Z0-9_:])/gi, '_');
|
|
24
|
+
return validPrometheusName;
|
|
25
|
+
}
|
|
26
|
+
exports.toPrometheusValidName = toPrometheusValidName;
|
|
27
|
+
exports.PROMETHEUS_REGEXP = /^[a-zA-Z_:][a-zA-Z0-9_:]*/;
|
|
28
28
|
//# sourceMappingURL=prometheus.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=prometheus.spec.d.ts.map
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const chai = require("chai");
|
|
19
|
-
const prometheus_1 = require("./prometheus");
|
|
20
|
-
const expect = chai.expect;
|
|
21
|
-
describe('Prometheus helper module', () => {
|
|
22
|
-
/* According to https://prometheus.io/docs/concepts/data_model/ */
|
|
23
|
-
const validName = 'theia_extension3242-:';
|
|
24
|
-
const invalidTheiaName = '@theia/something';
|
|
25
|
-
const validTheiaName = 'theia_something';
|
|
26
|
-
const invalidName2 = '@theia/?$%^ ';
|
|
27
|
-
it('Should correctly validate a metric name', () => {
|
|
28
|
-
expect(prometheus_1.PROMETHEUS_REGEXP.test(validName)).to.be.true;
|
|
29
|
-
expect(prometheus_1.PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
30
|
-
expect(prometheus_1.PROMETHEUS_REGEXP.test(invalidName2)).to.be.false;
|
|
31
|
-
});
|
|
32
|
-
it('Should correctly return a valid name from an otherwise invalid prometheus string', () => {
|
|
33
|
-
expect(prometheus_1.PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
34
|
-
const newName = (0, prometheus_1.toPrometheusValidName)(invalidTheiaName);
|
|
35
|
-
expect(prometheus_1.PROMETHEUS_REGEXP.test(newName)).to.be.true;
|
|
36
|
-
expect(newName).to.be.equal(validTheiaName);
|
|
37
|
-
const newName2 = (0, prometheus_1.toPrometheusValidName)(invalidName2);
|
|
38
|
-
expect(prometheus_1.PROMETHEUS_REGEXP.test(newName2)).to.be.true;
|
|
39
|
-
});
|
|
40
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const chai = require("chai");
|
|
19
|
+
const prometheus_1 = require("./prometheus");
|
|
20
|
+
const expect = chai.expect;
|
|
21
|
+
describe('Prometheus helper module', () => {
|
|
22
|
+
/* According to https://prometheus.io/docs/concepts/data_model/ */
|
|
23
|
+
const validName = 'theia_extension3242-:';
|
|
24
|
+
const invalidTheiaName = '@theia/something';
|
|
25
|
+
const validTheiaName = 'theia_something';
|
|
26
|
+
const invalidName2 = '@theia/?$%^ ';
|
|
27
|
+
it('Should correctly validate a metric name', () => {
|
|
28
|
+
expect(prometheus_1.PROMETHEUS_REGEXP.test(validName)).to.be.true;
|
|
29
|
+
expect(prometheus_1.PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
30
|
+
expect(prometheus_1.PROMETHEUS_REGEXP.test(invalidName2)).to.be.false;
|
|
31
|
+
});
|
|
32
|
+
it('Should correctly return a valid name from an otherwise invalid prometheus string', () => {
|
|
33
|
+
expect(prometheus_1.PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
34
|
+
const newName = (0, prometheus_1.toPrometheusValidName)(invalidTheiaName);
|
|
35
|
+
expect(prometheus_1.PROMETHEUS_REGEXP.test(newName)).to.be.true;
|
|
36
|
+
expect(newName).to.be.equal(validTheiaName);
|
|
37
|
+
const newName2 = (0, prometheus_1.toPrometheusValidName)(invalidName2);
|
|
38
|
+
expect(prometheus_1.PROMETHEUS_REGEXP.test(newName2)).to.be.true;
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
41
|
//# sourceMappingURL=prometheus.spec.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/metrics",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.3",
|
|
4
4
|
"description": "Theia - Metrics Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.34.
|
|
6
|
+
"@theia/core": "1.34.3",
|
|
7
7
|
"prom-client": "^10.2.0"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"watch": "theiaext watch"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@theia/ext-scripts": "1.34.
|
|
42
|
+
"@theia/ext-scripts": "1.34.3"
|
|
43
43
|
},
|
|
44
44
|
"nyc": {
|
|
45
45
|
"extends": "../../configs/nyc.json"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "a6cf9fe96b1624d6e27a11dce2ebdeae820478e5"
|
|
48
48
|
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
17
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
18
|
-
import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
|
|
19
|
-
import { PROMETHEUS_REGEXP, toPrometheusValidName } from './prometheus';
|
|
20
|
-
|
|
21
|
-
const metricsName = 'theia_extension_version';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class ExtensionMetricsContribution implements MetricsContribution {
|
|
25
|
-
private metrics: string = '';
|
|
26
|
-
|
|
27
|
-
@inject(ApplicationPackage)
|
|
28
|
-
protected readonly applicationPackage: ApplicationPackage;
|
|
29
|
-
|
|
30
|
-
getMetrics(): string {
|
|
31
|
-
return this.metrics;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
startCollecting(): void {
|
|
35
|
-
let latestMetrics = '';
|
|
36
|
-
const installedExtensions = this.applicationPackage.extensionPackages;
|
|
37
|
-
latestMetrics += `# HELP ${metricsName} Theia extension version info.\n`;
|
|
38
|
-
latestMetrics += `# TYPE ${metricsName} gauge\n`;
|
|
39
|
-
installedExtensions.forEach(extensionInfo => {
|
|
40
|
-
let extensionName = extensionInfo.name;
|
|
41
|
-
if (!PROMETHEUS_REGEXP.test(extensionName)) {
|
|
42
|
-
extensionName = toPrometheusValidName(extensionName);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const metricsValue = metricsName + `{extension="${extensionName}",version="${extensionInfo.version}"} 1`;
|
|
46
|
-
latestMetrics += metricsValue + '\n';
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
this.metrics = latestMetrics;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
17
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
18
|
+
import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
|
|
19
|
+
import { PROMETHEUS_REGEXP, toPrometheusValidName } from './prometheus';
|
|
20
|
+
|
|
21
|
+
const metricsName = 'theia_extension_version';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class ExtensionMetricsContribution implements MetricsContribution {
|
|
25
|
+
private metrics: string = '';
|
|
26
|
+
|
|
27
|
+
@inject(ApplicationPackage)
|
|
28
|
+
protected readonly applicationPackage: ApplicationPackage;
|
|
29
|
+
|
|
30
|
+
getMetrics(): string {
|
|
31
|
+
return this.metrics;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
startCollecting(): void {
|
|
35
|
+
let latestMetrics = '';
|
|
36
|
+
const installedExtensions = this.applicationPackage.extensionPackages;
|
|
37
|
+
latestMetrics += `# HELP ${metricsName} Theia extension version info.\n`;
|
|
38
|
+
latestMetrics += `# TYPE ${metricsName} gauge\n`;
|
|
39
|
+
installedExtensions.forEach(extensionInfo => {
|
|
40
|
+
let extensionName = extensionInfo.name;
|
|
41
|
+
if (!PROMETHEUS_REGEXP.test(extensionName)) {
|
|
42
|
+
extensionName = toPrometheusValidName(extensionName);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const metricsValue = metricsName + `{extension="${extensionName}",version="${extensionInfo.version}"} 1`;
|
|
46
|
+
latestMetrics += metricsValue + '\n';
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
this.metrics = latestMetrics;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/node/index.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
export * from './metrics-backend-application-contribution';
|
|
18
|
-
export * from './metrics-contribution';
|
|
19
|
-
export * from './node-metrics-contribution';
|
|
20
|
-
export * from './extensions-metrics-contribution';
|
|
21
|
-
export * from './prometheus';
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export * from './metrics-backend-application-contribution';
|
|
18
|
+
export * from './metrics-contribution';
|
|
19
|
+
export * from './node-metrics-contribution';
|
|
20
|
+
export * from './extensions-metrics-contribution';
|
|
21
|
+
export * from './prometheus';
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject, named } from '@theia/core/shared/inversify';
|
|
18
|
-
import * as http from 'http';
|
|
19
|
-
import * as https from 'https';
|
|
20
|
-
import * as express from '@theia/core/shared/express';
|
|
21
|
-
import { ContributionProvider } from '@theia/core/lib/common';
|
|
22
|
-
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
23
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
24
|
-
|
|
25
|
-
@injectable()
|
|
26
|
-
export class MetricsBackendApplicationContribution implements BackendApplicationContribution {
|
|
27
|
-
constructor(
|
|
28
|
-
@inject(ContributionProvider) @named(MetricsContribution)
|
|
29
|
-
protected readonly metricsProviders: ContributionProvider<MetricsContribution>
|
|
30
|
-
) {
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
configure(app: express.Application): void {
|
|
34
|
-
app.get('/metrics', (req, res) => {
|
|
35
|
-
const lastMetrics = this.fetchMetricsFromProviders();
|
|
36
|
-
res.send(lastMetrics);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
onStart(server: http.Server | https.Server): void {
|
|
41
|
-
this.metricsProviders.getContributions().forEach(contribution => {
|
|
42
|
-
contribution.startCollecting();
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
fetchMetricsFromProviders(): string {
|
|
47
|
-
return this.metricsProviders.getContributions().reduce((total, contribution) =>
|
|
48
|
-
total += contribution.getMetrics() + '\n', '');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject, named } from '@theia/core/shared/inversify';
|
|
18
|
+
import * as http from 'http';
|
|
19
|
+
import * as https from 'https';
|
|
20
|
+
import * as express from '@theia/core/shared/express';
|
|
21
|
+
import { ContributionProvider } from '@theia/core/lib/common';
|
|
22
|
+
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
23
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
24
|
+
|
|
25
|
+
@injectable()
|
|
26
|
+
export class MetricsBackendApplicationContribution implements BackendApplicationContribution {
|
|
27
|
+
constructor(
|
|
28
|
+
@inject(ContributionProvider) @named(MetricsContribution)
|
|
29
|
+
protected readonly metricsProviders: ContributionProvider<MetricsContribution>
|
|
30
|
+
) {
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
configure(app: express.Application): void {
|
|
34
|
+
app.get('/metrics', (req, res) => {
|
|
35
|
+
const lastMetrics = this.fetchMetricsFromProviders();
|
|
36
|
+
res.send(lastMetrics);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onStart(server: http.Server | https.Server): void {
|
|
41
|
+
this.metricsProviders.getContributions().forEach(contribution => {
|
|
42
|
+
contribution.startCollecting();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fetchMetricsFromProviders(): string {
|
|
47
|
+
return this.metricsProviders.getContributions().reduce((total, contribution) =>
|
|
48
|
+
total += contribution.getMetrics() + '\n', '');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
-
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
19
|
-
import { bindContributionProvider } from '@theia/core/lib/common';
|
|
20
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
21
|
-
import { NodeMetricsContribution } from './node-metrics-contribution';
|
|
22
|
-
import { ExtensionMetricsContribution } from './extensions-metrics-contribution';
|
|
23
|
-
import { MetricsBackendApplicationContribution } from './metrics-backend-application-contribution';
|
|
24
|
-
|
|
25
|
-
export default new ContainerModule(bind => {
|
|
26
|
-
bindContributionProvider(bind, MetricsContribution);
|
|
27
|
-
bind(MetricsContribution).to(NodeMetricsContribution).inSingletonScope();
|
|
28
|
-
bind(MetricsContribution).to(ExtensionMetricsContribution).inSingletonScope();
|
|
29
|
-
|
|
30
|
-
bind(BackendApplicationContribution).to(MetricsBackendApplicationContribution).inSingletonScope();
|
|
31
|
-
|
|
32
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
19
|
+
import { bindContributionProvider } from '@theia/core/lib/common';
|
|
20
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
21
|
+
import { NodeMetricsContribution } from './node-metrics-contribution';
|
|
22
|
+
import { ExtensionMetricsContribution } from './extensions-metrics-contribution';
|
|
23
|
+
import { MetricsBackendApplicationContribution } from './metrics-backend-application-contribution';
|
|
24
|
+
|
|
25
|
+
export default new ContainerModule(bind => {
|
|
26
|
+
bindContributionProvider(bind, MetricsContribution);
|
|
27
|
+
bind(MetricsContribution).to(NodeMetricsContribution).inSingletonScope();
|
|
28
|
+
bind(MetricsContribution).to(ExtensionMetricsContribution).inSingletonScope();
|
|
29
|
+
|
|
30
|
+
bind(BackendApplicationContribution).to(MetricsBackendApplicationContribution).inSingletonScope();
|
|
31
|
+
|
|
32
|
+
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
export const MetricsContribution = Symbol('MetricsContribution');
|
|
17
|
-
export interface MetricsContribution {
|
|
18
|
-
startCollecting(): void;
|
|
19
|
-
getMetrics(): string;
|
|
20
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
export const MetricsContribution = Symbol('MetricsContribution');
|
|
17
|
+
export interface MetricsContribution {
|
|
18
|
+
startCollecting(): void;
|
|
19
|
+
getMetrics(): string;
|
|
20
|
+
}
|