@theia/metrics 1.74.0-next.62 → 1.74.0-next.68

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 (42) hide show
  1. package/lib/browser/metrics-frontend-application-contribution.d.ts +2 -3
  2. package/lib/browser/metrics-frontend-application-contribution.d.ts.map +1 -1
  3. package/lib/browser/metrics-frontend-application-contribution.js +5 -8
  4. package/lib/browser/metrics-frontend-application-contribution.js.map +1 -1
  5. package/lib/browser/metrics-frontend-module.d.ts.map +1 -1
  6. package/lib/browser/metrics-frontend-module.js +1 -6
  7. package/lib/browser/metrics-frontend-module.js.map +1 -1
  8. package/lib/common/index.d.ts +1 -1
  9. package/lib/common/index.d.ts.map +1 -1
  10. package/lib/common/index.js +1 -1
  11. package/lib/common/index.js.map +1 -1
  12. package/lib/common/measurement-telemetry.d.ts +5 -0
  13. package/lib/common/measurement-telemetry.d.ts.map +1 -0
  14. package/lib/common/{measurement-notification-service.js → measurement-telemetry.js} +14 -5
  15. package/lib/common/measurement-telemetry.js.map +1 -0
  16. package/lib/node/measurement-metrics-contribution.d.ts +12 -6
  17. package/lib/node/measurement-metrics-contribution.d.ts.map +1 -1
  18. package/lib/node/measurement-metrics-contribution.js +40 -12
  19. package/lib/node/measurement-metrics-contribution.js.map +1 -1
  20. package/lib/node/measurement-telemetry-contribution.d.ts +12 -0
  21. package/lib/node/measurement-telemetry-contribution.d.ts.map +1 -0
  22. package/lib/node/measurement-telemetry-contribution.js +53 -0
  23. package/lib/node/measurement-telemetry-contribution.js.map +1 -0
  24. package/lib/node/measurement-telemetry-contribution.spec.d.ts +2 -0
  25. package/lib/node/measurement-telemetry-contribution.spec.d.ts.map +1 -0
  26. package/lib/node/measurement-telemetry-contribution.spec.js +148 -0
  27. package/lib/node/measurement-telemetry-contribution.spec.js.map +1 -0
  28. package/lib/node/metrics-backend-module.d.ts.map +1 -1
  29. package/lib/node/metrics-backend-module.js +9 -7
  30. package/lib/node/metrics-backend-module.js.map +1 -1
  31. package/package.json +4 -3
  32. package/src/browser/metrics-frontend-application-contribution.ts +5 -7
  33. package/src/browser/metrics-frontend-module.ts +1 -6
  34. package/src/common/index.ts +1 -1
  35. package/src/common/{measurement-notification-service.ts → measurement-telemetry.ts} +10 -10
  36. package/src/node/measurement-metrics-contribution.ts +47 -16
  37. package/src/node/measurement-telemetry-contribution.spec.ts +172 -0
  38. package/src/node/measurement-telemetry-contribution.ts +46 -0
  39. package/src/node/metrics-backend-module.ts +9 -9
  40. package/lib/common/measurement-notification-service.d.ts +0 -12
  41. package/lib/common/measurement-notification-service.d.ts.map +0 -1
  42. package/lib/common/measurement-notification-service.js.map +0 -1
@@ -1,11 +1,10 @@
1
1
  import { FrontendApplicationContribution } from '@theia/core/lib/browser';
2
2
  import { ILogger, MeasurementResult, Stopwatch } from '@theia/core';
3
- import { MeasurementNotificationService } from '../common';
3
+ import { TelemetryService } from '@theia/telemetry/lib/common';
4
4
  export declare class MetricsFrontendApplicationContribution implements FrontendApplicationContribution {
5
5
  protected stopwatch: Stopwatch;
6
- protected notificationService: MeasurementNotificationService;
6
+ protected telemetryService: TelemetryService;
7
7
  protected logger: ILogger;
8
- readonly id: string;
9
8
  initialize(): void;
10
9
  protected doInitialize(): Promise<void>;
11
10
  protected notify(result: MeasurementResult): void;
@@ -1 +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"}
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;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,qBACa,sCAAuC,YAAW,+BAA+B;IAE1F,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAG/B,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAG7C,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAE1B,UAAU,IAAI,IAAI;cAIF,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAS7C,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;CAGpD"}
@@ -19,12 +19,9 @@ const tslib_1 = require("tslib");
19
19
  // *****************************************************************************
20
20
  const inversify_1 = require("@theia/core/shared/inversify");
21
21
  const core_1 = require("@theia/core");
22
- const coreutils_1 = require("@theia/core/shared/@lumino/coreutils");
23
- const common_1 = require("../common");
22
+ const common_1 = require("@theia/telemetry/lib/common");
23
+ const common_2 = require("../common");
24
24
  let MetricsFrontendApplicationContribution = class MetricsFrontendApplicationContribution {
25
- constructor() {
26
- this.id = coreutils_1.UUID.uuid4();
27
- }
28
25
  initialize() {
29
26
  this.doInitialize();
30
27
  }
@@ -37,7 +34,7 @@ let MetricsFrontendApplicationContribution = class MetricsFrontendApplicationCon
37
34
  this.stopwatch.onDidAddMeasurementResult(result => this.notify(result));
38
35
  }
39
36
  notify(result) {
40
- this.notificationService.onFrontendMeasurement(this.id, result);
37
+ (0, common_2.reportMeasurement)(this.telemetryService, result);
41
38
  }
42
39
  };
43
40
  exports.MetricsFrontendApplicationContribution = MetricsFrontendApplicationContribution;
@@ -46,9 +43,9 @@ tslib_1.__decorate([
46
43
  tslib_1.__metadata("design:type", core_1.Stopwatch)
47
44
  ], MetricsFrontendApplicationContribution.prototype, "stopwatch", void 0);
48
45
  tslib_1.__decorate([
49
- (0, inversify_1.inject)(common_1.MeasurementNotificationService),
46
+ (0, inversify_1.inject)(common_1.TelemetryService),
50
47
  tslib_1.__metadata("design:type", Object)
51
- ], MetricsFrontendApplicationContribution.prototype, "notificationService", void 0);
48
+ ], MetricsFrontendApplicationContribution.prototype, "telemetryService", void 0);
52
49
  tslib_1.__decorate([
53
50
  (0, inversify_1.inject)(core_1.ILogger),
54
51
  tslib_1.__metadata("design:type", Object)
@@ -1 +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,oEAA4D;AAC5D,sCAA2D;AAGpD,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAA5C;QAUM,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,CAAC;YAC9B,OAAO;QACX,CAAC;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;AA5BY,wFAAsC;AAErC;IADT,IAAA,kBAAM,EAAC,gBAAS,CAAC;sCACG,gBAAS;yEAAC;AAGrB;IADT,IAAA,kBAAM,EAAC,uCAA8B,CAAC;;mFACuB;AAGpD;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;;sEACU;iDARjB,sCAAsC;IADlD,IAAA,sBAAU,GAAE;GACA,sCAAsC,CA4BlD"}
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,wDAA+D;AAC/D,sCAA8C;AAGvC,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAU/C,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,CAAC;YAC9B,OAAO;QACX,CAAC;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,IAAA,0BAAiB,EAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACJ,CAAA;AA1BY,wFAAsC;AAErC;IADT,IAAA,kBAAM,EAAC,gBAAS,CAAC;sCACG,gBAAS;yEAAC;AAGrB;IADT,IAAA,kBAAM,EAAC,yBAAgB,CAAC;;gFACoB;AAGnC;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;;sEACU;iDARjB,sCAAsC;IADlD,IAAA,sBAAU,GAAE;GACA,sCAAsC,CA0BlD"}
@@ -1 +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"}
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;;AAI/D,wBAEG"}
@@ -16,14 +16,9 @@
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
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
19
  const browser_1 = require("@theia/core/lib/browser");
20
+ const metrics_frontend_application_contribution_1 = require("./metrics-frontend-application-contribution");
22
21
  exports.default = new inversify_1.ContainerModule(bind => {
23
22
  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
- }).inSingletonScope();
28
23
  });
