@theia/metrics 1.40.1 → 1.41.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.
Files changed (30) hide show
  1. package/lib/browser/metrics-frontend-application-contribution.d.ts +13 -0
  2. package/lib/browser/metrics-frontend-application-contribution.d.ts.map +1 -0
  3. package/lib/browser/metrics-frontend-application-contribution.js +67 -0
  4. package/lib/browser/metrics-frontend-application-contribution.js.map +1 -0
  5. package/lib/browser/metrics-frontend-module.d.ts +4 -0
  6. package/lib/browser/metrics-frontend-module.d.ts.map +1 -0
  7. package/lib/browser/metrics-frontend-module.js +29 -0
  8. package/lib/browser/metrics-frontend-module.js.map +1 -0
  9. package/lib/common/index.d.ts +2 -0
  10. package/lib/common/index.d.ts.map +1 -0
  11. package/lib/common/index.js +29 -0
  12. package/lib/common/index.js.map +1 -0
  13. package/lib/common/measurement-notification-service.d.ts +12 -0
  14. package/lib/common/measurement-notification-service.d.ts.map +1 -0
  15. package/lib/common/measurement-notification-service.js +21 -0
  16. package/lib/common/measurement-notification-service.js.map +1 -0
  17. package/lib/node/measurement-metrics-contribution.d.ts +18 -0
  18. package/lib/node/measurement-metrics-contribution.d.ts.map +1 -0
  19. package/lib/node/measurement-metrics-contribution.js +84 -0
  20. package/lib/node/measurement-metrics-contribution.js.map +1 -0
  21. package/lib/node/metrics-backend-module.d.ts.map +1 -1
  22. package/lib/node/metrics-backend-module.js +5 -0
  23. package/lib/node/metrics-backend-module.js.map +1 -1
  24. package/package.json +5 -4
  25. package/src/browser/metrics-frontend-application-contribution.ts +51 -0
  26. package/src/browser/metrics-frontend-module.ts +28 -0
  27. package/src/common/index.ts +17 -0
  28. package/src/common/measurement-notification-service.ts +29 -0
  29. package/src/node/measurement-metrics-contribution.ts +75 -0
  30. package/src/node/metrics-backend-module.ts +9 -1
