@theia/metrics 1.53.0-next.55 → 1.53.0-next.64
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/package.json +3 -3
- 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
package/README.md
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
-
|
|
7
|
-
<h2>ECLIPSE THEIA - METRICS EXTENSION</h2>
|
|
8
|
-
|
|
9
|
-
<hr />
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
## Description
|
|
14
|
-
|
|
15
|
-
The `@theia/metrics` extension provides metrics using the [Prometheus](https://prometheus.io/) API.
|
|
16
|
-
|
|
17
|
-
## Additional Information
|
|
18
|
-
|
|
19
|
-
- [API documentation for `@theia/metrics`](https://eclipse-theia.github.io/theia/docs/next/modules/metrics.html)
|
|
20
|
-
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
21
|
-
- [Theia - Website](https://theia-ide.org/)
|
|
22
|
-
|
|
23
|
-
## License
|
|
24
|
-
|
|
25
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
26
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
27
|
-
|
|
28
|
-
## Trademark
|
|
29
|
-
"Theia" is a trademark of the Eclipse Foundation
|
|
30
|
-
https://www.eclipse.org/theia
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - METRICS EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/metrics` extension provides metrics using the [Prometheus](https://prometheus.io/) API.
|
|
16
|
+
|
|
17
|
+
## Additional Information
|
|
18
|
+
|
|
19
|
+
- [API documentation for `@theia/metrics`](https://eclipse-theia.github.io/theia/docs/next/modules/metrics.html)
|
|
20
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
21
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
26
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
27
|
+
|
|
28
|
+
## Trademark
|
|
29
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
30
|
+
https://www.eclipse.org/theia
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/metrics",
|
|
3
|
-
"version": "1.53.0-next.
|
|
3
|
+
"version": "1.53.0-next.64+23b351d26",
|
|
4
4
|
"description": "Theia - Metrics Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.53.0-next.
|
|
6
|
+
"@theia/core": "1.53.0-next.64+23b351d26",
|
|
7
7
|
"prom-client": "^10.2.0",
|
|
8
8
|
"tslib": "^2.6.2"
|
|
9
9
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"nyc": {
|
|
50
50
|
"extends": "../../configs/nyc.json"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "23b351d26346a2b5d6aca3ee81fba59c056132f7"
|
|
53
53
|
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
17
|
-
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
18
|
-
import { ILogger, LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
|
|
19
|
-
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
|
|
20
|
-
import { MeasurementNotificationService } from '../common';
|
|
21
|
-
|
|
22
|
-
@injectable()
|
|
23
|
-
export class MetricsFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
24
|
-
@inject(Stopwatch)
|
|
25
|
-
protected stopwatch: Stopwatch;
|
|
26
|
-
|
|
27
|
-
@inject(MeasurementNotificationService)
|
|
28
|
-
protected notificationService: MeasurementNotificationService;
|
|
29
|
-
|
|
30
|
-
@inject(ILogger)
|
|
31
|
-
protected logger: ILogger;
|
|
32
|
-
|
|
33
|
-
readonly id = UUID.uuid4();
|
|
34
|
-
|
|
35
|
-
initialize(): void {
|
|
36
|
-
this.doInitialize();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
protected async doInitialize(): Promise<void> {
|
|
40
|
-
const logLevel = await this.logger.getLogLevel();
|
|
41
|
-
if (logLevel !== LogLevel.DEBUG) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.stopwatch.storedMeasurements.forEach(result => this.notify(result));
|
|
45
|
-
this.stopwatch.onDidAddMeasurementResult(result => this.notify(result));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected notify(result: MeasurementResult): void {
|
|
49
|
-
this.notificationService.onFrontendMeasurement(this.id, result);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
17
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
18
|
+
import { ILogger, LogLevel, MeasurementResult, Stopwatch } from '@theia/core';
|
|
19
|
+
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
|
|
20
|
+
import { MeasurementNotificationService } from '../common';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class MetricsFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
24
|
+
@inject(Stopwatch)
|
|
25
|
+
protected stopwatch: Stopwatch;
|
|
26
|
+
|
|
27
|
+
@inject(MeasurementNotificationService)
|
|
28
|
+
protected notificationService: MeasurementNotificationService;
|
|
29
|
+
|
|
30
|
+
@inject(ILogger)
|
|
31
|
+
protected logger: ILogger;
|
|
32
|
+
|
|
33
|
+
readonly id = UUID.uuid4();
|
|
34
|
+
|
|
35
|
+
initialize(): void {
|
|
36
|
+
this.doInitialize();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected async doInitialize(): Promise<void> {
|
|
40
|
+
const logLevel = await this.logger.getLogLevel();
|
|
41
|
+
if (logLevel !== LogLevel.DEBUG) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.stopwatch.storedMeasurements.forEach(result => this.notify(result));
|
|
45
|
+
this.stopwatch.onDidAddMeasurementResult(result => this.notify(result));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected notify(result: MeasurementResult): void {
|
|
49
|
+
this.notificationService.onFrontendMeasurement(this.id, result);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
-
import { MetricsFrontendApplicationContribution } from './metrics-frontend-application-contribution';
|
|
19
|
-
import { MeasurementNotificationService, measurementNotificationServicePath } from '../common';
|
|
20
|
-
import { FrontendApplicationContribution, WebSocketConnectionProvider } from '@theia/core/lib/browser';
|
|
21
|
-
|
|
22
|
-
export default new ContainerModule(bind => {
|
|
23
|
-
bind(FrontendApplicationContribution).to(MetricsFrontendApplicationContribution).inSingletonScope();
|
|
24
|
-
bind(MeasurementNotificationService).toDynamicValue(ctx => {
|
|
25
|
-
const connection = ctx.container.get(WebSocketConnectionProvider);
|
|
26
|
-
return connection.createProxy<MeasurementNotificationService>(measurementNotificationServicePath);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { MetricsFrontendApplicationContribution } from './metrics-frontend-application-contribution';
|
|
19
|
+
import { MeasurementNotificationService, measurementNotificationServicePath } from '../common';
|
|
20
|
+
import { FrontendApplicationContribution, WebSocketConnectionProvider } from '@theia/core/lib/browser';
|
|
21
|
+
|
|
22
|
+
export default new ContainerModule(bind => {
|
|
23
|
+
bind(FrontendApplicationContribution).to(MetricsFrontendApplicationContribution).inSingletonScope();
|
|
24
|
+
bind(MeasurementNotificationService).toDynamicValue(ctx => {
|
|
25
|
+
const connection = ctx.container.get(WebSocketConnectionProvider);
|
|
26
|
+
return connection.createProxy<MeasurementNotificationService>(measurementNotificationServicePath);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/common/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
export * from './measurement-notification-service';
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export * from './measurement-notification-service';
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { MeasurementResult } from '@theia/core';
|
|
18
|
-
|
|
19
|
-
export const measurementNotificationServicePath = '/services/measurement-notification';
|
|
20
|
-
|
|
21
|
-
export const MeasurementNotificationService = Symbol('MeasurementNotificationService');
|
|
22
|
-
export interface MeasurementNotificationService {
|
|
23
|
-
/**
|
|
24
|
-
* Notify the backend when a fronted stopwatch provides a new measurement.
|
|
25
|
-
* @param frontendId The unique id associated with the frontend that sends the notification
|
|
26
|
-
* @param result The new measurement result
|
|
27
|
-
*/
|
|
28
|
-
onFrontendMeasurement(frontendId: string, result: MeasurementResult): void;
|
|
29
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { MeasurementResult } from '@theia/core';
|
|
18
|
+
|
|
19
|
+
export const measurementNotificationServicePath = '/services/measurement-notification';
|
|
20
|
+
|
|
21
|
+
export const MeasurementNotificationService = Symbol('MeasurementNotificationService');
|
|
22
|
+
export interface MeasurementNotificationService {
|
|
23
|
+
/**
|
|
24
|
+
* Notify the backend when a fronted stopwatch provides a new measurement.
|
|
25
|
+
* @param frontendId The unique id associated with the frontend that sends the notification
|
|
26
|
+
* @param result The new measurement result
|
|
27
|
+
*/
|
|
28
|
+
onFrontendMeasurement(frontendId: string, result: MeasurementResult): void;
|
|
29
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
-
import { MetricsElectronTokenValidator } from './electron-token-validator';
|
|
19
|
-
import { ElectronTokenValidator } from '@theia/core/lib/electron-node/token/electron-token-validator';
|
|
20
|
-
|
|
21
|
-
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
22
|
-
bind(MetricsElectronTokenValidator).toSelf().inSingletonScope();
|
|
23
|
-
rebind(ElectronTokenValidator).to(MetricsElectronTokenValidator);
|
|
24
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { MetricsElectronTokenValidator } from './electron-token-validator';
|
|
19
|
+
import { ElectronTokenValidator } from '@theia/core/lib/electron-node/token/electron-token-validator';
|
|
20
|
+
|
|
21
|
+
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
22
|
+
bind(MetricsElectronTokenValidator).toSelf().inSingletonScope();
|
|
23
|
+
rebind(ElectronTokenValidator).to(MetricsElectronTokenValidator);
|
|
24
|
+
});
|
|
@@ -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
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
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
|
-
import * as prom from 'prom-client';
|
|
18
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import { MetricsContribution } from './metrics-contribution';
|
|
20
|
-
|
|
21
|
-
@injectable()
|
|
22
|
-
export class NodeMetricsContribution implements MetricsContribution {
|
|
23
|
-
getMetrics(): string {
|
|
24
|
-
return prom.register.metrics().toString();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
startCollecting(): void {
|
|
28
|
-
const collectDefaultMetrics = prom.collectDefaultMetrics;
|
|
29
|
-
|
|
30
|
-
// Probe every 5th second.
|
|
31
|
-
collectDefaultMetrics({ timeout: 5000 });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
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
|
+
import * as prom from 'prom-client';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { MetricsContribution } from './metrics-contribution';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class NodeMetricsContribution implements MetricsContribution {
|
|
23
|
+
getMetrics(): string {
|
|
24
|
+
return prom.register.metrics().toString();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
startCollecting(): void {
|
|
28
|
+
const collectDefaultMetrics = prom.collectDefaultMetrics;
|
|
29
|
+
|
|
30
|
+
// Probe every 5th second.
|
|
31
|
+
collectDefaultMetrics({ timeout: 5000 });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
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
|
-
import * as chai from 'chai';
|
|
18
|
-
import { PROMETHEUS_REGEXP, toPrometheusValidName } from './prometheus';
|
|
19
|
-
|
|
20
|
-
const expect = chai.expect;
|
|
21
|
-
|
|
22
|
-
describe('Prometheus helper module', () => {
|
|
23
|
-
/* According to https://prometheus.io/docs/concepts/data_model/ */
|
|
24
|
-
|
|
25
|
-
const validName = 'theia_extension3242-:';
|
|
26
|
-
const invalidTheiaName = '@theia/something';
|
|
27
|
-
const validTheiaName = 'theia_something';
|
|
28
|
-
const invalidName2 = '@theia/?$%^ ';
|
|
29
|
-
|
|
30
|
-
it('Should correctly validate a metric name', () => {
|
|
31
|
-
expect(PROMETHEUS_REGEXP.test(validName)).to.be.true;
|
|
32
|
-
|
|
33
|
-
expect(PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
34
|
-
|
|
35
|
-
expect(PROMETHEUS_REGEXP.test(invalidName2)).to.be.false;
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('Should correctly return a valid name from an otherwise invalid prometheus string', () => {
|
|
40
|
-
expect(PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
41
|
-
|
|
42
|
-
const newName = toPrometheusValidName(invalidTheiaName);
|
|
43
|
-
expect(PROMETHEUS_REGEXP.test(newName)).to.be.true;
|
|
44
|
-
expect(newName).to.be.equal(validTheiaName);
|
|
45
|
-
|
|
46
|
-
const newName2 = toPrometheusValidName(invalidName2);
|
|
47
|
-
expect(PROMETHEUS_REGEXP.test(newName2)).to.be.true;
|
|
48
|
-
});
|
|
49
|
-
});
|
|
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
|
+
import * as chai from 'chai';
|
|
18
|
+
import { PROMETHEUS_REGEXP, toPrometheusValidName } from './prometheus';
|
|
19
|
+
|
|
20
|
+
const expect = chai.expect;
|
|
21
|
+
|
|
22
|
+
describe('Prometheus helper module', () => {
|
|
23
|
+
/* According to https://prometheus.io/docs/concepts/data_model/ */
|
|
24
|
+
|
|
25
|
+
const validName = 'theia_extension3242-:';
|
|
26
|
+
const invalidTheiaName = '@theia/something';
|
|
27
|
+
const validTheiaName = 'theia_something';
|
|
28
|
+
const invalidName2 = '@theia/?$%^ ';
|
|
29
|
+
|
|
30
|
+
it('Should correctly validate a metric name', () => {
|
|
31
|
+
expect(PROMETHEUS_REGEXP.test(validName)).to.be.true;
|
|
32
|
+
|
|
33
|
+
expect(PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
34
|
+
|
|
35
|
+
expect(PROMETHEUS_REGEXP.test(invalidName2)).to.be.false;
|
|
36
|
+
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('Should correctly return a valid name from an otherwise invalid prometheus string', () => {
|
|
40
|
+
expect(PROMETHEUS_REGEXP.test(invalidTheiaName)).to.be.false;
|
|
41
|
+
|
|
42
|
+
const newName = toPrometheusValidName(invalidTheiaName);
|
|
43
|
+
expect(PROMETHEUS_REGEXP.test(newName)).to.be.true;
|
|
44
|
+
expect(newName).to.be.equal(validTheiaName);
|
|
45
|
+
|
|
46
|
+
const newName2 = toPrometheusValidName(invalidName2);
|
|
47
|
+
expect(PROMETHEUS_REGEXP.test(newName2)).to.be.true;
|
|
48
|
+
});
|
|
49
|
+
});
|
package/src/node/prometheus.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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 function toPrometheusValidName(name: string): string {
|
|
18
|
-
/* Make sure that start of name is valid and respect [a-zA-Z_:] */
|
|
19
|
-
const validFirstCharString = name.replace(/(^[^a-zA-Z_:]+)/gi, '');
|
|
20
|
-
/* Make sure that rest of the name respect [a-zA-Z0-9_:]* */
|
|
21
|
-
const validPrometheusName = validFirstCharString.replace(/([^a-zA-Z0-9_:])/gi, '_');
|
|
22
|
-
return validPrometheusName;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const PROMETHEUS_REGEXP = /^[a-zA-Z_:][a-zA-Z0-9_:]*/;
|
|
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 function toPrometheusValidName(name: string): string {
|
|
18
|
+
/* Make sure that start of name is valid and respect [a-zA-Z_:] */
|
|
19
|
+
const validFirstCharString = name.replace(/(^[^a-zA-Z_:]+)/gi, '');
|
|
20
|
+
/* Make sure that rest of the name respect [a-zA-Z0-9_:]* */
|
|
21
|
+
const validPrometheusName = validFirstCharString.replace(/([^a-zA-Z0-9_:])/gi, '_');
|
|
22
|
+
return validPrometheusName;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const PROMETHEUS_REGEXP = /^[a-zA-Z_:][a-zA-Z0-9_:]*/;
|