@theia/metrics 1.48.0 → 1.48.1
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/README.md +30 -30
- package/lib/browser/metrics-frontend-application-contribution.d.ts +12 -12
- package/lib/browser/metrics-frontend-application-contribution.js +58 -58
- package/lib/browser/metrics-frontend-module.d.ts +3 -3
- package/lib/browser/metrics-frontend-module.js +28 -28
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +19 -19
- package/lib/common/measurement-notification-service.d.ts +11 -11
- package/lib/common/measurement-notification-service.js +20 -20
- package/lib/electron-node/electron-metrics-backend-module.d.ts +3 -3
- package/lib/electron-node/electron-metrics-backend-module.js +24 -24
- package/lib/electron-node/electron-token-validator.d.ts +9 -9
- package/lib/electron-node/electron-token-validator.js +43 -43
- package/lib/node/extensions-metrics-contribution.d.ts +8 -8
- package/lib/node/extensions-metrics-contribution.js +54 -54
- package/lib/node/index.d.ts +5 -5
- package/lib/node/index.js +23 -23
- package/lib/node/measurement-metrics-contribution.d.ts +17 -17
- package/lib/node/measurement-metrics-contribution.js +75 -75
- package/lib/node/metrics-backend-application-contribution.d.ts +16 -16
- package/lib/node/metrics-backend-application-contribution.js +50 -50
- package/lib/node/metrics-backend-module.d.ts +3 -3
- package/lib/node/metrics-backend-module.js +35 -35
- package/lib/node/metrics-contribution.d.ts +5 -5
- package/lib/node/metrics-contribution.js +19 -19
- package/lib/node/node-metrics-contribution.d.ts +5 -5
- package/lib/node/node-metrics-contribution.js +35 -35
- package/lib/node/prometheus.d.ts +2 -2
- package/lib/node/prometheus.js +27 -27
- package/lib/node/prometheus.spec.d.ts +1 -1
- package/lib/node/prometheus.spec.js +40 -40
- package/package.json +4 -4
- package/src/browser/metrics-frontend-application-contribution.ts +51 -51
- package/src/browser/metrics-frontend-module.ts +28 -28
- package/src/common/index.ts +17 -17
- package/src/common/measurement-notification-service.ts +29 -29
- package/src/electron-node/electron-metrics-backend-module.ts +24 -24
- package/src/electron-node/electron-token-validator.ts +37 -37
- package/src/node/extensions-metrics-contribution.ts +51 -51
- package/src/node/index.ts +21 -21
- package/src/node/measurement-metrics-contribution.ts +75 -75
- package/src/node/metrics-backend-application-contribution.ts +51 -51
- package/src/node/metrics-backend-module.ts +40 -40
- package/src/node/metrics-contribution.ts +20 -20
- package/src/node/node-metrics-contribution.ts +33 -33
- package/src/node/prometheus.spec.ts +49 -49
- package/src/node/prometheus.ts +25 -25
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ElectronTokenValidator } from '@theia/core/lib/electron-node/token/electron-token-validator';
|
|
19
|
-
import { IncomingMessage } from 'http';
|
|
20
|
-
import { MetricsBackendApplicationContribution } from '../node/metrics-backend-application-contribution';
|
|
21
|
-
import { MaybePromise } from '@theia/core';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class MetricsElectronTokenValidator extends ElectronTokenValidator {
|
|
25
|
-
@postConstruct()
|
|
26
|
-
protected override init(): void {
|
|
27
|
-
super.init();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override allowWsUpgrade(request: IncomingMessage): MaybePromise<boolean> {
|
|
31
|
-
return this.allowRequest(request);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override allowRequest(request: IncomingMessage): boolean {
|
|
35
|
-
return request.url === MetricsBackendApplicationContribution.ENDPOINT || super.allowRequest(request);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
+
import { ElectronTokenValidator } from '@theia/core/lib/electron-node/token/electron-token-validator';
|
|
19
|
+
import { IncomingMessage } from 'http';
|
|
20
|
+
import { MetricsBackendApplicationContribution } from '../node/metrics-backend-application-contribution';
|
|
21
|
+
import { MaybePromise } from '@theia/core';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class MetricsElectronTokenValidator extends ElectronTokenValidator {
|
|
25
|
+
@postConstruct()
|
|
26
|
+
protected override init(): void {
|
|
27
|
+
super.init();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override allowWsUpgrade(request: IncomingMessage): MaybePromise<boolean> {
|
|
31
|
+
return this.allowRequest(request);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override allowRequest(request: IncomingMessage): boolean {
|
|
35
|
+
return request.url === MetricsBackendApplicationContribution.ENDPOINT || super.allowRequest(request);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
17
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
18
|
-
import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
|
|
19
|
-
import { PROMETHEUS_REGEXP, toPrometheusValidName } from './prometheus';
|
|
20
|
-
|
|
21
|
-
const metricsName = 'theia_extension_version';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class ExtensionMetricsContribution implements MetricsContribution {
|
|
25
|
-
private metrics: string = '';
|
|
26
|
-
|
|
27
|
-
@inject(ApplicationPackage)
|
|
28
|
-
protected readonly applicationPackage: ApplicationPackage;
|
|
29
|
-
|
|
30
|
-
getMetrics(): string {
|
|
31
|
-
return this.metrics;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
startCollecting(): void {
|
|
35
|
-
let latestMetrics = '';
|
|
36
|
-
const installedExtensions = this.applicationPackage.extensionPackages;
|
|
37
|
-
latestMetrics += `# HELP ${metricsName} Theia extension version info.\n`;
|
|
38
|
-
latestMetrics += `# TYPE ${metricsName} gauge\n`;
|
|
39
|
-
installedExtensions.forEach(extensionInfo => {
|
|
40
|
-
let extensionName = extensionInfo.name;
|
|
41
|
-
if (!PROMETHEUS_REGEXP.test(extensionName)) {
|
|
42
|
-
extensionName = toPrometheusValidName(extensionName);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const metricsValue = metricsName + `{extension="${extensionName}",version="${extensionInfo.version}"} 1`;
|
|
46
|
-
latestMetrics += metricsValue + '\n';
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
this.metrics = latestMetrics;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
17
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
18
|
+
import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
|
|
19
|
+
import { PROMETHEUS_REGEXP, toPrometheusValidName } from './prometheus';
|
|
20
|
+
|
|
21
|
+
const metricsName = 'theia_extension_version';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class ExtensionMetricsContribution implements MetricsContribution {
|
|
25
|
+
private metrics: string = '';
|
|
26
|
+
|
|
27
|
+
@inject(ApplicationPackage)
|
|
28
|
+
protected readonly applicationPackage: ApplicationPackage;
|
|
29
|
+
|
|
30
|
+
getMetrics(): string {
|
|
31
|
+
return this.metrics;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
startCollecting(): void {
|
|
35
|
+
let latestMetrics = '';
|
|
36
|
+
const installedExtensions = this.applicationPackage.extensionPackages;
|
|
37
|
+
latestMetrics += `# HELP ${metricsName} Theia extension version info.\n`;
|
|
38
|
+
latestMetrics += `# TYPE ${metricsName} gauge\n`;
|
|
39
|
+
installedExtensions.forEach(extensionInfo => {
|
|
40
|
+
let extensionName = extensionInfo.name;
|
|
41
|
+
if (!PROMETHEUS_REGEXP.test(extensionName)) {
|
|
42
|
+
extensionName = toPrometheusValidName(extensionName);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const metricsValue = metricsName + `{extension="${extensionName}",version="${extensionInfo.version}"} 1`;
|
|
46
|
+
latestMetrics += metricsValue + '\n';
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
this.metrics = latestMetrics;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/node/index.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
export * from './metrics-backend-application-contribution';
|
|
18
|
-
export * from './metrics-contribution';
|
|
19
|
-
export * from './node-metrics-contribution';
|
|
20
|
-
export * from './extensions-metrics-contribution';
|
|
21
|
-
export * from './prometheus';
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export * from './metrics-backend-application-contribution';
|
|
18
|
+
export * from './metrics-contribution';
|
|
19
|
+
export * from './node-metrics-contribution';
|
|
20
|
+
export * from './extensions-metrics-contribution';
|
|
21
|
+
export * from './prometheus';
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
import { inject, injectable, } from '@theia/core/shared/inversify';
|
|
17
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
18
|
-
import { LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
|
|
19
|
-
import { MeasurementNotificationService } from '../common';
|
|
20
|
-
import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
|
|
21
|
-
|
|
22
|
-
const backendId = 'backend';
|
|
23
|
-
const metricsName = 'theia_measurements';
|
|
24
|
-
|
|
25
|
-
@injectable()
|
|
26
|
-
export class MeasurementMetricsBackendContribution implements MetricsContribution, MeasurementNotificationService {
|
|
27
|
-
@inject(Stopwatch)
|
|
28
|
-
protected backendStopwatch: Stopwatch;
|
|
29
|
-
|
|
30
|
-
@inject(LogLevelCliContribution)
|
|
31
|
-
protected logLevelCli: LogLevelCliContribution;
|
|
32
|
-
|
|
33
|
-
protected metrics = '';
|
|
34
|
-
protected frontendCounters = new Map<string, string>();
|
|
35
|
-
|
|
36
|
-
startCollecting(): void {
|
|
37
|
-
if (this.logLevelCli.defaultLogLevel !== LogLevel.DEBUG) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
this.metrics += `# HELP ${metricsName} Theia stopwatch measurement results.\n`;
|
|
41
|
-
this.metrics += `# TYPE ${metricsName} gauge\n`;
|
|
42
|
-
this.backendStopwatch.storedMeasurements.forEach(result => this.onBackendMeasurement(result));
|
|
43
|
-
this.backendStopwatch.onDidAddMeasurementResult(result => this.onBackendMeasurement(result));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getMetrics(): string {
|
|
47
|
-
return this.metrics;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
protected appendMetricsValue(id: string, result: MeasurementResult): void {
|
|
51
|
-
const { name, elapsed, startTime, owner } = result;
|
|
52
|
-
const labels: string = `id="${id}", name="${name}", startTime="${startTime}", owner="${owner}"`;
|
|
53
|
-
const metricsValue = `${metricsName}{${labels}} ${elapsed}`;
|
|
54
|
-
this.metrics += (metricsValue + '\n');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected onBackendMeasurement(result: MeasurementResult): void {
|
|
58
|
-
this.appendMetricsValue(backendId, result);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
protected createFrontendCounterId(frontendId: string): string {
|
|
62
|
-
const counterId = `frontend-${this.frontendCounters.size + 1}`;
|
|
63
|
-
this.frontendCounters.set(frontendId, counterId);
|
|
64
|
-
return counterId;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
protected toCounterId(frontendId: string): string {
|
|
68
|
-
return this.frontendCounters.get(frontendId) ?? this.createFrontendCounterId(frontendId);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
onFrontendMeasurement(frontendId: string, result: MeasurementResult): void {
|
|
72
|
-
this.appendMetricsValue(this.toCounterId(frontendId), result);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
import { inject, injectable, } from '@theia/core/shared/inversify';
|
|
17
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
18
|
+
import { LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
|
|
19
|
+
import { MeasurementNotificationService } from '../common';
|
|
20
|
+
import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution';
|
|
21
|
+
|
|
22
|
+
const backendId = 'backend';
|
|
23
|
+
const metricsName = 'theia_measurements';
|
|
24
|
+
|
|
25
|
+
@injectable()
|
|
26
|
+
export class MeasurementMetricsBackendContribution implements MetricsContribution, MeasurementNotificationService {
|
|
27
|
+
@inject(Stopwatch)
|
|
28
|
+
protected backendStopwatch: Stopwatch;
|
|
29
|
+
|
|
30
|
+
@inject(LogLevelCliContribution)
|
|
31
|
+
protected logLevelCli: LogLevelCliContribution;
|
|
32
|
+
|
|
33
|
+
protected metrics = '';
|
|
34
|
+
protected frontendCounters = new Map<string, string>();
|
|
35
|
+
|
|
36
|
+
startCollecting(): void {
|
|
37
|
+
if (this.logLevelCli.defaultLogLevel !== LogLevel.DEBUG) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.metrics += `# HELP ${metricsName} Theia stopwatch measurement results.\n`;
|
|
41
|
+
this.metrics += `# TYPE ${metricsName} gauge\n`;
|
|
42
|
+
this.backendStopwatch.storedMeasurements.forEach(result => this.onBackendMeasurement(result));
|
|
43
|
+
this.backendStopwatch.onDidAddMeasurementResult(result => this.onBackendMeasurement(result));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getMetrics(): string {
|
|
47
|
+
return this.metrics;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected appendMetricsValue(id: string, result: MeasurementResult): void {
|
|
51
|
+
const { name, elapsed, startTime, owner } = result;
|
|
52
|
+
const labels: string = `id="${id}", name="${name}", startTime="${startTime}", owner="${owner}"`;
|
|
53
|
+
const metricsValue = `${metricsName}{${labels}} ${elapsed}`;
|
|
54
|
+
this.metrics += (metricsValue + '\n');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected onBackendMeasurement(result: MeasurementResult): void {
|
|
58
|
+
this.appendMetricsValue(backendId, result);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected createFrontendCounterId(frontendId: string): string {
|
|
62
|
+
const counterId = `frontend-${this.frontendCounters.size + 1}`;
|
|
63
|
+
this.frontendCounters.set(frontendId, counterId);
|
|
64
|
+
return counterId;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected toCounterId(frontendId: string): string {
|
|
68
|
+
return this.frontendCounters.get(frontendId) ?? this.createFrontendCounterId(frontendId);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onFrontendMeasurement(frontendId: string, result: MeasurementResult): void {
|
|
72
|
+
this.appendMetricsValue(this.toCounterId(frontendId), result);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject, named } from '@theia/core/shared/inversify';
|
|
18
|
-
import * as http from 'http';
|
|
19
|
-
import * as https from 'https';
|
|
20
|
-
import * as express from '@theia/core/shared/express';
|
|
21
|
-
import { ContributionProvider } from '@theia/core/lib/common';
|
|
22
|
-
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
23
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
24
|
-
|
|
25
|
-
@injectable()
|
|
26
|
-
export class MetricsBackendApplicationContribution implements BackendApplicationContribution {
|
|
27
|
-
static ENDPOINT = '/metrics';
|
|
28
|
-
constructor(
|
|
29
|
-
@inject(ContributionProvider) @named(MetricsContribution)
|
|
30
|
-
protected readonly metricsProviders: ContributionProvider<MetricsContribution>
|
|
31
|
-
) {
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
configure(app: express.Application): void {
|
|
35
|
-
app.get(MetricsBackendApplicationContribution.ENDPOINT, (req, res) => {
|
|
36
|
-
const lastMetrics = this.fetchMetricsFromProviders();
|
|
37
|
-
res.send(lastMetrics);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
onStart(server: http.Server | https.Server): void {
|
|
42
|
-
this.metricsProviders.getContributions().forEach(contribution => {
|
|
43
|
-
contribution.startCollecting();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
fetchMetricsFromProviders(): string {
|
|
48
|
-
return this.metricsProviders.getContributions().reduce((total, contribution) =>
|
|
49
|
-
total += contribution.getMetrics() + '\n', '');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject, named } from '@theia/core/shared/inversify';
|
|
18
|
+
import * as http from 'http';
|
|
19
|
+
import * as https from 'https';
|
|
20
|
+
import * as express from '@theia/core/shared/express';
|
|
21
|
+
import { ContributionProvider } from '@theia/core/lib/common';
|
|
22
|
+
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
23
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
24
|
+
|
|
25
|
+
@injectable()
|
|
26
|
+
export class MetricsBackendApplicationContribution implements BackendApplicationContribution {
|
|
27
|
+
static ENDPOINT = '/metrics';
|
|
28
|
+
constructor(
|
|
29
|
+
@inject(ContributionProvider) @named(MetricsContribution)
|
|
30
|
+
protected readonly metricsProviders: ContributionProvider<MetricsContribution>
|
|
31
|
+
) {
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
configure(app: express.Application): void {
|
|
35
|
+
app.get(MetricsBackendApplicationContribution.ENDPOINT, (req, res) => {
|
|
36
|
+
const lastMetrics = this.fetchMetricsFromProviders();
|
|
37
|
+
res.send(lastMetrics);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onStart(server: http.Server | https.Server): void {
|
|
42
|
+
this.metricsProviders.getContributions().forEach(contribution => {
|
|
43
|
+
contribution.startCollecting();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fetchMetricsFromProviders(): string {
|
|
48
|
+
return this.metricsProviders.getContributions().reduce((total, contribution) =>
|
|
49
|
+
total += contribution.getMetrics() + '\n', '');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
-
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
19
|
-
import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '@theia/core/lib/common';
|
|
20
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
21
|
-
import { NodeMetricsContribution } from './node-metrics-contribution';
|
|
22
|
-
import { ExtensionMetricsContribution } from './extensions-metrics-contribution';
|
|
23
|
-
import { MetricsBackendApplicationContribution } from './metrics-backend-application-contribution';
|
|
24
|
-
import { measurementNotificationServicePath } from '../common';
|
|
25
|
-
import { MeasurementMetricsBackendContribution } from './measurement-metrics-contribution';
|
|
26
|
-
|
|
27
|
-
export default new ContainerModule(bind => {
|
|
28
|
-
bindContributionProvider(bind, MetricsContribution);
|
|
29
|
-
bind(MetricsContribution).to(NodeMetricsContribution).inSingletonScope();
|
|
30
|
-
bind(MetricsContribution).to(ExtensionMetricsContribution).inSingletonScope();
|
|
31
|
-
|
|
32
|
-
bind(MeasurementMetricsBackendContribution).toSelf().inSingletonScope();
|
|
33
|
-
bind(MetricsContribution).toService(MeasurementMetricsBackendContribution);
|
|
34
|
-
bind(ConnectionHandler).toDynamicValue(ctx =>
|
|
35
|
-
new RpcConnectionHandler(measurementNotificationServicePath,
|
|
36
|
-
() => ctx.container.get(MeasurementMetricsBackendContribution)));
|
|
37
|
-
|
|
38
|
-
bind(BackendApplicationContribution).to(MetricsBackendApplicationContribution).inSingletonScope();
|
|
39
|
-
|
|
40
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017-2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
19
|
+
import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '@theia/core/lib/common';
|
|
20
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
21
|
+
import { NodeMetricsContribution } from './node-metrics-contribution';
|
|
22
|
+
import { ExtensionMetricsContribution } from './extensions-metrics-contribution';
|
|
23
|
+
import { MetricsBackendApplicationContribution } from './metrics-backend-application-contribution';
|
|
24
|
+
import { measurementNotificationServicePath } from '../common';
|
|
25
|
+
import { MeasurementMetricsBackendContribution } from './measurement-metrics-contribution';
|
|
26
|
+
|
|
27
|
+
export default new ContainerModule(bind => {
|
|
28
|
+
bindContributionProvider(bind, MetricsContribution);
|
|
29
|
+
bind(MetricsContribution).to(NodeMetricsContribution).inSingletonScope();
|
|
30
|
+
bind(MetricsContribution).to(ExtensionMetricsContribution).inSingletonScope();
|
|
31
|
+
|
|
32
|
+
bind(MeasurementMetricsBackendContribution).toSelf().inSingletonScope();
|
|
33
|
+
bind(MetricsContribution).toService(MeasurementMetricsBackendContribution);
|
|
34
|
+
bind(ConnectionHandler).toDynamicValue(ctx =>
|
|
35
|
+
new RpcConnectionHandler(measurementNotificationServicePath,
|
|
36
|
+
() => ctx.container.get(MeasurementMetricsBackendContribution)));
|
|
37
|
+
|
|
38
|
+
bind(BackendApplicationContribution).to(MetricsBackendApplicationContribution).inSingletonScope();
|
|
39
|
+
|
|
40
|
+
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
export const MetricsContribution = Symbol('MetricsContribution');
|
|
17
|
-
export interface MetricsContribution {
|
|
18
|
-
startCollecting(): void;
|
|
19
|
-
getMetrics(): string;
|
|
20
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
export const MetricsContribution = Symbol('MetricsContribution');
|
|
17
|
+
export interface MetricsContribution {
|
|
18
|
+
startCollecting(): void;
|
|
19
|
+
getMetrics(): string;
|
|
20
|
+
}
|