@@ -0,0 +1,13 @@
1
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser';
2
+ import { ILogger, MeasurementResult, Stopwatch } from '@theia/core';
3
+ import { MeasurementNotificationService } from '../common';
4
+ export declare class MetricsFrontendApplicationContribution implements FrontendApplicationContribution {
5
+ protected stopwatch: Stopwatch;
6
+ protected notificationService: MeasurementNotificationService;
7
+ protected logger: ILogger;
8
+ readonly id: string;
9
+ initialize(): void;
10
+ protected doInitialize(): Promise<void>;
11
+ protected notify(result: MeasurementResult): void;
12
+ }
13
+ //# sourceMappingURL=metrics-frontend-application-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/metrics-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAY,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAE3D,qBACa,sCAAuC,YAAW,+BAA+B;IAE1F,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAG/B,SAAS,CAAC,mBAAmB,EAAE,8BAA8B,CAAC;IAG9D,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAE1B,QAAQ,CAAC,EAAE,SAAgB;IAE3B,UAAU,IAAI,IAAI;cAIF,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAS7C,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;CAGpD"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MetricsFrontendApplicationContribution = void 0;
13
+ // *****************************************************************************
14
+ // Copyright (C) 2023 STMicroelectronics and others.
15
+ //
16
+ // This program and the accompanying materials are made available under the
17
+ // terms of the Eclipse Public License v. 2.0 which is available at
18
+ // http://www.eclipse.org/legal/epl-2.0.
19
+ //
20
+ // This Source Code may also be made available under the following Secondary
21
+ // Licenses when the conditions for such availability set forth in the Eclipse
22
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
+ // with the GNU Classpath Exception which is available at
24
+ // https://www.gnu.org/software/classpath/license.html.
25
+ //
26
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
27
+ // *****************************************************************************
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const core_1 = require("@theia/core");
30
+ const coreutils_1 = require("@theia/core/shared/@phosphor/coreutils");
31
+ const common_1 = require("../common");
32
+ let MetricsFrontendApplicationContribution = class MetricsFrontendApplicationContribution {
33
+ constructor() {
34
+ this.id = coreutils_1.UUID.uuid4();
35
+ }
36
+ initialize() {
37
+ this.doInitialize();
38
+ }
39
+ async doInitialize() {
40
+ const logLevel = await this.logger.getLogLevel();
41
+ if (logLevel !== core_1.LogLevel.DEBUG) {
42
+ return;
43
+ }
44
+ this.stopwatch.storedMeasurements.forEach(result => this.notify(result));
45
+ this.stopwatch.onDidAddMeasurementResult(result => this.notify(result));
46
+ }
47
+ notify(result) {
48
+ this.notificationService.onFrontendMeasurement(this.id, result);
49
+ }
50
+ };
51
+ __decorate([
52
+ (0, inversify_1.inject)(core_1.Stopwatch),
53
+ __metadata("design:type", core_1.Stopwatch)
54
+ ], MetricsFrontendApplicationContribution.prototype, "stopwatch", void 0);
55
+ __decorate([
56
+ (0, inversify_1.inject)(common_1.MeasurementNotificationService),
57
+ __metadata("design:type", Object)
58
+ ], MetricsFrontendApplicationContribution.prototype, "notificationService", void 0);
59
+ __decorate([
60
+ (0, inversify_1.inject)(core_1.ILogger),
61
+ __metadata("design:type", Object)
62
+ ], MetricsFrontendApplicationContribution.prototype, "logger", void 0);
63
+ MetricsFrontendApplicationContribution = __decorate([
64
+ (0, inversify_1.injectable)()
65
+ ], MetricsFrontendApplicationContribution);
66
+ exports.MetricsFrontendApplicationContribution = MetricsFrontendApplicationContribution;
67
+ //# sourceMappingURL=metrics-frontend-application-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/metrics-frontend-application-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,4DAAkE;AAElE,sCAA8E;AAC9E,sEAA8D;AAC9D,sCAA2D;AAG3D,IAAa,sCAAsC,GAAnD,MAAa,sCAAsC;IAAnD;QAUa,OAAE,GAAG,gBAAI,CAAC,KAAK,EAAE,CAAC;IAkB/B,CAAC;IAhBG,UAAU;QACN,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAES,KAAK,CAAC,YAAY;QACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACjD,IAAI,QAAQ,KAAK,eAAQ,CAAC,KAAK,EAAE;YAC7B,OAAO;SACV;QACD,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5E,CAAC;IAES,MAAM,CAAC,MAAyB;QACtC,IAAI,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;CACJ,CAAA;AA1BG;IADC,IAAA,kBAAM,EAAC,gBAAS,CAAC;8BACG,gBAAS;yEAAC;AAG/B;IADC,IAAA,kBAAM,EAAC,uCAA8B,CAAC;;mFACuB;AAG9D;IADC,IAAA,kBAAM,EAAC,cAAO,CAAC;;sEACU;AARjB,sCAAsC;IADlD,IAAA,sBAAU,GAAE;GACA,sCAAsC,CA4BlD;AA5BY,wFAAsC"}
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=metrics-frontend-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/metrics-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAK/D,wBAMG"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const inversify_1 = require("@theia/core/shared/inversify");
19
+ const metrics_frontend_application_contribution_1 = require("./metrics-frontend-application-contribution");
20
+ const common_1 = require("../common");
21
+ const browser_1 = require("@theia/core/lib/browser");
22
+ exports.default = new inversify_1.ContainerModule(bind => {
23
+ bind(browser_1.FrontendApplicationContribution).to(metrics_frontend_application_contribution_1.MetricsFrontendApplicationContribution).inSingletonScope();
24
+ bind(common_1.MeasurementNotificationService).toDynamicValue(ctx => {
25
+ const connection = ctx.container.get(browser_1.WebSocketConnectionProvider);
26
+ return connection.createProxy(common_1.measurementNotificationServicePath);
27
+ });
28
+ });
29
+ //# sourceMappingURL=metrics-frontend-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-frontend-module.js","sourceRoot":"","sources":["../../src/browser/metrics-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,2GAAqG;AACrG,sCAA+F;AAC/F,qDAAuG;AAEvG,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,yCAA+B,CAAC,CAAC,EAAE,CAAC,kFAAsC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpG,IAAI,CAAC,uCAA8B,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QACtD,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,qCAA2B,CAAC,CAAC;QAClE,OAAO,UAAU,CAAC,WAAW,CAAiC,2CAAkC,CAAC,CAAC;IACtG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './measurement-notification-service';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAgBA,cAAc,oCAAoC,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ __exportStar(require("./measurement-notification-service"), exports);
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;;;;;;;;AAEhF,qEAAmD"}
@@ -0,0 +1,12 @@
1
+ import { MeasurementResult } from '@theia/core';
2
+ export declare const measurementNotificationServicePath = "/services/measurement-notification";
3
+ export declare const MeasurementNotificationService: unique symbol;
4
+ export interface MeasurementNotificationService {
5
+ /**
6
+ * Notify the backend when a fronted stopwatch provides a new measurement.
7
+ * @param frontendId The unique id associated with the frontend that sends the notification
8
+ * @param result The new measurement result
9
+ */
10
+ onFrontendMeasurement(frontendId: string, result: MeasurementResult): void;
11
+ }
12
+ //# sourceMappingURL=measurement-notification-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-notification-service.d.ts","sourceRoot":"","sources":["../../src/common/measurement-notification-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,kCAAkC,uCAAuC,CAAC;AAEvF,eAAO,MAAM,8BAA8B,eAA2C,CAAC;AACvF,MAAM,WAAW,8BAA8B;IAC3C;;;;OAIG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC9E"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.MeasurementNotificationService = exports.measurementNotificationServicePath = void 0;
19
+ exports.measurementNotificationServicePath = '/services/measurement-notification';
20
+ exports.MeasurementNotificationService = Symbol('MeasurementNotificationService');
21
+ //# sourceMappingURL=measurement-notification-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-notification-service.js","sourceRoot":"","sources":["../../src/common/measurement-notification-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAInE,QAAA,kCAAkC,GAAG,oCAAoC,CAAC;AAE1E,QAAA,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { MetricsContribution } from './metrics-contribution';
2
+ import { MeasurementResult, Stopwatch } from '@theia/core';
3
+ import { MeasurementNotificationService } from '../common';
4
+ import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
5
+ export declare class MeasurementMetricsBackendContribution implements MetricsContribution, MeasurementNotificationService {
6
+ protected backendStopwatch: Stopwatch;
7
+ protected logLevelCli: LogLevelCliContribution;
8
+ protected metrics: string;
9
+ protected frontendCounters: Map<string, string>;
10
+ startCollecting(): void;
11
+ getMetrics(): string;
12
+ protected appendMetricsValue(id: string, result: MeasurementResult): void;
13
+ protected onBackendMeasurement(result: MeasurementResult): void;
14
+ protected createFrontendCounterId(frontendId: string): string;
15
+ protected toCounterId(frontendId: string): string;
16
+ onFrontendMeasurement(frontendId: string, result: MeasurementResult): void;
17
+ }
18
+ //# sourceMappingURL=measurement-metrics-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-metrics-contribution.d.ts","sourceRoot":"","sources":["../../src/node/measurement-metrics-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAY,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAKvF,qBACa,qCAAsC,YAAW,mBAAmB,EAAE,8BAA8B;IAE7G,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC;IAGtC,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAE/C,SAAS,CAAC,OAAO,SAAM;IACvB,SAAS,CAAC,gBAAgB,sBAA6B;IAEvD,eAAe,IAAI,IAAI;IAUvB,UAAU,IAAI,MAAM;IAIpB,SAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAOzE,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAI/D,SAAS,CAAC,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAM7D,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAIjD,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;CAI7E"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MeasurementMetricsBackendContribution = void 0;
13
+ // *****************************************************************************
14
+ // Copyright (C) 2023 STMicroelectronics and others.
15
+ //
16
+ // This program and the accompanying materials are made available under the
17
+ // terms of the Eclipse Public License v. 2.0 which is available at
18
+ // http://www.eclipse.org/legal/epl-2.0.
19
+ //
20
+ // This Source Code may also be made available under the following Secondary
21
+ // Licenses when the conditions for such availability set forth in the Eclipse
22
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
+ // with the GNU Classpath Exception which is available at
24
+ // https://www.gnu.org/software/classpath/license.html.
25
+ //
26
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
27
+ // *****************************************************************************
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const core_1 = require("@theia/core");
30
+ const logger_cli_contribution_1 = require("@theia/core/lib/node/logger-cli-contribution");
31
+ const backendId = 'backend';
32
+ const metricsName = 'theia_measurements';
33
+ let MeasurementMetricsBackendContribution = class MeasurementMetricsBackendContribution {
34
+ constructor() {
35
+ this.metrics = '';
36
+ this.frontendCounters = new Map();
37
+ }
38
+ startCollecting() {
39
+ if (this.logLevelCli.defaultLogLevel !== core_1.LogLevel.DEBUG) {
40
+ return;
41
+ }
42
+ this.metrics += `# HELP ${metricsName} Theia stopwatch measurement results.\n`;
43
+ this.metrics += `# TYPE ${metricsName} gauge\n`;
44
+ this.backendStopwatch.storedMeasurements.forEach(result => this.onBackendMeasurement(result));
45
+ this.backendStopwatch.onDidAddMeasurementResult(result => this.onBackendMeasurement(result));
46
+ }
47
+ getMetrics() {
48
+ return this.metrics;
49
+ }
50
+ appendMetricsValue(id, result) {
51
+ const { name, elapsed, startTime, owner } = result;
52
+ const labels = `id="${id}", name="${name}", startTime="${startTime}", owner="${owner}"`;
53
+ const metricsValue = `${metricsName}{${labels}} ${elapsed}`;
54
+ this.metrics += (metricsValue + '\n');
55
+ }
56
+ onBackendMeasurement(result) {
57
+ this.appendMetricsValue(backendId, result);
58
+ }
59
+ createFrontendCounterId(frontendId) {
60
+ const counterId = `frontend-${this.frontendCounters.size + 1}`;
61
+ this.frontendCounters.set(frontendId, counterId);
62
+ return counterId;
63
+ }
64
+ toCounterId(frontendId) {
65
+ var _a;
66
+ return (_a = this.frontendCounters.get(frontendId)) !== null && _a !== void 0 ? _a : this.createFrontendCounterId(frontendId);
67
+ }
68
+ onFrontendMeasurement(frontendId, result) {
69
+ this.appendMetricsValue(this.toCounterId(frontendId), result);
70
+ }
71
+ };
72
+ __decorate([
73
+ (0, inversify_1.inject)(core_1.Stopwatch),
74
+ __metadata("design:type", core_1.Stopwatch)
75
+ ], MeasurementMetricsBackendContribution.prototype, "backendStopwatch", void 0);
76
+ __decorate([
77
+ (0, inversify_1.inject)(logger_cli_contribution_1.LogLevelCliContribution),
78
+ __metadata("design:type", logger_cli_contribution_1.LogLevelCliContribution)
79
+ ], MeasurementMetricsBackendContribution.prototype, "logLevelCli", void 0);
80
+ MeasurementMetricsBackendContribution = __decorate([
81
+ (0, inversify_1.injectable)()
82
+ ], MeasurementMetricsBackendContribution);
83
+ exports.MeasurementMetricsBackendContribution = MeasurementMetricsBackendContribution;
84
+ //# sourceMappingURL=measurement-metrics-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-metrics-contribution.js","sourceRoot":"","sources":["../../src/node/measurement-metrics-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,4DAAmE;AAEnE,sCAAqE;AAErE,0FAAuF;AAEvF,MAAM,SAAS,GAAG,SAAS,CAAC;AAC5B,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAGzC,IAAa,qCAAqC,GAAlD,MAAa,qCAAqC;IAAlD;QAOc,YAAO,GAAG,EAAE,CAAC;QACb,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAyC3D,CAAC;IAvCG,eAAe;QACX,IAAI,IAAI,CAAC,WAAW,CAAC,eAAe,KAAK,eAAQ,CAAC,KAAK,EAAE;YACrD,OAAO;SACV;QACD,IAAI,CAAC,OAAO,IAAI,UAAU,WAAW,yCAAyC,CAAC;QAC/E,IAAI,CAAC,OAAO,IAAI,UAAU,WAAW,UAAU,CAAC;QAChD,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAES,kBAAkB,CAAC,EAAU,EAAE,MAAyB;QAC9D,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACnD,MAAM,MAAM,GAAW,OAAO,EAAE,YAAY,IAAI,iBAAiB,SAAS,aAAa,KAAK,GAAG,CAAC;QAChG,MAAM,YAAY,GAAG,GAAG,WAAW,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QAC5D,IAAI,CAAC,OAAO,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;IAES,oBAAoB,CAAC,MAAyB;QACpD,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAES,uBAAuB,CAAC,UAAkB;QAChD,MAAM,SAAS,GAAG,YAAY,IAAI,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAC/D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACjD,OAAO,SAAS,CAAC;IACrB,CAAC;IAES,WAAW,CAAC,UAAkB;;QACpC,OAAO,MAAA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,mCAAI,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAC7F,CAAC;IAED,qBAAqB,CAAC,UAAkB,EAAE,MAAyB;QAC/D,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CAEJ,CAAA;AA/CG;IADC,IAAA,kBAAM,EAAC,gBAAS,CAAC;8BACU,gBAAS;+EAAC;AAGtC;IADC,IAAA,kBAAM,EAAC,iDAAuB,CAAC;8BACT,iDAAuB;0EAAC;AALtC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CAiDjD;AAjDY,sFAAqC"}
@@ -1 +1 @@
1
- {"version":3,"file":"metrics-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/metrics-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAQ/D,wBAOG"}
1
+ {"version":3,"file":"metrics-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/metrics-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAU/D,wBAaG"}
@@ -22,10 +22,15 @@ const metrics_contribution_1 = require("./metrics-contribution");
22
22
  const node_metrics_contribution_1 = require("./node-metrics-contribution");
