@theia/plugin-metrics 1.34.2 → 1.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +641 -641
- package/README.md +63 -63
- package/lib/browser/plugin-metrics-creator.d.ts +67 -67
- package/lib/browser/plugin-metrics-creator.js +185 -185
- package/lib/browser/plugin-metrics-frontend-module.d.ts +3 -3
- package/lib/browser/plugin-metrics-frontend-module.js +36 -36
- package/lib/browser/plugin-metrics-languages-main.d.ts +58 -58
- package/lib/browser/plugin-metrics-languages-main.js +211 -211
- package/lib/browser/plugin-metrics-output-registry.d.ts +7 -7
- package/lib/browser/plugin-metrics-output-registry.js +48 -48
- package/lib/browser/plugin-metrics-resolver.d.ts +17 -17
- package/lib/browser/plugin-metrics-resolver.js +69 -69
- package/lib/common/metrics-protocol.d.ts +10 -10
- package/lib/common/metrics-protocol.js +24 -24
- package/lib/common/plugin-metrics-types.d.ts +27 -27
- package/lib/common/plugin-metrics-types.js +56 -56
- package/lib/node/metric-output/plugin-metrics-time-count.d.ts +5 -5
- package/lib/node/metric-output/plugin-metrics-time-count.js +43 -43
- package/lib/node/metric-output/plugin-metrics-time-sum.d.ts +5 -5
- package/lib/node/metric-output/plugin-metrics-time-sum.js +41 -41
- package/lib/node/metric-string-generator.d.ts +6 -6
- package/lib/node/metric-string-generator.js +78 -78
- package/lib/node/metrics-contributor.d.ts +6 -6
- package/lib/node/metrics-contributor.js +76 -76
- package/lib/node/metrics-contributor.spec.d.ts +1 -1
- package/lib/node/metrics-contributor.spec.js +203 -203
- package/lib/node/plugin-metrics-backend-module.d.ts +3 -3
- package/lib/node/plugin-metrics-backend-module.js +47 -47
- package/lib/node/plugin-metrics-impl.d.ts +10 -10
- package/lib/node/plugin-metrics-impl.js +45 -45
- package/lib/node/plugin-metrics.d.ts +10 -10
- package/lib/node/plugin-metrics.js +54 -54
- package/package.json +7 -7
- package/src/browser/plugin-metrics-creator.ts +189 -189
- package/src/browser/plugin-metrics-frontend-module.ts +38 -38
- package/src/browser/plugin-metrics-languages-main.ts +325 -325
- package/src/browser/plugin-metrics-output-registry.ts +37 -37
- package/src/browser/plugin-metrics-resolver.ts +57 -57
- package/src/common/metrics-protocol.ts +27 -27
- package/src/common/plugin-metrics-types.ts +80 -80
- package/src/node/metric-output/plugin-metrics-time-count.ts +36 -36
- package/src/node/metric-output/plugin-metrics-time-sum.ts +35 -35
- package/src/node/metric-string-generator.ts +70 -70
- package/src/node/metrics-contributor.spec.ts +234 -234
- package/src/node/metrics-contributor.ts +70 -70
- package/src/node/plugin-metrics-backend-module.ts +49 -49
- package/src/node/plugin-metrics-impl.ts +38 -38
- package/src/node/plugin-metrics.ts +44 -44
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { OutputChannelRegistryMainImpl } from '@theia/plugin-ext/lib/main/browser/output-channel-registry-main';
|
|
19
|
-
import { PluginMetricsCreator } from './plugin-metrics-creator';
|
|
20
|
-
import { createDefaultRequestData } from '../common/plugin-metrics-types';
|
|
21
|
-
import { PluginInfo } from '@theia/plugin-ext/lib/common/plugin-api-rpc';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class PluginMetricsOutputChannelRegistry extends OutputChannelRegistryMainImpl {
|
|
25
|
-
|
|
26
|
-
@inject(PluginMetricsCreator)
|
|
27
|
-
protected readonly pluginMetricsCreator: PluginMetricsCreator;
|
|
28
|
-
|
|
29
|
-
override $append(channelName: string, errorOrValue: string, pluginInfo: PluginInfo): PromiseLike<void> {
|
|
30
|
-
if (errorOrValue.startsWith('[Error')) {
|
|
31
|
-
const createdMetric = createDefaultRequestData(pluginInfo.id, errorOrValue);
|
|
32
|
-
this.pluginMetricsCreator.createErrorMetric(createdMetric);
|
|
33
|
-
}
|
|
34
|
-
return super.$append(channelName, errorOrValue, pluginInfo);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { OutputChannelRegistryMainImpl } from '@theia/plugin-ext/lib/main/browser/output-channel-registry-main';
|
|
19
|
+
import { PluginMetricsCreator } from './plugin-metrics-creator';
|
|
20
|
+
import { createDefaultRequestData } from '../common/plugin-metrics-types';
|
|
21
|
+
import { PluginInfo } from '@theia/plugin-ext/lib/common/plugin-api-rpc';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class PluginMetricsOutputChannelRegistry extends OutputChannelRegistryMainImpl {
|
|
25
|
+
|
|
26
|
+
@inject(PluginMetricsCreator)
|
|
27
|
+
protected readonly pluginMetricsCreator: PluginMetricsCreator;
|
|
28
|
+
|
|
29
|
+
override $append(channelName: string, errorOrValue: string, pluginInfo: PluginInfo): PromiseLike<void> {
|
|
30
|
+
if (errorOrValue.startsWith('[Error')) {
|
|
31
|
+
const createdMetric = createDefaultRequestData(pluginInfo.id, errorOrValue);
|
|
32
|
+
this.pluginMetricsCreator.createErrorMetric(createdMetric);
|
|
33
|
+
}
|
|
34
|
+
return super.$append(channelName, errorOrValue, pluginInfo);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
-
|
|
19
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
20
|
-
import { PluginMetricsCreator } from './plugin-metrics-creator';
|
|
21
|
-
import { createRequestData } from '../common/plugin-metrics-types';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* This class helps resolve language server requests into successes or failures
|
|
25
|
-
* and sends the data to the metricsExtractor
|
|
26
|
-
*/
|
|
27
|
-
@injectable()
|
|
28
|
-
export class PluginMetricsResolver {
|
|
29
|
-
|
|
30
|
-
@inject(PluginMetricsCreator)
|
|
31
|
-
private metricsCreator: PluginMetricsCreator;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Resolve a request for pluginID and create a metric based on whether or not
|
|
35
|
-
* the language server errored.
|
|
36
|
-
*
|
|
37
|
-
* @param pluginID the ID of the plugin that made the request
|
|
38
|
-
* @param method the method that was request
|
|
39
|
-
* @param request the result of the language server request
|
|
40
|
-
*/
|
|
41
|
-
async resolveRequest(pluginID: string, method: string, request: PromiseLike<any> | Promise<any> | Thenable<any> | any): Promise<any> {
|
|
42
|
-
const currentTime = performance.now();
|
|
43
|
-
try {
|
|
44
|
-
const value = await request;
|
|
45
|
-
this.createAndSetMetric(pluginID, method, performance.now() - currentTime, true);
|
|
46
|
-
return value;
|
|
47
|
-
} catch (error) {
|
|
48
|
-
this.createAndSetMetric(pluginID, method, performance.now() - currentTime, false);
|
|
49
|
-
return Promise.reject(error);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private createAndSetMetric(pluginID: string, method: string, time: number, successful: boolean): void {
|
|
54
|
-
const createdSuccessMetric = createRequestData(pluginID, method, time);
|
|
55
|
-
this.metricsCreator.createMetric(createdSuccessMetric, successful);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
+
|
|
19
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
20
|
+
import { PluginMetricsCreator } from './plugin-metrics-creator';
|
|
21
|
+
import { createRequestData } from '../common/plugin-metrics-types';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This class helps resolve language server requests into successes or failures
|
|
25
|
+
* and sends the data to the metricsExtractor
|
|
26
|
+
*/
|
|
27
|
+
@injectable()
|
|
28
|
+
export class PluginMetricsResolver {
|
|
29
|
+
|
|
30
|
+
@inject(PluginMetricsCreator)
|
|
31
|
+
private metricsCreator: PluginMetricsCreator;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a request for pluginID and create a metric based on whether or not
|
|
35
|
+
* the language server errored.
|
|
36
|
+
*
|
|
37
|
+
* @param pluginID the ID of the plugin that made the request
|
|
38
|
+
* @param method the method that was request
|
|
39
|
+
* @param request the result of the language server request
|
|
40
|
+
*/
|
|
41
|
+
async resolveRequest(pluginID: string, method: string, request: PromiseLike<any> | Promise<any> | Thenable<any> | any): Promise<any> {
|
|
42
|
+
const currentTime = performance.now();
|
|
43
|
+
try {
|
|
44
|
+
const value = await request;
|
|
45
|
+
this.createAndSetMetric(pluginID, method, performance.now() - currentTime, true);
|
|
46
|
+
return value;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
this.createAndSetMetric(pluginID, method, performance.now() - currentTime, false);
|
|
49
|
+
return Promise.reject(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private createAndSetMetric(pluginID: string, method: string, time: number, successful: boolean): void {
|
|
54
|
+
const createdSuccessMetric = createRequestData(pluginID, method, time);
|
|
55
|
+
this.metricsCreator.createMetric(createdSuccessMetric, successful);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The JSON-RPC interface for plugin metrics
|
|
19
|
-
*/
|
|
20
|
-
export const metricsJsonRpcPath = '/services/plugin-ext/metrics';
|
|
21
|
-
export const PluginMetrics = Symbol('PluginMetrics');
|
|
22
|
-
export interface PluginMetrics {
|
|
23
|
-
setMetrics(metrics: string): void;
|
|
24
|
-
getMetrics(): string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const METRICS_TIMEOUT = 10000;
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The JSON-RPC interface for plugin metrics
|
|
19
|
+
*/
|
|
20
|
+
export const metricsJsonRpcPath = '/services/plugin-ext/metrics';
|
|
21
|
+
export const PluginMetrics = Symbol('PluginMetrics');
|
|
22
|
+
export interface PluginMetrics {
|
|
23
|
+
setMetrics(metrics: string): void;
|
|
24
|
+
getMetrics(): string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const METRICS_TIMEOUT = 10000;
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
// Define common interfaces that multiple classes can use
|
|
18
|
-
|
|
19
|
-
export interface MetricsMap {
|
|
20
|
-
[extensionID: string]: MethodToAnalytics
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface MethodToAnalytics {
|
|
24
|
-
[methodID: string]: AnalyticsFromRequests;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface AnalyticsFromRequests {
|
|
28
|
-
totalRequests: number;
|
|
29
|
-
successfulResponses: number;
|
|
30
|
-
sumOfTimeForSuccess: number;
|
|
31
|
-
sumOfTimeForFailure: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface DataFromRequest {
|
|
35
|
-
pluginID: string;
|
|
36
|
-
errorContentsOrMethod: string;
|
|
37
|
-
timeTaken: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface MetricOutput {
|
|
41
|
-
header: string;
|
|
42
|
-
createMetricOutput(pluginID: string, method: string, requestAnalytics: AnalyticsFromRequests): string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Helper functions for creating an object that corresponds to the DataFromRequest interface
|
|
47
|
-
*/
|
|
48
|
-
export function createRequestData(pluginID: string, errorContentsOrMethod: string, timeTaken: number): DataFromRequest {
|
|
49
|
-
return {
|
|
50
|
-
pluginID,
|
|
51
|
-
errorContentsOrMethod,
|
|
52
|
-
timeTaken
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function createDefaultRequestData(pluginID: string, errorContentsOrMethod: string): DataFromRequest {
|
|
57
|
-
return {
|
|
58
|
-
pluginID,
|
|
59
|
-
errorContentsOrMethod,
|
|
60
|
-
timeTaken: 0
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function createDefaultAnalytics(timeTaken: number, isRequestSuccessful: boolean): AnalyticsFromRequests {
|
|
65
|
-
if (isRequestSuccessful) {
|
|
66
|
-
return {
|
|
67
|
-
sumOfTimeForSuccess: timeTaken,
|
|
68
|
-
sumOfTimeForFailure: 0,
|
|
69
|
-
successfulResponses: 0,
|
|
70
|
-
totalRequests: 0
|
|
71
|
-
};
|
|
72
|
-
} else {
|
|
73
|
-
return {
|
|
74
|
-
sumOfTimeForSuccess: 0,
|
|
75
|
-
sumOfTimeForFailure: timeTaken,
|
|
76
|
-
successfulResponses: 0,
|
|
77
|
-
totalRequests: 0
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
// Define common interfaces that multiple classes can use
|
|
18
|
+
|
|
19
|
+
export interface MetricsMap {
|
|
20
|
+
[extensionID: string]: MethodToAnalytics
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface MethodToAnalytics {
|
|
24
|
+
[methodID: string]: AnalyticsFromRequests;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AnalyticsFromRequests {
|
|
28
|
+
totalRequests: number;
|
|
29
|
+
successfulResponses: number;
|
|
30
|
+
sumOfTimeForSuccess: number;
|
|
31
|
+
sumOfTimeForFailure: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface DataFromRequest {
|
|
35
|
+
pluginID: string;
|
|
36
|
+
errorContentsOrMethod: string;
|
|
37
|
+
timeTaken: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface MetricOutput {
|
|
41
|
+
header: string;
|
|
42
|
+
createMetricOutput(pluginID: string, method: string, requestAnalytics: AnalyticsFromRequests): string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Helper functions for creating an object that corresponds to the DataFromRequest interface
|
|
47
|
+
*/
|
|
48
|
+
export function createRequestData(pluginID: string, errorContentsOrMethod: string, timeTaken: number): DataFromRequest {
|
|
49
|
+
return {
|
|
50
|
+
pluginID,
|
|
51
|
+
errorContentsOrMethod,
|
|
52
|
+
timeTaken
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function createDefaultRequestData(pluginID: string, errorContentsOrMethod: string): DataFromRequest {
|
|
57
|
+
return {
|
|
58
|
+
pluginID,
|
|
59
|
+
errorContentsOrMethod,
|
|
60
|
+
timeTaken: 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function createDefaultAnalytics(timeTaken: number, isRequestSuccessful: boolean): AnalyticsFromRequests {
|
|
65
|
+
if (isRequestSuccessful) {
|
|
66
|
+
return {
|
|
67
|
+
sumOfTimeForSuccess: timeTaken,
|
|
68
|
+
sumOfTimeForFailure: 0,
|
|
69
|
+
successfulResponses: 0,
|
|
70
|
+
totalRequests: 0
|
|
71
|
+
};
|
|
72
|
+
} else {
|
|
73
|
+
return {
|
|
74
|
+
sumOfTimeForSuccess: 0,
|
|
75
|
+
sumOfTimeForFailure: timeTaken,
|
|
76
|
+
successfulResponses: 0,
|
|
77
|
+
totalRequests: 0
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types';
|
|
18
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
|
|
20
|
-
@injectable()
|
|
21
|
-
export class PluginMetricTimeCount implements MetricOutput {
|
|
22
|
-
|
|
23
|
-
public header = '# HELP language_server_time_count Number of language server requests\n# TYPE language_server_time_count gauge\n';
|
|
24
|
-
|
|
25
|
-
createMetricOutput(id: string, method: string, requestAnalytics: AnalyticsFromRequests): string {
|
|
26
|
-
if (requestAnalytics.successfulResponses < 0) {
|
|
27
|
-
requestAnalytics.successfulResponses = 0;
|
|
28
|
-
}
|
|
29
|
-
const successMetric = `language_server_time_count{id="${id}" method="${method}" result="success"} ${requestAnalytics.successfulResponses}\n`;
|
|
30
|
-
|
|
31
|
-
const failedRequests = requestAnalytics.totalRequests - requestAnalytics.successfulResponses;
|
|
32
|
-
const failureMetric = `language_server_time_count{id="${id}" method="${method}" result="fail"} ${failedRequests}\n`;
|
|
33
|
-
return successMetric + failureMetric;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class PluginMetricTimeCount implements MetricOutput {
|
|
22
|
+
|
|
23
|
+
public header = '# HELP language_server_time_count Number of language server requests\n# TYPE language_server_time_count gauge\n';
|
|
24
|
+
|
|
25
|
+
createMetricOutput(id: string, method: string, requestAnalytics: AnalyticsFromRequests): string {
|
|
26
|
+
if (requestAnalytics.successfulResponses < 0) {
|
|
27
|
+
requestAnalytics.successfulResponses = 0;
|
|
28
|
+
}
|
|
29
|
+
const successMetric = `language_server_time_count{id="${id}" method="${method}" result="success"} ${requestAnalytics.successfulResponses}\n`;
|
|
30
|
+
|
|
31
|
+
const failedRequests = requestAnalytics.totalRequests - requestAnalytics.successfulResponses;
|
|
32
|
+
const failureMetric = `language_server_time_count{id="${id}" method="${method}" result="fail"} ${failedRequests}\n`;
|
|
33
|
+
return successMetric + failureMetric;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types';
|
|
18
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
|
|
20
|
-
@injectable()
|
|
21
|
-
export class PluginMetricTimeSum implements MetricOutput {
|
|
22
|
-
|
|
23
|
-
public header = '# HELP language_server_time_sum Sum of time in milliseconds that language server requests take\n# TYPE language_server_time_sum gauge\n';
|
|
24
|
-
|
|
25
|
-
createMetricOutput(id: string, method: string, requestAnalytics: AnalyticsFromRequests): string {
|
|
26
|
-
const successTime = requestAnalytics.sumOfTimeForSuccess;
|
|
27
|
-
const success = `language_server_time_sum{id="${id}" method="${method}" result="success"} ${successTime}\n`;
|
|
28
|
-
|
|
29
|
-
const failureTime = requestAnalytics.sumOfTimeForFailure;
|
|
30
|
-
const failure = `language_server_time_sum{id="${id}" method="${method}" result="failure"} ${failureTime}\n`;
|
|
31
|
-
|
|
32
|
-
return success + failure;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { MetricOutput, AnalyticsFromRequests } from '../../common/plugin-metrics-types';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class PluginMetricTimeSum implements MetricOutput {
|
|
22
|
+
|
|
23
|
+
public header = '# HELP language_server_time_sum Sum of time in milliseconds that language server requests take\n# TYPE language_server_time_sum gauge\n';
|
|
24
|
+
|
|
25
|
+
createMetricOutput(id: string, method: string, requestAnalytics: AnalyticsFromRequests): string {
|
|
26
|
+
const successTime = requestAnalytics.sumOfTimeForSuccess;
|
|
27
|
+
const success = `language_server_time_sum{id="${id}" method="${method}" result="success"} ${successTime}\n`;
|
|
28
|
+
|
|
29
|
+
const failureTime = requestAnalytics.sumOfTimeForFailure;
|
|
30
|
+
const failure = `language_server_time_sum{id="${id}" method="${method}" result="failure"} ${failureTime}\n`;
|
|
31
|
+
|
|
32
|
+
return success + failure;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|