29
24
  //# sourceMappingURL=metrics-frontend-module.js.map
@@ -1 +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,gBAAgB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
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,qDAA0E;AAC1E,2GAAqG;AAErG,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,yCAA+B,CAAC,CAAC,EAAE,CAAC,kFAAsC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACxG,CAAC,CAAC,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './measurement-notification-service';
1
+ export * from './measurement-telemetry';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAgBA,cAAc,oCAAoC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAgBA,cAAc,yBAAyB,CAAC"}
@@ -16,5 +16,5 @@
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const tslib_1 = require("tslib");
19
- tslib_1.__exportStar(require("./measurement-notification-service"), exports);
19
+ tslib_1.__exportStar(require("./measurement-telemetry"), exports);
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +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,6EAAmD"}
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,kEAAwC"}
@@ -0,0 +1,5 @@
1
+ import { MeasurementResult } from '@theia/core';
2
+ import { TelemetryService } from '@theia/telemetry/lib/common';
3
+ export declare const MEASUREMENT_TELEMETRY_TOPIC = "theia/measurement/result";
4
+ export declare function reportMeasurement(telemetryService: TelemetryService, result: MeasurementResult): void;
5
+ //# sourceMappingURL=measurement-telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-telemetry.d.ts","sourceRoot":"","sources":["../../src/common/measurement-telemetry.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AAEtE,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAOrG"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  // *****************************************************************************
3
- // Copyright (C) 2023 STMicroelectronics and others.
3
+ // Copyright (C) 2026 STMicroelectronics and others.
4
4
  //
5
5
  // This program and the accompanying materials are made available under the
6
6
  // terms of the Eclipse Public License v. 2.0 which is available at
@@ -15,7 +15,16 @@
15
15
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
16
  // *****************************************************************************
17
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
18
+ exports.MEASUREMENT_TELEMETRY_TOPIC = void 0;
19
+ exports.reportMeasurement = reportMeasurement;
20
+ exports.MEASUREMENT_TELEMETRY_TOPIC = 'theia/measurement/result';
21
+ function reportMeasurement(telemetryService, result) {
22
+ const { name, startTime, elapsed, owner } = result;
23
+ if (owner === undefined) {
24
+ telemetryService.report(exports.MEASUREMENT_TELEMETRY_TOPIC, { name, startTime, elapsed });
25
+ }
26
+ else {
27
+ telemetryService.report(exports.MEASUREMENT_TELEMETRY_TOPIC, { name, startTime, elapsed, owner });
28
+ }
29
+ }
30
+ //# sourceMappingURL=measurement-telemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-telemetry.js","sourceRoot":"","sources":["../../src/common/measurement-telemetry.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;;;AAOhF,8CAOC;AATY,QAAA,2BAA2B,GAAG,0BAA0B,CAAC;AAEtE,SAAgB,iBAAiB,CAAC,gBAAkC,EAAE,MAAyB;IAC3F,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IACnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,gBAAgB,CAAC,MAAM,CAAC,mCAA2B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;IACvF,CAAC;SAAM,CAAC;QACJ,gBAAgB,CAAC,MAAM,CAAC,mCAA2B,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9F,CAAC;AACL,CAAC"}
@@ -1,16 +1,22 @@
1
- import { MetricsContribution } from './metrics-contribution';
2
- import { MeasurementResult, Stopwatch } from '@theia/core';
3
- import { MeasurementNotificationService } from '../common';
1
+ import { MeasurementResult } from '@theia/core';
4
2
  import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