23
23
  const extensions_metrics_contribution_1 = require("./extensions-metrics-contribution");
24
24
  const metrics_backend_application_contribution_1 = require("./metrics-backend-application-contribution");
25
+ const common_2 = require("../common");
26
+ const measurement_metrics_contribution_1 = require("./measurement-metrics-contribution");
25
27
  exports.default = new inversify_1.ContainerModule(bind => {
26
28
  (0, common_1.bindContributionProvider)(bind, metrics_contribution_1.MetricsContribution);
27
29
  bind(metrics_contribution_1.MetricsContribution).to(node_metrics_contribution_1.NodeMetricsContribution).inSingletonScope();
28
30
  bind(metrics_contribution_1.MetricsContribution).to(extensions_metrics_contribution_1.ExtensionMetricsContribution).inSingletonScope();
31
+ bind(measurement_metrics_contribution_1.MeasurementMetricsBackendContribution).toSelf().inSingletonScope();
32
+ bind(metrics_contribution_1.MetricsContribution).toService(measurement_metrics_contribution_1.MeasurementMetricsBackendContribution);
33
+ bind(common_1.ConnectionHandler).toDynamicValue(ctx => new common_1.RpcConnectionHandler(common_2.measurementNotificationServicePath, () => ctx.container.get(measurement_metrics_contribution_1.MeasurementMetricsBackendContribution)));
29
34
  bind(node_1.BackendApplicationContribution).to(metrics_backend_application_contribution_1.MetricsBackendApplicationContribution).inSingletonScope();
30
35
  });
