@theia/plugin-metrics 1.34.2 → 1.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +641 -641
- package/README.md +63 -63
- package/lib/browser/plugin-metrics-creator.d.ts +67 -67
- package/lib/browser/plugin-metrics-creator.js +185 -185
- package/lib/browser/plugin-metrics-frontend-module.d.ts +3 -3
- package/lib/browser/plugin-metrics-frontend-module.js +36 -36
- package/lib/browser/plugin-metrics-languages-main.d.ts +58 -58
- package/lib/browser/plugin-metrics-languages-main.js +211 -211
- package/lib/browser/plugin-metrics-output-registry.d.ts +7 -7
- package/lib/browser/plugin-metrics-output-registry.js +48 -48
- package/lib/browser/plugin-metrics-resolver.d.ts +17 -17
- package/lib/browser/plugin-metrics-resolver.js +69 -69
- package/lib/common/metrics-protocol.d.ts +10 -10
- package/lib/common/metrics-protocol.js +24 -24
- package/lib/common/plugin-metrics-types.d.ts +27 -27
- package/lib/common/plugin-metrics-types.js +56 -56
- package/lib/node/metric-output/plugin-metrics-time-count.d.ts +5 -5
- package/lib/node/metric-output/plugin-metrics-time-count.js +43 -43
- package/lib/node/metric-output/plugin-metrics-time-sum.d.ts +5 -5
- package/lib/node/metric-output/plugin-metrics-time-sum.js +41 -41
- package/lib/node/metric-string-generator.d.ts +6 -6
- package/lib/node/metric-string-generator.js +78 -78
- package/lib/node/metrics-contributor.d.ts +6 -6
- package/lib/node/metrics-contributor.js +76 -76
- package/lib/node/metrics-contributor.spec.d.ts +1 -1
- package/lib/node/metrics-contributor.spec.js +203 -203
- package/lib/node/plugin-metrics-backend-module.d.ts +3 -3
- package/lib/node/plugin-metrics-backend-module.js +47 -47
- package/lib/node/plugin-metrics-impl.d.ts +10 -10
- package/lib/node/plugin-metrics-impl.js +45 -45
- package/lib/node/plugin-metrics.d.ts +10 -10
- package/lib/node/plugin-metrics.js +54 -54
- package/package.json +7 -7
- package/src/browser/plugin-metrics-creator.ts +189 -189
- package/src/browser/plugin-metrics-frontend-module.ts +38 -38
- package/src/browser/plugin-metrics-languages-main.ts +325 -325
- package/src/browser/plugin-metrics-output-registry.ts +37 -37
- package/src/browser/plugin-metrics-resolver.ts +57 -57
- package/src/common/metrics-protocol.ts +27 -27
- package/src/common/plugin-metrics-types.ts +80 -80
- package/src/node/metric-output/plugin-metrics-time-count.ts +36 -36
- package/src/node/metric-output/plugin-metrics-time-sum.ts +35 -35
- package/src/node/metric-string-generator.ts +70 -70
- package/src/node/metrics-contributor.spec.ts +234 -234
- package/src/node/metrics-contributor.ts +70 -70
- package/src/node/plugin-metrics-backend-module.ts +49 -49
- package/src/node/plugin-metrics-impl.ts +38 -38
- package/src/node/plugin-metrics.ts +44 -44
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { PluginMetrics } from '../common/metrics-protocol';
|
|
18
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import { AnalyticsFromRequests, MetricsMap } from '../common/plugin-metrics-types';
|
|
20
|
-
|
|
21
|
-
@injectable()
|
|
22
|
-
export class PluginMetricsContributor {
|
|
23
|
-
clients: Set<PluginMetrics> = new Set();
|
|
24
|
-
|
|
25
|
-
reconcile(): MetricsMap {
|
|
26
|
-
const reconciledMap: MetricsMap = {};
|
|
27
|
-
this.clients.forEach(c => {
|
|
28
|
-
const extensionIDtoMap = JSON.parse(c.getMetrics()) as MetricsMap;
|
|
29
|
-
|
|
30
|
-
for (const vscodeExtensionID in extensionIDtoMap) {
|
|
31
|
-
if (!extensionIDtoMap.hasOwnProperty(vscodeExtensionID)) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!reconciledMap[vscodeExtensionID]) {
|
|
36
|
-
reconciledMap[vscodeExtensionID] = extensionIDtoMap[vscodeExtensionID];
|
|
37
|
-
} else {
|
|
38
|
-
const methodToAnalytics = extensionIDtoMap[vscodeExtensionID];
|
|
39
|
-
for (const method in methodToAnalytics) {
|
|
40
|
-
|
|
41
|
-
if (!methodToAnalytics.hasOwnProperty(method)) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!reconciledMap[vscodeExtensionID][method]) {
|
|
46
|
-
reconciledMap[vscodeExtensionID][method] = methodToAnalytics[method];
|
|
47
|
-
} else {
|
|
48
|
-
const currentAnalytic = reconciledMap[vscodeExtensionID][method];
|
|
49
|
-
if (!methodToAnalytics[method]) {
|
|
50
|
-
reconciledMap[vscodeExtensionID][method] = currentAnalytic;
|
|
51
|
-
} else {
|
|
52
|
-
// It does have the method
|
|
53
|
-
// Then we need to reconcile the two analytics from requests
|
|
54
|
-
const newAnalytic = methodToAnalytics[method] as AnalyticsFromRequests;
|
|
55
|
-
newAnalytic.sumOfTimeForSuccess = newAnalytic.sumOfTimeForSuccess + currentAnalytic.sumOfTimeForSuccess;
|
|
56
|
-
newAnalytic.sumOfTimeForFailure = newAnalytic.sumOfTimeForFailure + currentAnalytic.sumOfTimeForFailure;
|
|
57
|
-
newAnalytic.totalRequests += currentAnalytic.totalRequests;
|
|
58
|
-
newAnalytic.successfulResponses += currentAnalytic.successfulResponses;
|
|
59
|
-
|
|
60
|
-
reconciledMap[vscodeExtensionID][method] = newAnalytic;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return reconciledMap;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { PluginMetrics } from '../common/metrics-protocol';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { AnalyticsFromRequests, MetricsMap } from '../common/plugin-metrics-types';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class PluginMetricsContributor {
|
|
23
|
+
clients: Set<PluginMetrics> = new Set();
|
|
24
|
+
|
|
25
|
+
reconcile(): MetricsMap {
|
|
26
|
+
const reconciledMap: MetricsMap = {};
|
|
27
|
+
this.clients.forEach(c => {
|
|
28
|
+
const extensionIDtoMap = JSON.parse(c.getMetrics()) as MetricsMap;
|
|
29
|
+
|
|
30
|
+
for (const vscodeExtensionID in extensionIDtoMap) {
|
|
31
|
+
if (!extensionIDtoMap.hasOwnProperty(vscodeExtensionID)) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!reconciledMap[vscodeExtensionID]) {
|
|
36
|
+
reconciledMap[vscodeExtensionID] = extensionIDtoMap[vscodeExtensionID];
|
|
37
|
+
} else {
|
|
38
|
+
const methodToAnalytics = extensionIDtoMap[vscodeExtensionID];
|
|
39
|
+
for (const method in methodToAnalytics) {
|
|
40
|
+
|
|
41
|
+
if (!methodToAnalytics.hasOwnProperty(method)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!reconciledMap[vscodeExtensionID][method]) {
|
|
46
|
+
reconciledMap[vscodeExtensionID][method] = methodToAnalytics[method];
|
|
47
|
+
} else {
|
|
48
|
+
const currentAnalytic = reconciledMap[vscodeExtensionID][method];
|
|
49
|
+
if (!methodToAnalytics[method]) {
|
|
50
|
+
reconciledMap[vscodeExtensionID][method] = currentAnalytic;
|
|
51
|
+
} else {
|
|
52
|
+
// It does have the method
|
|
53
|
+
// Then we need to reconcile the two analytics from requests
|
|
54
|
+
const newAnalytic = methodToAnalytics[method] as AnalyticsFromRequests;
|
|
55
|
+
newAnalytic.sumOfTimeForSuccess = newAnalytic.sumOfTimeForSuccess + currentAnalytic.sumOfTimeForSuccess;
|
|
56
|
+
newAnalytic.sumOfTimeForFailure = newAnalytic.sumOfTimeForFailure + currentAnalytic.sumOfTimeForFailure;
|
|
57
|
+
newAnalytic.totalRequests += currentAnalytic.totalRequests;
|
|
58
|
+
newAnalytic.successfulResponses += currentAnalytic.successfulResponses;
|
|
59
|
+
|
|
60
|
+
reconciledMap[vscodeExtensionID][method] = newAnalytic;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return reconciledMap;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { 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';
|
|
21
|
-
import { ConnectionHandler } from '@theia/core/lib/common/messaging/handler';
|
|
22
|
-
import { JsonRpcConnectionHandler } from '@theia/core';
|
|
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';
|
|
28
|
-
|
|
29
|
-
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
30
|
-
bind(PluginMetricTimeSum).toSelf().inSingletonScope();
|
|
31
|
-
bind(PluginMetricTimeCount).toSelf().inSingletonScope();
|
|
32
|
-
bind(PluginMetrics).to(PluginMetricsImpl).inTransientScope();
|
|
33
|
-
bind(PluginMetricStringGenerator).toSelf().inSingletonScope();
|
|
34
|
-
bind(PluginMetricsContributor).toSelf().inSingletonScope();
|
|
35
|
-
bind(ConnectionHandler).toDynamicValue(ctx => {
|
|
36
|
-
const clients = ctx.container.get(PluginMetricsContributor);
|
|
37
|
-
return new JsonRpcConnectionHandler(metricsJsonRpcPath, client => {
|
|
38
|
-
const pluginMetricsHandler: PluginMetrics = ctx.container.get(PluginMetrics);
|
|
39
|
-
clients.clients.add(pluginMetricsHandler);
|
|
40
|
-
client.onDidCloseConnection(() => {
|
|
41
|
-
clients.clients.delete(pluginMetricsHandler);
|
|
42
|
-
});
|
|
43
|
-
return pluginMetricsHandler;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
).inSingletonScope();
|
|
47
|
-
|
|
48
|
-
bind(MetricsContribution).to(PluginMetricsContribution).inSingletonScope();
|
|
49
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { 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';
|
|
21
|
+
import { ConnectionHandler } from '@theia/core/lib/common/messaging/handler';
|
|
22
|
+
import { JsonRpcConnectionHandler } from '@theia/core';
|
|
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';
|
|
28
|
+
|
|
29
|
+
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
30
|
+
bind(PluginMetricTimeSum).toSelf().inSingletonScope();
|
|
31
|
+
bind(PluginMetricTimeCount).toSelf().inSingletonScope();
|
|
32
|
+
bind(PluginMetrics).to(PluginMetricsImpl).inTransientScope();
|
|
33
|
+
bind(PluginMetricStringGenerator).toSelf().inSingletonScope();
|
|
34
|
+
bind(PluginMetricsContributor).toSelf().inSingletonScope();
|
|
35
|
+
bind(ConnectionHandler).toDynamicValue(ctx => {
|
|
36
|
+
const clients = ctx.container.get(PluginMetricsContributor);
|
|
37
|
+
return new JsonRpcConnectionHandler(metricsJsonRpcPath, client => {
|
|
38
|
+
const pluginMetricsHandler: PluginMetrics = ctx.container.get(PluginMetrics);
|
|
39
|
+
clients.clients.add(pluginMetricsHandler);
|
|
40
|
+
client.onDidCloseConnection(() => {
|
|
41
|
+
clients.clients.delete(pluginMetricsHandler);
|
|
42
|
+
});
|
|
43
|
+
return pluginMetricsHandler;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
).inSingletonScope();
|
|
47
|
+
|
|
48
|
+
bind(MetricsContribution).to(PluginMetricsContribution).inSingletonScope();
|
|
49
|
+
});
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { PluginMetrics } from '../common/metrics-protocol';
|
|
19
|
-
|
|
20
|
-
@injectable()
|
|
21
|
-
export class PluginMetricsImpl implements PluginMetrics {
|
|
22
|
-
|
|
23
|
-
private metrics: string = '{}';
|
|
24
|
-
|
|
25
|
-
// tslint:disable-next-line:typedef
|
|
26
|
-
setMetrics(metrics: string) {
|
|
27
|
-
this.metrics = metrics;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* This sends all the information about metrics inside of the plugins to the backend
|
|
32
|
-
* where it is served on the /metrics endpoint
|
|
33
|
-
*/
|
|
34
|
-
getMetrics(): string {
|
|
35
|
-
return this.metrics;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { PluginMetrics } from '../common/metrics-protocol';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class PluginMetricsImpl implements PluginMetrics {
|
|
22
|
+
|
|
23
|
+
private metrics: string = '{}';
|
|
24
|
+
|
|
25
|
+
// tslint:disable-next-line:typedef
|
|
26
|
+
setMetrics(metrics: string) {
|
|
27
|
+
this.metrics = metrics;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* This sends all the information about metrics inside of the plugins to the backend
|
|
32
|
+
* where it is served on the /metrics endpoint
|
|
33
|
+
*/
|
|
34
|
+
getMetrics(): string {
|
|
35
|
+
return this.metrics;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
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';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class PluginMetricsContribution implements MetricsContribution {
|
|
25
|
-
|
|
26
|
-
@inject(PluginMetricsContributor)
|
|
27
|
-
protected readonly metricsContributor: PluginMetricsContributor;
|
|
28
|
-
|
|
29
|
-
@inject(PluginMetricStringGenerator)
|
|
30
|
-
protected readonly stringGenerator: PluginMetricStringGenerator;
|
|
31
|
-
|
|
32
|
-
private metrics: string;
|
|
33
|
-
|
|
34
|
-
getMetrics(): string {
|
|
35
|
-
return this.metrics;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
startCollecting(): void {
|
|
39
|
-
setInterval(() => {
|
|
40
|
-
const reconciledMetrics = this.metricsContributor.reconcile();
|
|
41
|
-
this.metrics = this.stringGenerator.getMetricsString(reconciledMetrics);
|
|
42
|
-
}, METRICS_TIMEOUT);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
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';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class PluginMetricsContribution implements MetricsContribution {
|
|
25
|
+
|
|
26
|
+
@inject(PluginMetricsContributor)
|
|
27
|
+
protected readonly metricsContributor: PluginMetricsContributor;
|
|
28
|
+
|
|
29
|
+
@inject(PluginMetricStringGenerator)
|
|
30
|
+
protected readonly stringGenerator: PluginMetricStringGenerator;
|
|
31
|
+
|
|
32
|
+
private metrics: string;
|
|
33
|
+
|
|
34
|
+
getMetrics(): string {
|
|
35
|
+
return this.metrics;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
startCollecting(): void {
|
|
39
|
+
setInterval(() => {
|
|
40
|
+
const reconciledMetrics = this.metricsContributor.reconcile();
|
|
41
|
+
this.metrics = this.stringGenerator.getMetricsString(reconciledMetrics);
|
|
42
|
+
}, METRICS_TIMEOUT);
|
|
43
|
+
}
|
|
44
|
+
}
|