5
- export declare class MeasurementMetricsBackendContribution implements MetricsContribution, MeasurementNotificationService {
6
- protected backendStopwatch: Stopwatch;
3
+ import { TelemetryEvent } from '@theia/telemetry/lib/common';
4
+ import { TelemetrySink } from '@theia/telemetry/lib/node';
5
+ import { MetricsContribution } from './metrics-contribution';
6
+ export declare class MeasurementMetricsBackendContribution implements MetricsContribution, TelemetrySink {
7
+ readonly id = "theia/measurements";
8
+ readonly interests: readonly string[];
9
+ readonly scope: 'local' | 'remote';
7
10
  protected logLevelCli: LogLevelCliContribution;
8
11
  protected metrics: string;
9
12
  protected frontendCounters: Map<string, string>;
10
13
  startCollecting(): void;
11
14
  getMetrics(): string;
12
- protected appendMetricsValue(id: string, result: MeasurementResult): void;
15
+ handle(event: TelemetryEvent): void;
13
16
  protected onBackendMeasurement(result: MeasurementResult): void;
17
+ protected isEnabled(): boolean;
18
+ protected toMeasurementResult(event: TelemetryEvent): MeasurementResult | undefined;
19
+ protected appendMetricsValue(id: string, result: MeasurementResult): void;
14
20
  protected createFrontendCounterId(frontendId: string): string;
15
21
  protected toCounterId(frontendId: string): string;
16
22
  onFrontendMeasurement(frontendId: string, result: MeasurementResult): void;
@@ -1 +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,M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,CAAC,EAAE,wBAAwB;IACnC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAA2B;IAChE,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAW;IAG7C,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAE/C,SAAS,CAAC,OAAO,SAAM;IACvB,SAAS,CAAC,gBAAgB,sBAA6B;IAEvD,eAAe,IAAI,IAAI;IAQvB,UAAU,IAAI,MAAM;IAIpB,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAenC,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAI/D,SAAS,CAAC,SAAS,IAAI,OAAO;IAI9B,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,iBAAiB,GAAG,SAAS;IAcnF,SAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAOzE,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;CAG7E"}
@@ -17,37 +17,69 @@ const tslib_1 = require("tslib");
17
17
  //
18
18
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
19
19
  // *****************************************************************************
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
20
  const core_1 = require("@theia/core");
22
21
  const logger_cli_contribution_1 = require("@theia/core/lib/node/logger-cli-contribution");
23
- const backendId = 'backend';
22
+ const inversify_1 = require("@theia/core/shared/inversify");
23
+ const common_1 = require("@theia/telemetry/lib/common");
24
24
  const metricsName = 'theia_measurements';
25
25
  let MeasurementMetricsBackendContribution = class MeasurementMetricsBackendContribution {
26
26
  constructor() {
27
+ this.id = 'theia/measurements';
28
+ this.interests = ['theia/measurement/*'];
29
+ this.scope = 'local';
27
30
  this.metrics = '';
28
31
  this.frontendCounters = new Map();
29
32
  }
30
33
  startCollecting() {
31
- if (this.logLevelCli.defaultLogLevel !== core_1.LogLevel.DEBUG) {
34
+ if (!this.isEnabled()) {
32
35
  return;
33
36
  }
34
37
  this.metrics += `# HELP ${metricsName} Theia stopwatch measurement results.\n`;
35
38
  this.metrics += `# TYPE ${metricsName} gauge\n`;
36
- this.backendStopwatch.storedMeasurements.forEach(result => this.onBackendMeasurement(result));
37
- this.backendStopwatch.onDidAddMeasurementResult(result => this.onBackendMeasurement(result));
38
39
  }
39
40
  getMetrics() {
40
41
  return this.metrics;
41
42
  }
43
+ handle(event) {
44
+ if (!this.isEnabled()) {
45
+ return;
46
+ }
47
+ const result = this.toMeasurementResult(event);
48
+ if (!result) {
49
+ return;
50
+ }
51
+ if (event.session === common_1.BACKEND_TELEMETRY_SESSION) {
52
+ this.onBackendMeasurement(result);
53
+ }
54
+ else {
55
+ this.onFrontendMeasurement(event.session, result);
56
+ }
57
+ }
58
+ onBackendMeasurement(result) {
59
+ this.appendMetricsValue(common_1.BACKEND_TELEMETRY_SESSION, result);
60
+ }
61
+ isEnabled() {
62
+ return this.logLevelCli.defaultLogLevel === core_1.LogLevel.DEBUG;
63
+ }
64
+ toMeasurementResult(event) {
65
+ const data = event.data;
66
+ if (!data || typeof data.name !== 'string' || typeof data.startTime !== 'number' || typeof data.elapsed !== 'number'
67
+ || data.owner !== undefined && typeof data.owner !== 'string') {
68
+ return undefined;
69
+ }
70
+ return {
71
+ name: data.name,
72
+ startTime: data.startTime,
73
+ elapsed: data.elapsed,
74
+ ...(data.owner === undefined ? {} : { owner: data.owner })
75
+ };
76
+ }
42
77
  appendMetricsValue(id, result) {
43
78
  const { name, elapsed, startTime, owner } = result;
44
79
  const labels = `id="${id}", name="${name}", startTime="${startTime}", owner="${owner}"`;
45
80
  const metricsValue = `${metricsName}{${labels}} ${elapsed}`;
46
81
  this.metrics += (metricsValue + '\n');
47
82
  }
48
- onBackendMeasurement(result) {
49
- this.appendMetricsValue(backendId, result);
50
- }
51
83
  createFrontendCounterId(frontendId) {
52
84
  const counterId = `frontend-${this.frontendCounters.size + 1}`;
53
85
  this.frontendCounters.set(frontendId, counterId);
@@ -61,10 +93,6 @@ let MeasurementMetricsBackendContribution = class MeasurementMetricsBackendContr
61
93
  }
62
94
  };
63
95
  exports.MeasurementMetricsBackendContribution = MeasurementMetricsBackendContribution;
64
- tslib_1.__decorate([
65
- (0, inversify_1.inject)(core_1.Stopwatch),
66
- tslib_1.__metadata("design:type", core_1.Stopwatch)
67
- ], MeasurementMetricsBackendContribution.prototype, "backendStopwatch", void 0);
68
96
  tslib_1.__decorate([
69
97
  (0, inversify_1.inject)(logger_cli_contribution_1.LogLevelCliContribution),
70
98
  tslib_1.__metadata("design:type", logger_cli_contribution_1.LogLevelCliContribution)
@@ -1 +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;AAGlC,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QAOO,YAAO,GAAG,EAAE,CAAC;QACb,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAyC3D,CAAC;IAvCG,eAAe;QACX,IAAI,IAAI,CAAC,WAAW,CAAC,eAAe,KAAK,eAAQ,C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AC,GAAG,CAAC,UAAU,CAAC,IAAI,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;AAjDY,sFAAqC;AAEpC;IADT,IAAA,kBAAM,EAAC,gBAAS,CAAC;sCACU,gBAAS;+EAAC;AAG5B;IADT,IAAA,kBAAM,EAAC,iDAAuB,CAAC;sCACT,iDAAuB;0EAAC;gDALtC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CAiDjD"}
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,sCAA0D;AAC1D,0FAAuF;AACvF,4DAAkE;AAClE,wDAAwF;AAIxF,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAGlC,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QACM,OAAE,GAAG,oBAAoB,CAAC;QAC1B,cAAS,GAAsB,CAAC,qBAAqB,CAAC,CAAC;QACvD,UAAK,GAAuB,OAAO,CAAC;QAKnC,YAAO,GAAG,EAAE,CAAC;QACb,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAuE3D,CAAC;IArEG,eAAe;QACX,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACpB,OAAO;QACX,CAAC;QACD,IAAI,CAAC,OAAO,IAAI,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E;GACA,qCAAqC,CAgFjD"}
@@ -0,0 +1,12 @@
1
+ import { MeasurementResult, Stopwatch } from '@theia/core';
2
+ import { BackendApplicationContribution } from '@theia/core/lib/node';
3
+ import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
4
+ import { TelemetryService } from '@theia/telemetry/lib/common';
5
+ export declare class MeasurementTelemetryContribution implements BackendApplicationContribution {
6
+ protected stopwatch: Stopwatch;
7
+ protected logLevelCli: LogLevelCliContribution;
8
+ protected telemetryService: TelemetryService;
9
+ onStart(): void;
10
+ protected report(result: MeasurementResult): void;
11
+ }
12
+ //# sourceMappingURL=measurement-telemetry-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-telemetry-contribution.d.ts","sourceRoot":"","sources":["../../src/node/measurement-telemetry-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAY,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,qBACa,gCAAiC,YAAW,8BAA8B;IAEnF,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAG/B,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAG/C,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAE7C,OAAO,IAAI,IAAI;IAQf,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;CAGpD"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 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.MeasurementTelemetryContribution = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const core_1 = require("@theia/core");
21
+ const logger_cli_contribution_1 = require("@theia/core/lib/node/logger-cli-contribution");
22
+ const inversify_1 = require("@theia/core/shared/inversify");
23
+ const common_1 = require("@theia/telemetry/lib/common");
24
+ const common_2 = require("../common");
25
+ let MeasurementTelemetryContribution = class MeasurementTelemetryContribution {
26
+ onStart() {
27
+ if (this.logLevelCli.defaultLogLevel !== core_1.LogLevel.DEBUG) {
28
+ return;
29
+ }
30
+ this.stopwatch.storedMeasurements.forEach(result => this.report(result));
31
+ this.stopwatch.onDidAddMeasurementResult(result => this.report(result));
32
+ }
33
+ report(result) {
34
+ (0, common_2.reportMeasurement)(this.telemetryService, result);
35
+ }
36
+ };
37
+ exports.MeasurementTelemetryContribution = MeasurementTelemetryContribution;
38
+ tslib_1.__decorate([
39
+ (0, inversify_1.inject)(core_1.Stopwatch),
40
+ tslib_1.__metadata("design:type", core_1.Stopwatch)
41
+ ], MeasurementTelemetryContribution.prototype, "stopwatch", void 0);
42
+ tslib_1.__decorate([
43
+ (0, inversify_1.inject)(logger_cli_contribution_1.LogLevelCliContribution),
44
+ tslib_1.__metadata("design:type", logger_cli_contribution_1.LogLevelCliContribution)
45
+ ], MeasurementTelemetryContribution.prototype, "logLevelCli", void 0);
46
+ tslib_1.__decorate([
47
+ (0, inversify_1.inject)(common_1.TelemetryService),
48
+ tslib_1.__metadata("design:type", Object)
49
+ ], MeasurementTelemetryContribution.prototype, "telemetryService", void 0);
50
+ exports.MeasurementTelemetryContribution = MeasurementTelemetryContribution = tslib_1.__decorate([
51
+ (0, inversify_1.injectable)()
52
+ ], MeasurementTelemetryContribution);
53
+ //# sourceMappingURL=measurement-telemetry-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-telemetry-contribution.js","sourceRoot":"","sources":["../../src/node/measurement-telemetry-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;;;;AAEhF,sCAAqE;AAErE,0FAAuF;AACvF,4DAAkE;AAClE,wDAA+D;AAC/D,sCAA8C;AAGvC,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;IAUzC,OAAO;QACH,IAAI,IAAI,CAAC,WAAW,CAAC,eAAe,KAAK,eAAQ,CAAC,KAAK,EAAE,CAAC;YACtD,OAAO;QACX,CAAC;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,IAAA,0BAAiB,EAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACJ,CAAA;AArBY,4EAAgC;AAE/B;IADT,IAAA,kBAAM,EAAC,gBAAS,CAAC;sCACG,gBAAS;mEAAC;AAGrB;IADT,IAAA,kBAAM,EAAC,iDAAuB,CAAC;sCACT,iDAAuB;qEAAC;AAGrC;IADT,IAAA,kBAAM,EAAC,yBAAgB,CAAC;;0EACoB;2CARpC,gCAAgC;IAD5C,IAAA,sBAAU,GAAE;GACA,gCAAgC,CAqB5C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=measurement-telemetry-contribution.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-telemetry-contribution.spec.d.ts","sourceRoot":"","sources":["../../src/node/measurement-telemetry-contribution.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 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 core_1 = require("@theia/core");
19
+ const common_1 = require("@theia/telemetry/lib/common");
20
+ const chai_1 = require("chai");
21
+ const common_2 = require("../common");
22
+ const measurement_metrics_contribution_1 = require("./measurement-metrics-contribution");
23
+ const measurement_telemetry_contribution_1 = require("./measurement-telemetry-contribution");
24
+ const storedResult = {
25
+ name: 'startup',
26
+ startTime: 12,
27
+ elapsed: 34
28
+ };
29
+ class TestMeasurementTelemetryContribution extends measurement_telemetry_contribution_1.MeasurementTelemetryContribution {
30
+ configure(stopwatch, defaultLogLevel, telemetryService) {
31
+ this.stopwatch = stopwatch;
32
+ this.logLevelCli = { defaultLogLevel };
33
+ this.telemetryService = telemetryService;
34
+ }
35
+ }
36
+ class TestMeasurementMetricsBackendContribution extends measurement_metrics_contribution_1.MeasurementMetricsBackendContribution {
37
+ configure(defaultLogLevel) {
38
+ this.logLevelCli = { defaultLogLevel };
39
+ }
40
+ }
41
+ class OverridingMeasurementMetricsBackendContribution extends TestMeasurementMetricsBackendContribution {
42
+ constructor() {
43
+ super(...arguments);
44
+ this.backendMeasurements = [];
45
+ this.frontendMeasurements = [];
46
+ }
47
+ onBackendMeasurement(result) {
48
+ this.backendMeasurements.push(result);
49
+ }
50
+ onFrontendMeasurement(frontendId, result) {
51
+ this.frontendMeasurements.push([frontendId, result]);
52
+ }
53
+ }
54
+ function createStopwatch(storedMeasurements, emitter) {
55
+ return {
56
+ storedMeasurements,
57
+ onDidAddMeasurementResult: emitter.event
58
+ };
59
+ }
60
+ function createEvent(session, data) {
61
+ return {
62
+ topic: common_2.MEASUREMENT_TELEMETRY_TOPIC,
63
+ kind: 'usage',
64
+ data,
65
+ session,
66
+ timestamp: 1
67
+ };
68
+ }
69
+ describe('measurement telemetry integration', () => {
70
+ it('reports stored and new backend measurements at DEBUG level', () => {
71
+ const reports = [];
72
+ const telemetryService = {
73
+ report: (topic, data, options) => reports.push([topic, data, options])
74
+ };
75
+ const emitter = new core_1.Emitter();
76
+ const contribution = new TestMeasurementTelemetryContribution();
77
+ contribution.configure(createStopwatch([storedResult], emitter), core_1.LogLevel.DEBUG, telemetryService);
78
+ contribution.onStart();
79
+ emitter.fire({ ...storedResult, owner: 'backend' });
80
+ (0, chai_1.expect)(reports).to.deep.equal([
81
+ [common_2.MEASUREMENT_TELEMETRY_TOPIC, storedResult, undefined],
82
+ [common_2.MEASUREMENT_TELEMETRY_TOPIC, { ...storedResult, owner: 'backend' }, undefined]
83
+ ]);
84
+ });
85
+ it('does not report backend measurements above DEBUG level', () => {
86
+ const reports = [];
87
+ const telemetryService = {
88
+ report: (...args) => reports.push(args)
89
+ };
90
+ const emitter = new core_1.Emitter();
91
+ const contribution = new TestMeasurementTelemetryContribution();
92
+ contribution.configure(createStopwatch([storedResult], emitter), core_1.LogLevel.INFO, telemetryService);
93
+ contribution.onStart();
94
+ emitter.fire(storedResult);
95
+ (0, chai_1.expect)(reports).to.be.empty;
96
+ });
97
+ it('converts telemetry sessions to backend and stable frontend counter IDs', () => {
98
+ const contribution = new TestMeasurementMetricsBackendContribution();
99
+ contribution.configure(core_1.LogLevel.DEBUG);
100
+ contribution.startCollecting();
101
+ contribution.handle(createEvent(common_1.BACKEND_TELEMETRY_SESSION, { name: 'startup', startTime: 12, elapsed: 34 }));
102
+ contribution.handle(createEvent('frontend/session-a', { name: 'startup', startTime: 12, elapsed: 34 }));
103
+ contribution.handle(createEvent('frontend/session-a', { ...storedResult, name: 'second' }));
104
+ contribution.handle(createEvent('frontend/session-b', { name: 'startup', startTime: 12, elapsed: 34 }));
105
+ const metrics = contribution.getMetrics();
106
+ (0, chai_1.expect)(metrics).to.contain('id="backend", name="startup"');
107
+ (0, chai_1.expect)(metrics).to.contain('id="frontend-1", name="startup"');
108
+ (0, chai_1.expect)(metrics).to.contain('id="frontend-1", name="second"');
109
+ (0, chai_1.expect)(metrics).to.contain('id="frontend-2", name="startup"');
110
+ });
111
+ it('does not append telemetry events above DEBUG level', () => {
112
+ const contribution = new TestMeasurementMetricsBackendContribution();
113
+ contribution.configure(core_1.LogLevel.INFO);
114
+ contribution.startCollecting();
115
+ contribution.handle(createEvent(common_1.BACKEND_TELEMETRY_SESSION, { ...storedResult }));
116
+ (0, chai_1.expect)(contribution.getMetrics()).to.equal('');
117
+ });
118
+ it('dispatches telemetry events through the backend and frontend extension points', () => {
119
+ const contribution = new OverridingMeasurementMetricsBackendContribution();
120
+ contribution.configure(core_1.LogLevel.DEBUG);
121
+ const frontendResult = { ...storedResult, owner: 'frontend' };
122
+ contribution.handle(createEvent(common_1.BACKEND_TELEMETRY_SESSION, { ...storedResult }));
123
+ contribution.handle(createEvent('frontend/session-a', frontendResult));
124
+ (0, chai_1.expect)(contribution.backendMeasurements).to.deep.equal([storedResult]);
125
+ (0, chai_1.expect)(contribution.frontendMeasurements).to.deep.equal([['frontend/session-a', frontendResult]]);
126
+ });
127
+ it('reports measurement data with optional owner', () => {
128
+ const reports = [];
129
+ const telemetryService = {
130
+ report: (topic, data, options) => reports.push([topic, data, options])
131
+ };
132
+ (0, common_2.reportMeasurement)(telemetryService, storedResult);
133
+ (0, common_2.reportMeasurement)(telemetryService, { ...storedResult, owner: 'frontend' });
134
+ (0, chai_1.expect)(reports).to.deep.equal([
135
+ [common_2.MEASUREMENT_TELEMETRY_TOPIC, storedResult, undefined],
136
+ [common_2.MEASUREMENT_TELEMETRY_TOPIC, { ...storedResult, owner: 'frontend' }, undefined]
137
+ ]);
138
+ });
139
+ it('ignores malformed measurement payloads', () => {
140
+ const contribution = new TestMeasurementMetricsBackendContribution();
141
+ contribution.configure(core_1.LogLevel.DEBUG);
142
+ contribution.startCollecting();
143
+ const initialMetrics = contribution.getMetrics();
144
+ contribution.handle(createEvent('session-a', { name: 'invalid' }));
145
+ (0, chai_1.expect)(contribution.getMetrics()).to.equal(initialMetrics);
146
+ });
147
+ });
148
+ //# sourceMappingURL=measurement-telemetry-contribution.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measurement-telemetry-contribution.spec.js","sourceRoot":"","sources":["../../src/node/measurement-telemetry-contribution.spec.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,sCAA8E;AAC9E,wDAA0G;AAC1G,+BAA8B;AAC9B,sCAA2E;AAC3E,yFAA2F;AAC3F,6FAAwF;AAExF,MAAM,YAAY,GAAsB;IACpC,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;CACd,CAAC;AAEF,MAAM,oCAAqC,SAAQ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
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"}
1
+ {"version":3,"file":"metrics-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/metrics-backend-module.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAS/D,wBAYG"}
@@ -15,22 +15,24 @@
15
15
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const inversify_1 = require("@theia/core/shared/inversify");
19
- const node_1 = require("@theia/core/lib/node");
20
18
  const common_1 = require("@theia/core/lib/common");
21
- const metrics_contribution_1 = require("./metrics-contribution");
22
- const node_metrics_contribution_1 = require("./node-metrics-contribution");
19
+ const node_1 = require("@theia/core/lib/node");
20
+ const inversify_1 = require("@theia/core/shared/inversify");
21
+ const node_2 = require("@theia/telemetry/lib/node");
23
22
  const extensions_metrics_contribution_1 = require("./extensions-metrics-contribution");
24
- const metrics_backend_application_contribution_1 = require("./metrics-backend-application-contribution");
25
- const common_2 = require("../common");
26
23
  const measurement_metrics_contribution_1 = require("./measurement-metrics-contribution");
24
+ const measurement_telemetry_contribution_1 = require("./measurement-telemetry-contribution");
25
+ const metrics_backend_application_contribution_1 = require("./metrics-backend-application-contribution");
26
+ const metrics_contribution_1 = require("./metrics-contribution");
27
+ const node_metrics_contribution_1 = require("./node-metrics-contribution");
27
28
  exports.default = new inversify_1.ContainerModule(bind => {
28
29
  (0, common_1.bindRootContributionProvider)(bind, metrics_contribution_1.MetricsContribution);
29
30
  bind(metrics_contribution_1.MetricsContribution).to(node_metrics_contribution_1.NodeMetricsContribution).inSingletonScope();
30
31
  bind(metrics_contribution_1.MetricsContribution).to(extensions_metrics_contribution_1.ExtensionMetricsContribution).inSingletonScope();
31
32
  bind(measurement_metrics_contribution_1.MeasurementMetricsBackendContribution).toSelf().inSingletonScope();
32
33
  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)));
34
+ bind(node_2.TelemetrySink).toService(measurement_metrics_contribution_1.MeasurementMetricsBackendContribution);
34
35
  bind(node_1.BackendApplicationContribution).to(metrics_backend_application_contribution_1.MetricsBackendApplicationContribution).inSingletonScope();
36
+ bind(node_1.BackendApplicationContribution).to(measurement_telemetry_contribution_1.MeasurementTelemetryContribution).inSingletonScope();
35
37
  });
36
38
  //# 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,mDAA+G;AAC/G,iEAA6D;AAC7D,2EAAsE;AACtE,uFAAiF;AACjF,yGAAmG;AACnG,sCAA+D;AAC/D,yFAA2F;AAE3F,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAA,qCAA4B,EAAC,IAAI,EAAE,0CAAmB,CAAC,CAAC;IACxD,IAAI,CAAC,0CAAmB,CAAC,CAAC,EAAE,CAAC,mDAAuB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACzE,IAAI,CAAC,0CAAmB,CAAC,CAAC,EAAE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,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,oBAAa,CAAC,CAAC,SAAS,CAAC,wEAAqC,CAAC,CAAC;IAErE,IAAI,CAAC,qCAA8B,CAAC,CAAC,EAAE,CAAC,gFAAqC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAClG,IAAI,CAAC,qCAA8B,CAAC,CAAC,EAAE,CAAC,qEAAgC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAEjG,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@theia/metrics",
3
- "version": "1.74.0-next.62+ab0187b47",
3
+ "version": "1.74.0-next.68+e1dc76c4d",
4
4
  "description": "Theia - Metrics Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.74.0-next.62+ab0187b47",
6
+ "@theia/core": "1.74.0-next.68+e1dc76c4d",
7
+ "@theia/telemetry": "1.74.0-next.68+e1dc76c4d",
7
8
  "prom-client": "^10.2.3",
8
9
  "tslib": "^2.8.1"
9
10
  },
@@ -49,5 +50,5 @@
49
50
  "nyc": {
50
51
  "extends": "../../configs/nyc.json"
51
52
  },
52
- "gitHead": "ab0187b4731e59053642128f8f71bb28a1a0ba8e"
53
+ "gitHead": "e1dc76c4d66625cacab9b6e9d288eca104090c4e"
53
54
  }