31
36
  //# sourceMappingURL=metrics-backend-module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metrics-backend-module.js","sourceRoot":"","sources":["../../src/node/metrics-backend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,+CAAsE;AACtE,mDAAkE;AAClE,iEAA6D;AAC7D,2EAAsE;AACtE,uFAAiF;AACjF,yGAAmG;AAEnG,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAA,iCAAwB,EAAC,IAAI,EAAE,0CAAmB,CAAC,CAAC;IACpD,IAAI,CAAC,0CAAmB,CAAC,CAAC,EAAE,CAAC,mDAAuB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACzE,IAAI,CAAC,0CAAmB,CAAC,CAAC,EAAE,CAAC,8DAA4B,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAE9E,IAAI,CAAC,qCAA8B,CAAC,CAAC,EAAE,CAAC,gFAAqC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAEtG,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"metrics-backend-module.js","sourceRoot":"","sources":["../../src/node/metrics-backend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,+CAAsE;AACtE,mDAA2G;AAC3G,iEAA6D;AAC7D,2EAAsE;AACtE,uFAAiF;AACjF,yGAAmG;AACnG,sCAA+D;AAC/D,yFAA2F;AAE3F,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAA,iCAAwB,EAAC,IAAI,EAAE,0CAAmB,CAAC,CAAC;IACpD,IAAI,CAAC,0CAAmB,CAAC,CAAC,EAAE,CAAC,mDAAuB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACzE,IAAI,CAAC,0CAAmB,CAAC,CAAC,EAAE,CAAC,8DAA4B,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAE9E,IAAI,CAAC,wEAAqC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACxE,IAAI,CAAC,0CAAmB,CAAC,CAAC,SAAS,CAAC,wEAAqC,CAAC,CAAC;IAC3E,IAAI,CAAC,0BAAiB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CACzC,IAAI,6BAAoB,CAAC,2CAAkC,EACvD,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,wEAAqC,CAAC,CAAC,CAAC,CAAC;IAEzE,IAAI,CAAC,qCAA8B,CAAC,CAAC,EAAE,CAAC,gFAAqC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAEtG,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/metrics",
