-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[supervisor-frontend] add error counter and client counter
Co-authored-by: Huiwen <mhqnwt@gmail.com>
- Loading branch information
1 parent
5bfb308
commit 28848d7
Showing
8 changed files
with
3,928 additions
and
3,541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
components/supervisor/frontend/src/ide/ide-metrics-service-client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { MetricsServicePromiseClient } from '@gitpod/ide-metrics-api-grpcweb/lib/idemetrics_grpc_web_pb' | ||
import { AddCounterRequest, AddCounterResponse } from '@gitpod/ide-metrics-api-grpcweb/lib/idemetrics_pb' | ||
import { serverUrl } from '../shared/urls'; | ||
|
||
const client = new MetricsServicePromiseClient(serverUrl.asIDEMetrics().toString()) | ||
|
||
export enum MetricsName { | ||
SupervisorFrontendClientTotal = "gitpod_supervisor_frontend_client_total", | ||
SupervisorFrontendErrorTotal = "gitpod_supervisor_frontend_error_total" | ||
} | ||
|
||
export class IDEMetricsServiceClient { | ||
|
||
static async addCounter(metricsName: string, labels?: Map<string, string>, value?: number) : Promise<AddCounterResponse> { | ||
const req = new AddCounterRequest() | ||
req.setName(metricsName) | ||
if (value) { | ||
req.setValue(value) | ||
} | ||
if (labels) { | ||
const m = req.getLabelsMap() | ||
for (const [name, value] of labels) { | ||
m.set(name, value) | ||
} | ||
} | ||
return client.addCounter(req) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.