@@ -16,22 +16,20 @@
16
16
  import { inject, injectable } from '@theia/core/shared/inversify';
17
17
  import { FrontendApplicationContribution } from '@theia/core/lib/browser';
18
18
  import { ILogger, LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
19
- import { UUID } from '@theia/core/shared/@lumino/coreutils';
20
- import { MeasurementNotificationService } from '../common';
19
+ import { TelemetryService } from '@theia/telemetry/lib/common';
20
+ import { reportMeasurement } from '../common';
21
21
 
22
22
  @injectable()
23
23
  export class MetricsFrontendApplicationContribution implements FrontendApplicationContribution {
24
24
  @inject(Stopwatch)
25
25
  protected stopwatch: Stopwatch;
26
26
 
27
- @inject(MeasurementNotificationService)
28
- protected notificationService: MeasurementNotificationService;
27
+ @inject(TelemetryService)
28
+ protected telemetryService: TelemetryService;
29
29
 
30
30
  @inject(ILogger)
31
31
  protected logger: ILogger;
32
32
 
33
- readonly id = UUID.uuid4();
34
-
35
33
  initialize(): void {
36
34
  this.doInitialize();
37
35
  }
@@ -46,6 +44,6 @@ export class MetricsFrontendApplicationContribution implements FrontendApplicati
46
44
  }
47
45
 
48
46
  protected notify(result: MeasurementResult): void {
49
- this.notificationService.onFrontendMeasurement(this.id, result);
47
+ reportMeasurement(this.telemetryService, result);
50
48
  }
51
49
  }
