Skip to content

Commit 773444c

Browse files
committed
[dashboard] unify error reporting
move error boundary to general error reporting endpoint as well
1 parent 352484b commit 773444c

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

components/dashboard/src/components/error-boundaries/ReloadPageErrorBoundary.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
*/
66

77
import { FC, useCallback } from "react";
8-
import { ErrorBoundary, FallbackProps, ErrorBoundaryProps } from "react-error-boundary";
8+
import { ErrorBoundary, ErrorBoundaryProps, FallbackProps } from "react-error-boundary";
99
import gitpodIcon from "../../icons/gitpod.svg";
10-
import { getGitpodService } from "../../service/service";
1110
import { Heading1, Subheading } from "../typography/headings";
11+
import { reportError } from "../../service/metrics";
1212

1313
export type CaughtError = Error & { code?: number };
1414

@@ -64,11 +64,4 @@ export const ReloadPageErrorFallback: FC<Pick<FallbackProps, "error">> = ({ erro
6464
);
6565
};
6666

67-
export const handleError: ErrorBoundaryProps["onError"] = async (error, info) => {
68-
const url = window.location.toString();
69-
try {
70-
await getGitpodService().server.reportErrorBoundary(url, error.message || "Unknown Error");
71-
} catch (e) {
72-
console.error(e);
73-
}
74-
};
67+
export const handleError: ErrorBoundaryProps["onError"] = (error, info) => reportError("Error boundary", error, info);

components/dashboard/src/service/metrics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ console.error = function (...args) {
4040
reportError(...args);
4141
};
4242

43-
function reportError(...args: any[]) {
43+
export function reportError(...args: any[]) {
4444
let err = undefined;
4545
let details = undefined;
4646
if (args[0] instanceof Error) {

components/server/src/prometheus-metrics.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export function registerServerMetrics(registry: prometheusClient.Registry) {
2222
registry.registerMetric(imageBuildsStartedTotal);
2323
registry.registerMetric(imageBuildsCompletedTotal);
2424
registry.registerMetric(spicedbClientLatency);
25-
registry.registerMetric(dashboardErrorBoundary);
2625
registry.registerMetric(jwtCookieIssued);
2726
registry.registerMetric(jobStartedTotal);
2827
registry.registerMetric(jobsCompletedTotal);
@@ -264,15 +263,6 @@ export function observeSpicedbClientLatency(operation: string, outcome: Error |
264263
);
265264
}
266265

267-
export const dashboardErrorBoundary = new prometheusClient.Counter({
268-
name: "gitpod_dashboard_error_boundary_total",
269-
help: "Total number of errors caught by an error boundary in the dashboard",
270-
});
271-
272-
export function increaseDashboardErrorBoundaryCounter() {
273-
dashboardErrorBoundary.inc();
274-
}
275-
276266
export const jobStartedTotal = new prometheusClient.Counter({
277267
name: "gitpod_server_jobs_started_total",
278268
help: "Total number of errors caught by an error boundary in the dashboard",

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
144144
import { CostCenterJSON } from "@gitpod/gitpod-protocol/lib/usage";
145145
import { createCookielessId, maskIp } from "../analytics";
146146
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
147-
import { increaseDashboardErrorBoundaryCounter } from "../prometheus-metrics";
148147
import { LinkedInService } from "../linkedin-service";
149148
import { SnapshotService, WaitForSnapshotOptions } from "./snapshot-service";
150149
import { IncrementalPrebuildsService } from "../prebuilds/incremental-prebuilds-service";
@@ -3464,14 +3463,12 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
34643463
//
34653464
//#endregion
34663465

3466+
/**
3467+
* TODO(ak)
3468+
* @deprecated remove it after dashboard is deployed. It was replaced with error reporting in GCP.
3469+
*/
34673470
async reportErrorBoundary(ctx: TraceContextWithSpan, url: string, message: string): Promise<void> {
3468-
// Cap message and url length so the entries aren't of unbounded length
3469-
log.warn("dashboard error boundary", {
3470-
message: (message || "").substring(0, 200),
3471-
url: (url || "").substring(0, 200),
3472-
userId: this.userID,
3473-
});
3474-
increaseDashboardErrorBoundaryCounter();
3471+
// no-op
34753472
}
34763473

34773474
async getIDToken(): Promise<void> {}

0 commit comments

Comments
 (0)