3
- "version": "1.40.1",
3
+ "version": "1.41.0",
4
4
  "description": "Theia - Metrics Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.40.1",
6
+ "@theia/core": "1.41.0",
7
7
  "prom-client": "^10.2.0"
8
8
  },
9
9
  "publishConfig": {
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "theiaExtensions": [
13
13
  {
14
+ "frontend": "lib/browser/metrics-frontend-module",
14
15
  "backend": "lib/node/metrics-backend-module"
15
16
  }
16
17
  ],
@@ -39,10 +40,10 @@
39
40
  "watch": "theiaext watch"
40
41
  },
41
42
  "devDependencies": {
42
- "@theia/ext-scripts": "1.40.1"
43
+ "@theia/ext-scripts": "1.41.0"
43
44
  },
44
45
  "nyc": {
45
46
  "extends": "../../configs/nyc.json"
46
47
  },
47
- "gitHead": "92c1db6be117d2606c0ed4de6ea6e51cf8e9fbc8"
48
+ "gitHead": "180103ad086fc0a5e4e5fc01b5fcb43f06019eb1"
48
49
  }
@@ -0,0 +1,51 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { inject, injectable } from '@theia/core/shared/inversify';
17
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser';
18
+ import { ILogger, LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
19
+ import { UUID } from '@theia/core/shared/@phosphor/coreutils';
20
+ import { MeasurementNotificationService } from '../common';
21
+
22
+ @injectable()
23
+ export class MetricsFrontendApplicationContribution implements FrontendApplicationContribution {
24
+ @inject(Stopwatch)
25
+ protected stopwatch: Stopwatch;
26
+
27
+ @inject(MeasurementNotificationService)
28
+ protected notificationService: MeasurementNotificationService;
29
+
30
+ @inject(ILogger)
31
+ protected logger: ILogger;
32
+
33
+ readonly id = UUID.uuid4();
34
+
35
+ initialize(): void {
36
+ this.doInitialize();
37
+ }
38
+
39
+ protected async doInitialize(): Promise<void> {
40
+ const logLevel = await this.logger.getLogLevel();
41
+ if (logLevel !== LogLevel.DEBUG) {
42
+ return;
43
+ }
44
+ this.stopwatch.storedMeasurements.forEach(result => this.notify(result));
45
+ this.stopwatch.onDidAddMeasurementResult(result => this.notify(result));
46
+ }
47
+
48
+ protected notify(result: MeasurementResult): void {
49
+ this.notificationService.onFrontendMeasurement(this.id, result);
50
+ }
51
+ }
@@ -0,0 +1,28 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule } from '@theia/core/shared/inversify';
18
+ import { MetricsFrontendApplicationContribution } from './metrics-frontend-application-contribution';
19
+ import { MeasurementNotificationService, measurementNotificationServicePath } from '../common';
20
+ import { FrontendApplicationContribution, WebSocketConnectionProvider } from '@theia/core/lib/browser';
21
+
22
+ export default new ContainerModule(bind => {
23
+ bind(FrontendApplicationContribution).to(MetricsFrontendApplicationContribution).inSingletonScope();
24
+ bind(MeasurementNotificationService).toDynamicValue(ctx => {
25
+ const connection = ctx.container.get(WebSocketConnectionProvider);
26
+ return connection.createProxy<MeasurementNotificationService>(measurementNotificationServicePath);
27
+ });
28
+ });
@@ -0,0 +1,17 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ export * from './measurement-notification-service';
@@ -0,0 +1,29 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { MeasurementResult } from '@theia/core';
18
+
19
+ export const measurementNotificationServicePath = '/services/measurement-notification';
20
+
21
+ export const MeasurementNotificationService = Symbol('MeasurementNotificationService');
22
+ export interface MeasurementNotificationService {
23
+ /**
24
+ * Notify the backend when a fronted stopwatch provides a new measurement.
25
+ * @param frontendId The unique id associated with the frontend that sends the notification
26
+ * @param result The new measurement result
27
+ */
28
+ onFrontendMeasurement(frontendId: string, result: MeasurementResult): void;
29
+ }
@@ -0,0 +1,75 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { inject, injectable, } from '@theia/core/shared/inversify';
17
+ import { MetricsContribution } from './metrics-contribution';
18
+ import { LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
19
+ import { MeasurementNotificationService } from '../common';
20
+ import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
21
+
22
+ const backendId = 'backend';
23
+ const metricsName = 'theia_measurements';
24
+
25
+ @injectable()
26
+ export class MeasurementMetricsBackendContribution implements MetricsContribution, MeasurementNotificationService {
27
+ @inject(Stopwatch)
28
+ protected backendStopwatch: Stopwatch;
29
+
30
+ @inject(LogLevelCliContribution)
31
+ protected logLevelCli: LogLevelCliContribution;
32
+
33
+ protected metrics = '';
34
+ protected frontendCounters = new Map<string, string>();
35
+
36
+ startCollecting(): void {
37
+ if (this.logLevelCli.defaultLogLevel !== LogLevel.DEBUG) {
38
+ return;
39
+ }
40
+ this.metrics += `# HELP ${metricsName} Theia stopwatch measurement results.\n`;
41
+ this.metrics += `# TYPE ${metricsName} gauge\n`;
42
+ this.backendStopwatch.storedMeasurements.forEach(result => this.onBackendMeasurement(result));
43
+ this.backendStopwatch.onDidAddMeasurementResult(result => this.onBackendMeasurement(result));
44
+ }
45
+
46
+ getMetrics(): string {
47
+ return this.metrics;
48
+ }
49
+
50
+ protected appendMetricsValue(id: string, result: MeasurementResult): void {
51
+ const { name, elapsed, startTime, owner } = result;
52
+ const labels: string = `id="${id}", name="${name}", startTime="${startTime}", owner="${owner}"`;
53
+ const metricsValue = `${metricsName}{${labels}} ${elapsed}`;
54
+ this.metrics += (metricsValue + '\n');
55
+ }
56
+
57
+ protected onBackendMeasurement(result: MeasurementResult): void {
58
+ this.appendMetricsValue(backendId, result);
59
+ }
60
+
61
+ protected createFrontendCounterId(frontendId: string): string {
62
+ const counterId = `frontend-${this.frontendCounters.size + 1}`;
63
+ this.frontendCounters.set(frontendId, counterId);
64
+ return counterId;
65
+ }
66
+
67
+ protected toCounterId(frontendId: string): string {
68
+ return this.frontendCounters.get(frontendId) ?? this.createFrontendCounterId(frontendId);
69
+ }
70
+
71
+ onFrontendMeasurement(frontendId: string, result: MeasurementResult): void {
72
+ this.appendMetricsValue(this.toCounterId(frontendId), result);
73
+ }
74
+
75
+ }
@@ -16,17 +16,25 @@
16
16
 
17
17
  import { ContainerModule } from '@theia/core/shared/inversify';
18
18
  import { BackendApplicationContribution } from '@theia/core/lib/node';
19
- import { bindContributionProvider } from '@theia/core/lib/common';
19
+ import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '@theia/core/lib/common';
20
20
  import { MetricsContribution } from './metrics-contribution';
21
21
  import { NodeMetricsContribution } from './node-metrics-contribution';
22
22
  import { ExtensionMetricsContribution } from './extensions-metrics-contribution';
23
23
  import { MetricsBackendApplicationContribution } from './metrics-backend-application-contribution';
24
+ import { measurementNotificationServicePath } from '../common';
25
+ import { MeasurementMetricsBackendContribution } from './measurement-metrics-contribution';
24
26
 
25
27
  export default new ContainerModule(bind => {
26
28
  bindContributionProvider(bind, MetricsContribution);
27
29
  bind(MetricsContribution).to(NodeMetricsContribution).inSingletonScope();
28
30
  bind(MetricsContribution).to(ExtensionMetricsContribution).inSingletonScope();
29
31
 
32
+ bind(MeasurementMetricsBackendContribution).toSelf().inSingletonScope();
33
+ bind(MetricsContribution).toService(MeasurementMetricsBackendContribution);
34
+ bind(ConnectionHandler).toDynamicValue(ctx =>
35
+ new RpcConnectionHandler(measurementNotificationServicePath,
36
+ () => ctx.container.get(MeasurementMetricsBackendContribution)));
37
+
30
38
  bind(BackendApplicationContribution).to(MetricsBackendApplicationContribution).inSingletonScope();
31
39
 
32
40
  });