@@ -15,14 +15,9 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { ContainerModule } from '@theia/core/shared/inversify';
18
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser';
18
19
  import { MetricsFrontendApplicationContribution } from './metrics-frontend-application-contribution';
19
- import { MeasurementNotificationService, measurementNotificationServicePath } from '../common';
20
- import { FrontendApplicationContribution, WebSocketConnectionProvider } from '@theia/core/lib/browser';
21
20
 
22
21
  export default new ContainerModule(bind => {
23
22
  bind(FrontendApplicationContribution).to(MetricsFrontendApplicationContribution).inSingletonScope();
24
- bind(MeasurementNotificationService).toDynamicValue(ctx => {
25
- const connection = ctx.container.get(WebSocketConnectionProvider);
26
- return connection.createProxy<MeasurementNotificationService>(measurementNotificationServicePath);
27
- }).inSingletonScope();
28
23
  });
@@ -14,4 +14,4 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- export * from './measurement-notification-service';
17
+ export * from './measurement-telemetry';
@@ -1,5 +1,5 @@
1
1
  // *****************************************************************************
2
- // Copyright (C) 2023 STMicroelectronics and others.
2
+ // Copyright (C) 2026 STMicroelectronics and others.
3
3
  //
4
4
  // This program and the accompanying materials are made available under the
