@theia/plugin-metrics 1.77.0-next.1 → 1.77.0-next.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/plugin-metrics-creator.d.ts +1 -1
- package/lib/browser/plugin-metrics-creator.d.ts.map +1 -1
- package/lib/browser/plugin-metrics-creator.js +12 -17
- package/lib/browser/plugin-metrics-creator.js.map +1 -1
- package/lib/browser/plugin-metrics-frontend-module.js +17 -19
- package/lib/browser/plugin-metrics-frontend-module.js.map +1 -1
- package/lib/browser/plugin-metrics-languages-main.js +11 -15
- package/lib/browser/plugin-metrics-languages-main.js.map +1 -1
- package/lib/browser/plugin-metrics-output-registry.d.ts +1 -1
- package/lib/browser/plugin-metrics-output-registry.d.ts.map +1 -1
- package/lib/browser/plugin-metrics-output-registry.js +12 -16
- package/lib/browser/plugin-metrics-output-registry.js.map +1 -1
- package/lib/browser/plugin-metrics-resolver.js +10 -14
- package/lib/browser/plugin-metrics-resolver.js.map +1 -1
- package/lib/browser-only/browser-only-plugin-metrics.d.ts +10 -0
- package/lib/browser-only/browser-only-plugin-metrics.d.ts.map +1 -0
- package/lib/browser-only/browser-only-plugin-metrics.js +32 -0
- package/lib/browser-only/browser-only-plugin-metrics.js.map +1 -0
- package/lib/browser-only/browser-only-plugin-metrics.spec.d.ts +2 -0
- package/lib/browser-only/browser-only-plugin-metrics.spec.d.ts.map +1 -0
- package/lib/browser-only/browser-only-plugin-metrics.spec.js +40 -0
- package/lib/browser-only/browser-only-plugin-metrics.spec.js.map +1 -0
- package/lib/browser-only/plugin-metrics-frontend-only-module.d.ts +4 -0
- package/lib/browser-only/plugin-metrics-frontend-only-module.d.ts.map +1 -0
- package/lib/browser-only/plugin-metrics-frontend-only-module.js +29 -0
- package/lib/browser-only/plugin-metrics-frontend-only-module.js.map +1 -0
- package/lib/common/metrics-protocol.js +3 -6
- package/lib/common/metrics-protocol.js.map +1 -1
- package/lib/common/plugin-metrics-types.js +3 -8
- package/lib/common/plugin-metrics-types.js.map +1 -1
- package/lib/node/metric-output/plugin-metrics-time-count.d.ts +1 -1
- package/lib/node/metric-output/plugin-metrics-time-count.d.ts.map +1 -1
- package/lib/node/metric-output/plugin-metrics-time-count.js +5 -8
- package/lib/node/metric-output/plugin-metrics-time-count.js.map +1 -1
- package/lib/node/metric-output/plugin-metrics-time-sum.d.ts +1 -1
- package/lib/node/metric-output/plugin-metrics-time-sum.d.ts.map +1 -1
- package/lib/node/metric-output/plugin-metrics-time-sum.js +5 -8
- package/lib/node/metric-output/plugin-metrics-time-sum.js.map +1 -1
- package/lib/node/metric-string-generator.d.ts +1 -1
- package/lib/node/metric-string-generator.d.ts.map +1 -1
- package/lib/node/metric-string-generator.js +11 -16
- package/lib/node/metric-string-generator.js.map +1 -1
- package/lib/node/metrics-contributor.d.ts +2 -2
- package/lib/node/metrics-contributor.d.ts.map +1 -1
- package/lib/node/metrics-contributor.js +5 -8
- package/lib/node/metrics-contributor.js.map +1 -1
- package/lib/node/metrics-contributor.spec.js +23 -25
- package/lib/node/metrics-contributor.spec.js.map +1 -1
- package/lib/node/plugin-metrics-backend-module.js +22 -24
- package/lib/node/plugin-metrics-backend-module.js.map +1 -1
- package/lib/node/plugin-metrics-impl.d.ts +1 -1
- package/lib/node/plugin-metrics-impl.d.ts.map +1 -1
- package/lib/node/plugin-metrics-impl.js +5 -9
- package/lib/node/plugin-metrics-impl.js.map +1 -1
- package/lib/node/plugin-metrics.d.ts +2 -2
- package/lib/node/plugin-metrics.d.ts.map +1 -1
- package/lib/node/plugin-metrics.js +16 -18
- package/lib/node/plugin-metrics.js.map +1 -1
- package/lib/node/plugin-metrics.spec.d.ts +2 -0
- package/lib/node/plugin-metrics.spec.d.ts.map +1 -0
- package/lib/node/plugin-metrics.spec.js +67 -0
- package/lib/node/plugin-metrics.spec.js.map +1 -0
- package/package.json +15 -6
- package/src/browser/plugin-metrics-creator.ts +2 -2
- package/src/browser/plugin-metrics-frontend-module.ts +5 -5
- package/src/browser/plugin-metrics-languages-main.ts +1 -1
- package/src/browser/plugin-metrics-output-registry.ts +2 -2
- package/src/browser/plugin-metrics-resolver.ts +2 -2
- package/src/browser-only/browser-only-plugin-metrics.spec.ts +44 -0
- package/src/browser-only/browser-only-plugin-metrics.ts +32 -0
- package/src/browser-only/plugin-metrics-frontend-only-module.ts +29 -0
- package/src/node/metric-output/plugin-metrics-time-count.ts +1 -1
- package/src/node/metric-output/plugin-metrics-time-sum.ts +1 -1
- package/src/node/metric-string-generator.ts +3 -3
- package/src/node/metrics-contributor.spec.ts +4 -4
- package/src/node/metrics-contributor.ts +2 -2
- package/src/node/plugin-metrics-backend-module.ts +7 -7
- package/src/node/plugin-metrics-impl.ts +2 -3
- package/src/node/plugin-metrics.spec.ts +80 -0
- package/src/node/plugin-metrics.ts +4 -4
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// *****************************************************************************
|
|
3
2
|
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
4
3
|
//
|
|
@@ -14,14 +13,15 @@
|
|
|
14
13
|
//
|
|
15
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
15
|
// *****************************************************************************
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const metrics_contributor_1 = require("./metrics-contributor");
|
|
23
|
-
const metric_string_generator_1 = require("./metric-string-generator");
|
|
16
|
+
import { __decorate } from "tslib";
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { METRICS_TIMEOUT } from '../common/metrics-protocol.js';
|
|
19
|
+
import { PluginMetricsContributor } from './metrics-contributor.js';
|
|
20
|
+
import { PluginMetricStringGenerator } from './metric-string-generator.js';
|
|
24
21
|
let PluginMetricsContribution = class PluginMetricsContribution {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.metrics = '';
|
|
24
|
+
}
|
|
25
25
|
getMetrics() {
|
|
26
26
|
return this.metrics;
|
|
27
27
|
}
|
|
@@ -29,19 +29,17 @@ let PluginMetricsContribution = class PluginMetricsContribution {
|
|
|
29
29
|
setInterval(() => {
|
|
30
30
|
const reconciledMetrics = this.metricsContributor.reconcile();
|
|
31
31
|
this.metrics = this.stringGenerator.getMetricsString(reconciledMetrics);
|
|
32
|
-
},
|
|
32
|
+
}, METRICS_TIMEOUT);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
(0, inversify_1.inject)(metrics_contributor_1.PluginMetricsContributor),
|
|
38
|
-
tslib_1.__metadata("design:type", metrics_contributor_1.PluginMetricsContributor)
|
|
35
|
+
__decorate([
|
|
36
|
+
inject(PluginMetricsContributor)
|
|
39
37
|
], PluginMetricsContribution.prototype, "metricsContributor", void 0);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
tslib_1.__metadata("design:type", metric_string_generator_1.PluginMetricStringGenerator)
|
|
38
|
+
__decorate([
|
|
39
|
+
inject(PluginMetricStringGenerator)
|
|
43
40
|
], PluginMetricsContribution.prototype, "stringGenerator", void 0);
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
PluginMetricsContribution = __decorate([
|
|
42
|
+
injectable()
|
|
46
43
|
], PluginMetricsContribution);
|
|
44
|
+
export { PluginMetricsContribution };
|
|
47
45
|
//# sourceMappingURL=plugin-metrics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-metrics.js","sourceRoot":"","sources":["../../src/node/plugin-metrics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-metrics.js","sourceRoot":"","sources":["../../src/node/plugin-metrics.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,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAGpE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAA/B;QAQK,YAAO,GAAG,EAAE,CAAC;IAYzB,CAAC;IAVG,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,eAAe;QACX,WAAW,CAAC,GAAG,EAAE;YACb,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC;YAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QAC5E,CAAC,EAAE,eAAe,CAAC,CAAC;IACxB,CAAC;CACJ,CAAA;AAjBsB;IADlB,MAAM,CAAC,wBAAwB,CAAC;qEAC+B;AAG7C;IADlB,MAAM,CAAC,2BAA2B,CAAC;kEAC4B;AANvD,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CAoBrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-metrics.spec.d.ts","sourceRoot":"","sources":["../../src/node/plugin-metrics.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 Sahil Gupta 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 { Container, ContainerModule } from '@theia/core/shared/inversify';
|
|
17
|
+
import { PluginMetricsContribution } from './plugin-metrics.js';
|
|
18
|
+
import { PluginMetricsContributor } from './metrics-contributor.js';
|
|
19
|
+
import { PluginMetricStringGenerator } from './metric-string-generator.js';
|
|
20
|
+
import { METRICS_TIMEOUT } from '../common/metrics-protocol.js';
|
|
21
|
+
import * as assert from 'assert';
|
|
22
|
+
import * as sinon from 'sinon';
|
|
23
|
+
const COLLECTED_METRICS = 'test_metric 42\n';
|
|
24
|
+
describe('PluginMetricsContribution:', () => {
|
|
25
|
+
let testContainer;
|
|
26
|
+
let contribution;
|
|
27
|
+
let clock;
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
clock = sinon.useFakeTimers();
|
|
30
|
+
testContainer = new Container();
|
|
31
|
+
// Stub dependencies
|
|
32
|
+
const stubContributor = {
|
|
33
|
+
reconcile: () => ({})
|
|
34
|
+
};
|
|
35
|
+
const stubGenerator = {
|
|
36
|
+
getMetricsString: () => COLLECTED_METRICS
|
|
37
|
+
};
|
|
38
|
+
const module = new ContainerModule(bind => {
|
|
39
|
+
bind(PluginMetricsContributor).toConstantValue(stubContributor);
|
|
40
|
+
bind(PluginMetricStringGenerator).toConstantValue(stubGenerator);
|
|
41
|
+
bind(PluginMetricsContribution).toSelf().inSingletonScope();
|
|
42
|
+
});
|
|
43
|
+
testContainer.load(module);
|
|
44
|
+
contribution = testContainer.get(PluginMetricsContribution);
|
|
45
|
+
});
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
clock.restore();
|
|
48
|
+
});
|
|
49
|
+
describe('getMetrics:', () => {
|
|
50
|
+
it('should return empty string instead of undefined before startCollecting runs', () => {
|
|
51
|
+
// When getMetrics is called before the interval has collected any data
|
|
52
|
+
const metrics = contribution.getMetrics();
|
|
53
|
+
// Then it returns an empty string, not undefined
|
|
54
|
+
assert.strictEqual(metrics, '');
|
|
55
|
+
assert.strictEqual(typeof metrics, 'string');
|
|
56
|
+
});
|
|
57
|
+
it('should return the collected metrics once the collection interval has elapsed', () => {
|
|
58
|
+
contribution.startCollecting();
|
|
59
|
+
// The interval has not yet fired, so nothing has been collected
|
|
60
|
+
assert.strictEqual(contribution.getMetrics(), '');
|
|
61
|
+
clock.tick(METRICS_TIMEOUT);
|
|
62
|
+
// The interval has fired, so the generated metrics string is returned
|
|
63
|
+
assert.strictEqual(contribution.getMetrics(), COLLECTED_METRICS);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=plugin-metrics.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-metrics.spec.js","sourceRoot":"","sources":["../../src/node/plugin-metrics.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6CAA6C;AAC7C,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,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAE7C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACxC,IAAI,aAAwB,CAAC;IAC7B,IAAI,YAAuC,CAAC;IAC5C,IAAI,KAA4B,CAAC;IAEjC,UAAU,CAAC,GAAG,EAAE;QACZ,KAAK,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QAC9B,aAAa,GAAG,IAAI,SAAS,EAAE,CAAC;QAEhC,oBAAoB;QACpB,MAAM,eAAe,GAAsC;YACvD,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;SACxB,CAAC;QACF,MAAM,aAAa,GAAyC;YACxD,gBAAgB,EAAE,GAAG,EAAE,CAAC,iBAAiB;SAC5C,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;YACtC,IAAI,CAAC,wBAAwB,CAAC,CAAC,eAAe,CAAC,eAAsD,CAAC,CAAC;YACvG,IAAI,CAAC,2BAA2B,CAAC,CAAC,eAAe,CAAC,aAAuD,CAAC,CAAC;YAC3G,IAAI,CAAC,yBAAyB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;YACnF,uEAAuE;YACvE,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,EAAE,CAAC;YAE1C,iDAAiD;YACjD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAChC,MAAM,CAAC,WAAW,CAAC,OAAO,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8EAA8E,EAAE,GAAG,EAAE;YACpF,YAAY,CAAC,eAAe,EAAE,CAAC;YAE/B,gEAAgE;YAChE,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;YAElD,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAE5B,sEAAsE;YACtE,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,iBAAiB,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/plugin-metrics",
|
|
3
|
-
"version": "1.77.0-next.
|
|
3
|
+
"version": "1.77.0-next.108+30a548238",
|
|
4
4
|
"description": "Theia - Plugin Metrics",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.77.0-next.
|
|
7
|
-
"@theia/metrics": "1.77.0-next.
|
|
7
|
+
"@theia/core": "1.77.0-next.108+30a548238",
|
|
8
|
+
"@theia/metrics": "1.77.0-next.108+30a548238",
|
|
8
9
|
"@theia/monaco-editor-core": "1.108.201",
|
|
9
|
-
"@theia/plugin": "1.77.0-next.
|
|
10
|
-
"@theia/plugin-ext": "1.77.0-next.
|
|
10
|
+
"@theia/plugin": "1.77.0-next.108+30a548238",
|
|
11
|
+
"@theia/plugin-ext": "1.77.0-next.108+30a548238",
|
|
11
12
|
"tslib": "^2.8.1"
|
|
12
13
|
},
|
|
13
14
|
"publishConfig": {
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
"theiaExtensions": [
|
|
17
18
|
{
|
|
18
19
|
"frontend": "lib/browser/plugin-metrics-frontend-module",
|
|
20
|
+
"frontendOnly": "lib/browser-only/plugin-metrics-frontend-only-module",
|
|
19
21
|
"backend": "lib/node/plugin-metrics-backend-module"
|
|
20
22
|
}
|
|
21
23
|
],
|
|
@@ -49,5 +51,12 @@
|
|
|
49
51
|
"nyc": {
|
|
50
52
|
"extends": "../../configs/nyc.json"
|
|
51
53
|
},
|
|
52
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "30a5482386400715f42b541b4b142fd399ada7f3",
|
|
55
|
+
"exports": {
|
|
56
|
+
"./package.json": "./package.json",
|
|
57
|
+
"./lib/*.json": "./lib/*.json",
|
|
58
|
+
"./lib/*.js": "./lib/*.js",
|
|
59
|
+
"./lib/*": "./lib/*.js",
|
|
60
|
+
"./*": "./*"
|
|
61
|
+
}
|
|
53
62
|
}
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { PluginMetrics, METRICS_TIMEOUT } from '../common/metrics-protocol';
|
|
19
|
-
import { AnalyticsFromRequests, DataFromRequest, createRequestData, createDefaultAnalytics, MetricsMap } from '../common/plugin-metrics-types';
|
|
18
|
+
import { PluginMetrics, METRICS_TIMEOUT } from '../common/metrics-protocol.js';
|
|
19
|
+
import { AnalyticsFromRequests, DataFromRequest, createRequestData, createDefaultAnalytics, MetricsMap } from '../common/plugin-metrics-types.js';
|
|
20
20
|
|
|
21
21
|
@injectable()
|
|
22
22
|
export class PluginMetricsCreator {
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
-
import { LanguagesMainPluginMetrics } from './plugin-metrics-languages-main';
|
|
19
|
-
import { PluginMetrics, metricsJsonRpcPath } from '../common/metrics-protocol';
|
|
18
|
+
import { LanguagesMainPluginMetrics } from './plugin-metrics-languages-main.js';
|
|
19
|
+
import { PluginMetrics, metricsJsonRpcPath } from '../common/metrics-protocol.js';
|
|
20
20
|
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider';
|
|
21
|
-
import { PluginMetricsCreator } from './plugin-metrics-creator';
|
|
22
|
-
import { PluginMetricsResolver } from './plugin-metrics-resolver';
|
|
23
|
-
import { PluginMetricsOutputChannelRegistry } from './plugin-metrics-output-registry';
|
|
21
|
+
import { PluginMetricsCreator } from './plugin-metrics-creator.js';
|
|
22
|
+
import { PluginMetricsResolver } from './plugin-metrics-resolver.js';
|
|
23
|
+
import { PluginMetricsOutputChannelRegistry } from './plugin-metrics-output-registry.js';
|
|
24
24
|
import { LanguagesMainImpl } from '@theia/plugin-ext/lib/main/browser/languages-main';
|
|
25
25
|
import { OutputChannelRegistryMainImpl } from '@theia/plugin-ext/lib/main/browser/output-channel-registry-main';
|
|
26
26
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { CodeActionProviderDocumentation, Range, SerializedDocumentFilter, WorkspaceSymbolParams } from '@theia/plugin-ext/lib/common/plugin-api-rpc-model';
|
|
18
|
-
import { PluginMetricsResolver } from './plugin-metrics-resolver';
|
|
18
|
+
import { PluginMetricsResolver } from './plugin-metrics-resolver.js';
|
|
19
19
|
import { LanguagesMainImpl } from '@theia/plugin-ext/lib/main/browser/languages-main';
|
|
20
20
|
import { SymbolInformation } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
21
21
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
18
|
import { OutputChannelRegistryMainImpl } from '@theia/plugin-ext/lib/main/browser/output-channel-registry-main';
|
|
19
|
-
import { PluginMetricsCreator } from './plugin-metrics-creator';
|
|
20
|
-
import { createDefaultRequestData } from '../common/plugin-metrics-types';
|
|
19
|
+
import { PluginMetricsCreator } from './plugin-metrics-creator.js';
|
|
20
|
+
import { createDefaultRequestData } from '../common/plugin-metrics-types.js';
|
|
21
21
|
import { PluginInfo } from '@theia/plugin-ext/lib/common/plugin-api-rpc';
|
|
22
22
|
|
|
23
23
|
@injectable()
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
18
|
|
|
19
19
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
20
|
-
import { PluginMetricsCreator } from './plugin-metrics-creator';
|
|
21
|
-
import { createRequestData } from '../common/plugin-metrics-types';
|
|
20
|
+
import { PluginMetricsCreator } from './plugin-metrics-creator.js';
|
|
21
|
+
import { createRequestData } from '../common/plugin-metrics-types.js';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* This class helps resolve language server requests into successes or failures
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 Robert Jandow
|
|
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 { Container } from '@theia/core/shared/inversify';
|
|
18
|
+
import { expect } from 'chai';
|
|
19
|
+
import { PluginMetrics } from '../common/metrics-protocol.js';
|
|
20
|
+
import { BrowserOnlyPluginMetrics } from './browser-only-plugin-metrics.js';
|
|
21
|
+
import pluginMetricsFrontendOnlyModule from './plugin-metrics-frontend-only-module.js';
|
|
22
|
+
|
|
23
|
+
describe('browser-only plugin metrics', () => {
|
|
24
|
+
it('binds the no-op metrics', () => {
|
|
25
|
+
const container = new Container();
|
|
26
|
+
container.load(pluginMetricsFrontendOnlyModule);
|
|
27
|
+
|
|
28
|
+
const metrics = container.get<PluginMetrics>(PluginMetrics);
|
|
29
|
+
expect(metrics).to.be.instanceOf(BrowserOnlyPluginMetrics);
|
|
30
|
+
expect(() => metrics.setMetrics('metric 1')).not.to.throw();
|
|
31
|
+
expect(metrics.getMetrics()).to.equal('');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('replaces an existing metrics binding', () => {
|
|
35
|
+
const container = new Container();
|
|
36
|
+
container.bind(PluginMetrics).toConstantValue({
|
|
37
|
+
setMetrics: () => { },
|
|
38
|
+
getMetrics: () => 'existing'
|
|
39
|
+
});
|
|
40
|
+
container.load(pluginMetricsFrontendOnlyModule);
|
|
41
|
+
|
|
42
|
+
expect(container.get(PluginMetrics)).to.be.instanceOf(BrowserOnlyPluginMetrics);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 Robert Jandow
|
|
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 { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { PluginMetrics } from '../common/metrics-protocol.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Browser-only apps have no backend to expose metrics, so they are dropped. The `frontend` module
|
|
22
|
+
* isn't loaded there, so this binding is what keeps `PluginMetrics` injectable.
|
|
23
|
+
*/
|
|
24
|
+
@injectable()
|
|
25
|
+
export class BrowserOnlyPluginMetrics implements PluginMetrics {
|
|
26
|
+
|
|
27
|
+
setMetrics(_metrics: string): void { }
|
|
28
|
+
|
|
29
|
+
getMetrics(): string {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 Robert Jandow
|
|
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 { PluginMetrics } from '../common/metrics-protocol.js';
|
|
19
|
+
import { BrowserOnlyPluginMetrics } from './browser-only-plugin-metrics.js';
|
|
20
|
+
|
|
21
|
+
// Loaded instead of the `frontend` module, so plugin API calls aren't wrapped to collect metrics.
|
|
22
|
+
export default new ContainerModule((bind, _unbind, isBound, rebind) => {
|
|
23
|
+
bind(BrowserOnlyPluginMetrics).toSelf().inSingletonScope();
|
|
24
|
+
if (isBound(PluginMetrics)) {
|
|
25
|
+
rebind(PluginMetrics).toService(BrowserOnlyPluginMetrics);
|
|
26
|
+
} else {
|
|
27
|
+
bind(PluginMetrics).toService(BrowserOnlyPluginMetrics);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types';
|
|
17
|
+
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types.js';
|
|
18
18
|
import { injectable } from '@theia/core/shared/inversify';
|
|
19
19
|
|
|
20
20
|
@injectable()
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types';
|
|
17
|
+
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types.js';
|
|
18
18
|
import { injectable } from '@theia/core/shared/inversify';
|
|
19
19
|
|
|
20
20
|
@injectable()
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
//
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
|
-
import { PluginMetricTimeCount } from './metric-output/plugin-metrics-time-count';
|
|
17
|
-
import { PluginMetricTimeSum } from './metric-output/plugin-metrics-time-sum';
|
|
18
|
-
import { MetricsMap } from '../common/plugin-metrics-types';
|
|
16
|
+
import { PluginMetricTimeCount } from './metric-output/plugin-metrics-time-count.js';
|
|
17
|
+
import { PluginMetricTimeSum } from './metric-output/plugin-metrics-time-sum.js';
|
|
18
|
+
import { MetricsMap } from '../common/plugin-metrics-types.js';
|
|
19
19
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
20
20
|
|
|
21
21
|
@injectable()
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { AnalyticsFromRequests } from '../common/plugin-metrics-types';
|
|
18
|
-
import { PluginMetricsContributor } from './metrics-contributor';
|
|
17
|
+
import { AnalyticsFromRequests } from '../common/plugin-metrics-types.js';
|
|
18
|
+
import { PluginMetricsContributor } from './metrics-contributor.js';
|
|
19
19
|
import { Container, ContainerModule } from '@theia/core/shared/inversify';
|
|
20
|
-
import { PluginMetricsImpl } from './plugin-metrics-impl';
|
|
21
|
-
import { PluginMetrics } from '../common/metrics-protocol';
|
|
20
|
+
import { PluginMetricsImpl } from './plugin-metrics-impl.js';
|
|
21
|
+
import { PluginMetrics } from '../common/metrics-protocol.js';
|
|
22
22
|
import * as assert from 'assert';
|
|
23
23
|
import { ILogger } from '@theia/core/lib/common/logger';
|
|
24
24
|
import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { PluginMetrics } from '../common/metrics-protocol';
|
|
17
|
+
import { PluginMetrics } from '../common/metrics-protocol.js';
|
|
18
18
|
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import { AnalyticsFromRequests, MetricsMap } from '../common/plugin-metrics-types';
|
|
19
|
+
import { AnalyticsFromRequests, MetricsMap } from '../common/plugin-metrics-types.js';
|
|
20
20
|
|
|
21
21
|
@injectable()
|
|
22
22
|
export class PluginMetricsContributor {
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { MetricsContribution } from '@theia/metrics/lib/node/metrics-contribution';
|
|
18
|
-
import { PluginMetricsContribution } from './plugin-metrics';
|
|
19
|
-
import { PluginMetrics, metricsJsonRpcPath } from '../common/metrics-protocol';
|
|
20
|
-
import { PluginMetricsImpl } from './plugin-metrics-impl';
|
|
18
|
+
import { PluginMetricsContribution } from './plugin-metrics.js';
|
|
19
|
+
import { PluginMetrics, metricsJsonRpcPath } from '../common/metrics-protocol.js';
|
|
20
|
+
import { PluginMetricsImpl } from './plugin-metrics-impl.js';
|
|
21
21
|
import { ConnectionHandler } from '@theia/core/lib/common/messaging/handler';
|
|
22
22
|
import { RpcConnectionHandler } from '@theia/core';
|
|
23
23
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
24
|
-
import { PluginMetricsContributor } from './metrics-contributor';
|
|
25
|
-
import { PluginMetricTimeSum } from './metric-output/plugin-metrics-time-sum';
|
|
26
|
-
import { PluginMetricTimeCount } from './metric-output/plugin-metrics-time-count';
|
|
27
|
-
import { PluginMetricStringGenerator } from './metric-string-generator';
|
|
24
|
+
import { PluginMetricsContributor } from './metrics-contributor.js';
|
|
25
|
+
import { PluginMetricTimeSum } from './metric-output/plugin-metrics-time-sum.js';
|
|
26
|
+
import { PluginMetricTimeCount } from './metric-output/plugin-metrics-time-count.js';
|
|
27
|
+
import { PluginMetricStringGenerator } from './metric-string-generator.js';
|
|
28
28
|
|
|
29
29
|
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
30
30
|
bind(PluginMetricTimeSum).toSelf().inSingletonScope();
|
|
@@ -15,15 +15,14 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { PluginMetrics } from '../common/metrics-protocol';
|
|
18
|
+
import { PluginMetrics } from '../common/metrics-protocol.js';
|
|
19
19
|
|
|
20
20
|
@injectable()
|
|
21
21
|
export class PluginMetricsImpl implements PluginMetrics {
|
|
22
22
|
|
|
23
23
|
private metrics: string = '{}';
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
setMetrics(metrics: string) {
|
|
25
|
+
setMetrics(metrics: string): void {
|
|
27
26
|
this.metrics = metrics;
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 Sahil Gupta 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 { Container, ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { PluginMetricsContribution } from './plugin-metrics.js';
|
|
19
|
+
import { PluginMetricsContributor } from './metrics-contributor.js';
|
|
20
|
+
import { PluginMetricStringGenerator } from './metric-string-generator.js';
|
|
21
|
+
import { METRICS_TIMEOUT } from '../common/metrics-protocol.js';
|
|
22
|
+
import * as assert from 'assert';
|
|
23
|
+
import * as sinon from 'sinon';
|
|
24
|
+
|
|
25
|
+
const COLLECTED_METRICS = 'test_metric 42\n';
|
|
26
|
+
|
|
27
|
+
describe('PluginMetricsContribution:', () => {
|
|
28
|
+
let testContainer: Container;
|
|
29
|
+
let contribution: PluginMetricsContribution;
|
|
30
|
+
let clock: sinon.SinonFakeTimers;
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
clock = sinon.useFakeTimers();
|
|
34
|
+
testContainer = new Container();
|
|
35
|
+
|
|
36
|
+
// Stub dependencies
|
|
37
|
+
const stubContributor: Partial<PluginMetricsContributor> = {
|
|
38
|
+
reconcile: () => ({})
|
|
39
|
+
};
|
|
40
|
+
const stubGenerator: Partial<PluginMetricStringGenerator> = {
|
|
41
|
+
getMetricsString: () => COLLECTED_METRICS
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const module = new ContainerModule(bind => {
|
|
45
|
+
bind(PluginMetricsContributor).toConstantValue(stubContributor as unknown as PluginMetricsContributor);
|
|
46
|
+
bind(PluginMetricStringGenerator).toConstantValue(stubGenerator as unknown as PluginMetricStringGenerator);
|
|
47
|
+
bind(PluginMetricsContribution).toSelf().inSingletonScope();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
testContainer.load(module);
|
|
51
|
+
contribution = testContainer.get(PluginMetricsContribution);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterEach(() => {
|
|
55
|
+
clock.restore();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('getMetrics:', () => {
|
|
59
|
+
it('should return empty string instead of undefined before startCollecting runs', () => {
|
|
60
|
+
// When getMetrics is called before the interval has collected any data
|
|
61
|
+
const metrics = contribution.getMetrics();
|
|
62
|
+
|
|
63
|
+
// Then it returns an empty string, not undefined
|
|
64
|
+
assert.strictEqual(metrics, '');
|
|
65
|
+
assert.strictEqual(typeof metrics, 'string');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should return the collected metrics once the collection interval has elapsed', () => {
|
|
69
|
+
contribution.startCollecting();
|
|
70
|
+
|
|
71
|
+
// The interval has not yet fired, so nothing has been collected
|
|
72
|
+
assert.strictEqual(contribution.getMetrics(), '');
|
|
73
|
+
|
|
74
|
+
clock.tick(METRICS_TIMEOUT);
|
|
75
|
+
|
|
76
|
+
// The interval has fired, so the generated metrics string is returned
|
|
77
|
+
assert.strictEqual(contribution.getMetrics(), COLLECTED_METRICS);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
18
|
import { MetricsContribution } from '@theia/metrics/lib/node/metrics-contribution';
|
|
19
|
-
import { METRICS_TIMEOUT } from '../common/metrics-protocol';
|
|
20
|
-
import { PluginMetricsContributor } from './metrics-contributor';
|
|
21
|
-
import { PluginMetricStringGenerator } from './metric-string-generator';
|
|
19
|
+
import { METRICS_TIMEOUT } from '../common/metrics-protocol.js';
|
|
20
|
+
import { PluginMetricsContributor } from './metrics-contributor.js';
|
|
21
|
+
import { PluginMetricStringGenerator } from './metric-string-generator.js';
|
|
22
22
|
|
|
23
23
|
@injectable()
|
|
24
24
|
export class PluginMetricsContribution implements MetricsContribution {
|
|
@@ -29,7 +29,7 @@ export class PluginMetricsContribution implements MetricsContribution {
|
|
|
29
29
|
@inject(PluginMetricStringGenerator)
|
|
30
30
|
protected readonly stringGenerator: PluginMetricStringGenerator;
|
|
31
31
|
|
|
32
|
-
private metrics
|
|
32
|
+
private metrics = '';
|
|
33
33
|
|
|
34
34
|
getMetrics(): string {
|
|
35
35
|
return this.metrics;
|