5
5
  // terms of the Eclipse Public License v. 2.0 which is available at
@@ -15,15 +15,15 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { MeasurementResult } from '@theia/core';
18
+ import { TelemetryService } from '@theia/telemetry/lib/common';
18
19
 
19
- export const measurementNotificationServicePath = '/services/measurement-notification';
20
+ export const MEASUREMENT_TELEMETRY_TOPIC = 'theia/measurement/result';
20
21
 
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;
22
+ export function reportMeasurement(telemetryService: TelemetryService, result: MeasurementResult): void {
23
+ const { name, startTime, elapsed, owner } = result;
24
+ if (owner === undefined) {
25
+ telemetryService.report(MEASUREMENT_TELEMETRY_TOPIC, { name, startTime, elapsed });
26
+ } else {
27
+ telemetryService.report(MEASUREMENT_TELEMETRY_TOPIC, { name, startTime, elapsed, owner });
28
+ }
29
29
  }
@@ -13,19 +13,20 @@
13
13
  //
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
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';
16
+ import { LogLevel, MeasurementResult } from '@theia/core';
20
17
  import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { BACKEND_TELEMETRY_SESSION, TelemetryEvent } from '@theia/telemetry/lib/common';
20
+ import { TelemetrySink } from '@theia/telemetry/lib/node';
21
+ import { MetricsContribution } from './metrics-contribution';
21
22
 
22
- const backendId = 'backend';
23
23
  const metricsName = 'theia_measurements';
24
24
 
25
25
  @injectable()
26
- export class MeasurementMetricsBackendContribution implements MetricsContribution, MeasurementNotificationService {
27
- @inject(Stopwatch)
28
- protected backendStopwatch: Stopwatch;
26
+ export class MeasurementMetricsBackendContribution implements MetricsContribution, TelemetrySink {
27
+ readonly id = 'theia/measurements';
28
+ readonly interests: readonly string[] = ['theia/measurement/*'];
29
+ readonly scope: 'local' | 'remote' = 'local';
29
30
 
30
31
  @inject(LogLevelCliContribution)
31
32
  protected logLevelCli: LogLevelCliContribution;
@@ -34,19 +35,54 @@ export class MeasurementMetricsBackendContribution implements MetricsContributio
34
35
  protected frontendCounters = new Map<string, string>();
35
36
 
36
37
  startCollecting(): void {
37
- if (this.logLevelCli.defaultLogLevel !== LogLevel.DEBUG) {
38
+ if (!this.isEnabled()) {
38
39
  return;
39
40
  }
40
41
  this.metrics += `# HELP ${metricsName} Theia stopwatch measurement results.\n`;
41
42
  this.metrics += `# TYPE ${metricsName} gauge\n`;
42
- this.backendStopwatch.storedMeasurements.forEach(result => this.onBackendMeasurement(result));
43
- this.backendStopwatch.onDidAddMeasurementResult(result => this.onBackendMeasurement(result));
44
43
  }
45
44
 
46
45
  getMetrics(): string {
47
46
  return this.metrics;
48
47
  }
49
48
 
49
+ handle(event: TelemetryEvent): void {
50
+ if (!this.isEnabled()) {
51
+ return;
52
+ }
53
+ const result = this.toMeasurementResult(event);
54
+ if (!result) {
55
+ return;
56
+ }
57
+ if (event.session === BACKEND_TELEMETRY_SESSION) {
58
+ this.onBackendMeasurement(result);
59
+ } else {
60
+ this.onFrontendMeasurement(event.session, result);
61
+ }
62
+ }
63
+
64
+ protected onBackendMeasurement(result: MeasurementResult): void {
65
+ this.appendMetricsValue(BACKEND_TELEMETRY_SESSION, result);
66
+ }
67
+
68
+ protected isEnabled(): boolean {
69
+ return this.logLevelCli.defaultLogLevel === LogLevel.DEBUG;
70
+ }
71
+
72
+ protected toMeasurementResult(event: TelemetryEvent): MeasurementResult | undefined {
73
+ const data = event.data;
74
+ if (!data || typeof data.name !== 'string' || typeof data.startTime !== 'number' || typeof data.elapsed !== 'number'
75
+ || data.owner !== undefined && typeof data.owner !== 'string') {
76
+ return undefined;
77
+ }
78
+ return {
79
+ name: data.name,
80
+ startTime: data.startTime,
81
+ elapsed: data.elapsed,
82
+ ...(data.owner === undefined ? {} : { owner: data.owner })
83
+ };
84
+ }
85
+
50
86
  protected appendMetricsValue(id: string, result: MeasurementResult): void {
51
87
  const { name, elapsed, startTime, owner } = result;
52
88
  const labels: string = `id="${id}", name="${name}", startTime="${startTime}", owner="${owner}"`;
@@ -54,10 +90,6 @@ export class MeasurementMetricsBackendContribution implements MetricsContributio
54
90
  this.metrics += (metricsValue + '\n');
55
91
  }
56
92
 
57
- protected onBackendMeasurement(result: MeasurementResult): void {
58
- this.appendMetricsValue(backendId, result);
59
- }
60
-
61
93
  protected createFrontendCounterId(frontendId: string): string {
62
94
  const counterId = `frontend-${this.frontendCounters.size + 1}`;
63
95
  this.frontendCounters.set(frontendId, counterId);
@@ -71,5 +103,4 @@ export class MeasurementMetricsBackendContribution implements MetricsContributio
71
103
  onFrontendMeasurement(frontendId: string, result: MeasurementResult): void {
72
104
  this.appendMetricsValue(this.toCounterId(frontendId), result);
73
105
  }
74
-
75
106
  }
@@ -0,0 +1,172 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 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 { Emitter, LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
18
+ import { BACKEND_TELEMETRY_SESSION, TelemetryEvent, TelemetryService } from '@theia/telemetry/lib/common';
19
+ import { expect } from 'chai';
20
+ import { MEASUREMENT_TELEMETRY_TOPIC, reportMeasurement } from '../common';
21
+ import { MeasurementMetricsBackendContribution } from './measurement-metrics-contribution';
22
+ import { MeasurementTelemetryContribution } from './measurement-telemetry-contribution';
23
+
24
+ const storedResult: MeasurementResult = {
25
+ name: 'startup',
26
+ startTime: 12,
27
+ elapsed: 34
28
+ };
29
+
30
+ class TestMeasurementTelemetryContribution extends MeasurementTelemetryContribution {
31
+ configure(stopwatch: Stopwatch, defaultLogLevel: LogLevel, telemetryService: TelemetryService): void {
32
+ this.stopwatch = stopwatch;
33
+ this.logLevelCli = { defaultLogLevel } as never;
34
+ this.telemetryService = telemetryService;
35
+ }
36
+ }
37
+
38
+ class TestMeasurementMetricsBackendContribution extends MeasurementMetricsBackendContribution {
39
+ configure(defaultLogLevel: LogLevel): void {
40
+ this.logLevelCli = { defaultLogLevel } as never;
41
+ }
42
+ }
43
+
44
+ class OverridingMeasurementMetricsBackendContribution extends TestMeasurementMetricsBackendContribution {
45
+ readonly backendMeasurements: MeasurementResult[] = [];
46
+ readonly frontendMeasurements: Array<[string, MeasurementResult]> = [];
47
+
48
+ protected override onBackendMeasurement(result: MeasurementResult): void {
49
+ this.backendMeasurements.push(result);
50
+ }
51
+
52
+ override onFrontendMeasurement(frontendId: string, result: MeasurementResult): void {
53
+ this.frontendMeasurements.push([frontendId, result]);
54
+ }
55
+ }
56
+
57
+ function createStopwatch(storedMeasurements: MeasurementResult[], emitter: Emitter<MeasurementResult>): Stopwatch {
58
+ return {
59
+ storedMeasurements,
60
+ onDidAddMeasurementResult: emitter.event
61
+ } as unknown as Stopwatch;
62
+ }
63
+
64
+ function createEvent(session: string, data: TelemetryEvent['data']): TelemetryEvent {
65
+ return {
66
+ topic: MEASUREMENT_TELEMETRY_TOPIC,
67
+ kind: 'usage',
68
+ data,
69
+ session,
70
+ timestamp: 1
71
+ };
72
+ }
73
+
74
+ describe('measurement telemetry integration', () => {
75
+ it('reports stored and new backend measurements at DEBUG level', () => {
76
+ const reports: unknown[][] = [];
77
+ const telemetryService: TelemetryService = {
78
+ report: (topic, data, options) => reports.push([topic, data, options])
79
+ };
80
+ const emitter = new Emitter<MeasurementResult>();
81
+ const contribution = new TestMeasurementTelemetryContribution();
82
+ contribution.configure(createStopwatch([storedResult], emitter), LogLevel.DEBUG, telemetryService);
83
+
84
+ contribution.onStart();
85
+ emitter.fire({ ...storedResult, owner: 'backend' });
86
+
87
+ expect(reports).to.deep.equal([
88
+ [MEASUREMENT_TELEMETRY_TOPIC, storedResult, undefined],
89
+ [MEASUREMENT_TELEMETRY_TOPIC, { ...storedResult, owner: 'backend' }, undefined]
90
+ ]);
91
+ });
92
+
93
+ it('does not report backend measurements above DEBUG level', () => {
94
+ const reports: unknown[][] = [];
95
+ const telemetryService: TelemetryService = {
96
+ report: (...args) => reports.push(args)
97
+ };
98
+ const emitter = new Emitter<MeasurementResult>();
99
+ const contribution = new TestMeasurementTelemetryContribution();
100
+ contribution.configure(createStopwatch([storedResult], emitter), LogLevel.INFO, telemetryService);
101
+
102
+ contribution.onStart();
103
+ emitter.fire(storedResult);
104
+
105
+ expect(reports).to.be.empty;
106
+ });
107
+
108
+ it('converts telemetry sessions to backend and stable frontend counter IDs', () => {
109
+ const contribution = new TestMeasurementMetricsBackendContribution();
110
+ contribution.configure(LogLevel.DEBUG);
111
+ contribution.startCollecting();
112
+
113
+ contribution.handle(createEvent(BACKEND_TELEMETRY_SESSION, { name: 'startup', startTime: 12, elapsed: 34 }));
114
+ contribution.handle(createEvent('frontend/session-a', { name: 'startup', startTime: 12, elapsed: 34 }));
115
+ contribution.handle(createEvent('frontend/session-a', { ...storedResult, name: 'second' }));
116
+ contribution.handle(createEvent('frontend/session-b', { name: 'startup', startTime: 12, elapsed: 34 }));
117
+
118
+ const metrics = contribution.getMetrics();
119
+ expect(metrics).to.contain('id="backend", name="startup"');
120
+ expect(metrics).to.contain('id="frontend-1", name="startup"');
121
+ expect(metrics).to.contain('id="frontend-1", name="second"');
122
+ expect(metrics).to.contain('id="frontend-2", name="startup"');
123
+ });
124
+
125
+ it('does not append telemetry events above DEBUG level', () => {
126
+ const contribution = new TestMeasurementMetricsBackendContribution();
127
+ contribution.configure(LogLevel.INFO);
128
+ contribution.startCollecting();
129
+
130
+ contribution.handle(createEvent(BACKEND_TELEMETRY_SESSION, { ...storedResult }));
131
+
132
+ expect(contribution.getMetrics()).to.equal('');
133
+ });
134
+
135
+ it('dispatches telemetry events through the backend and frontend extension points', () => {
136
+ const contribution = new OverridingMeasurementMetricsBackendContribution();
137
+ contribution.configure(LogLevel.DEBUG);
138
+ const frontendResult = { ...storedResult, owner: 'frontend' };
139
+
140
+ contribution.handle(createEvent(BACKEND_TELEMETRY_SESSION, { ...storedResult }));
141
+ contribution.handle(createEvent('frontend/session-a', frontendResult));
142
+
143
+ expect(contribution.backendMeasurements).to.deep.equal([storedResult]);
144
+ expect(contribution.frontendMeasurements).to.deep.equal([['frontend/session-a', frontendResult]]);
145
+ });
146
+
147
+ it('reports measurement data with optional owner', () => {
148
+ const reports: unknown[][] = [];
149
+ const telemetryService: TelemetryService = {
150
+ report: (topic, data, options) => reports.push([topic, data, options])
151
+ };
152
+
153
+ reportMeasurement(telemetryService, storedResult);
154
+ reportMeasurement(telemetryService, { ...storedResult, owner: 'frontend' });
155
+
156
+ expect(reports).to.deep.equal([
157
+ [MEASUREMENT_TELEMETRY_TOPIC, storedResult, undefined],
158
+ [MEASUREMENT_TELEMETRY_TOPIC, { ...storedResult, owner: 'frontend' }, undefined]
159
+ ]);
160
+ });
161
+
162
+ it('ignores malformed measurement payloads', () => {
163
+ const contribution = new TestMeasurementMetricsBackendContribution();
164
+ contribution.configure(LogLevel.DEBUG);
165
+ contribution.startCollecting();
166
+ const initialMetrics = contribution.getMetrics();
167
+
168
+ contribution.handle(createEvent('session-a', { name: 'invalid' }));
169
+
170
+ expect(contribution.getMetrics()).to.equal(initialMetrics);
171
+ });
172
+ });
@@ -0,0 +1,46 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 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 { LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
18
+ import { BackendApplicationContribution } from '@theia/core/lib/node';
19
+ import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
20
+ import { inject, injectable } from '@theia/core/shared/inversify';
21
+ import { TelemetryService } from '@theia/telemetry/lib/common';
22
+ import { reportMeasurement } from '../common';
23
+
24
+ @injectable()
25
+ export class MeasurementTelemetryContribution implements BackendApplicationContribution {
26
+ @inject(Stopwatch)
27
+ protected stopwatch: Stopwatch;
28
+
29
+ @inject(LogLevelCliContribution)
30
+ protected logLevelCli: LogLevelCliContribution;
31
+
32
+ @inject(TelemetryService)
33
+ protected telemetryService: TelemetryService;
34
+
35
+ onStart(): void {
36
+ if (this.logLevelCli.defaultLogLevel !== LogLevel.DEBUG) {
37
+ return;
38
+ }
39
+ this.stopwatch.storedMeasurements.forEach(result => this.report(result));
40
+ this.stopwatch.onDidAddMeasurementResult(result => this.report(result));
41
+ }
42
+
43
+ protected report(result: MeasurementResult): void {
44
+ reportMeasurement(this.telemetryService, result);
45
+ }
46
+ }
@@ -14,15 +14,16 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { ContainerModule } from '@theia/core/shared/inversify';
17
+ import { bindRootContributionProvider } from '@theia/core/lib/common';
18
18
  import { BackendApplicationContribution } from '@theia/core/lib/node';
19
- import { ConnectionHandler, RpcConnectionHandler, bindRootContributionProvider } from '@theia/core/lib/common';
20
- import { MetricsContribution } from './metrics-contribution';
21
- import { NodeMetricsContribution } from './node-metrics-contribution';
19
+ import { ContainerModule } from '@theia/core/shared/inversify';
20
+ import { TelemetrySink } from '@theia/telemetry/lib/node';
22
21
  import { ExtensionMetricsContribution } from './extensions-metrics-contribution';
23
- import { MetricsBackendApplicationContribution } from './metrics-backend-application-contribution';
24
- import { measurementNotificationServicePath } from '../common';
25
22
  import { MeasurementMetricsBackendContribution } from './measurement-metrics-contribution';
23
+ import { MeasurementTelemetryContribution } from './measurement-telemetry-contribution';
24
+ import { MetricsBackendApplicationContribution } from './metrics-backend-application-contribution';
25
+ import { MetricsContribution } from './metrics-contribution';
26
+ import { NodeMetricsContribution } from './node-metrics-contribution';
26
27
 
27
28
  export default new ContainerModule(bind => {
28
29
  bindRootContributionProvider(bind, MetricsContribution);
@@ -31,10 +32,9 @@ export default new ContainerModule(bind => {
31
32
 
32
33
  bind(MeasurementMetricsBackendContribution).toSelf().inSingletonScope();
33
34
  bind(MetricsContribution).toService(MeasurementMetricsBackendContribution);
34
- bind(ConnectionHandler).toDynamicValue(ctx =>
35
- new RpcConnectionHandler(measurementNotificationServicePath,
36
- () => ctx.container.get(MeasurementMetricsBackendContribution)));
35
+ bind(TelemetrySink).toService(MeasurementMetricsBackendContribution);
37
36
 
38
37
  bind(BackendApplicationContribution).to(MetricsBackendApplicationContribution).inSingletonScope();
38
+ bind(BackendApplicationContribution).to(MeasurementTelemetryContribution).inSingletonScope();
39
39
 
40
40
  });
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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"}