diff --git a/components/dashboard/src/service/metrics.ts b/components/dashboard/src/service/metrics.ts index 2090603df441d7..1c1d16e4fb5e35 100644 --- a/components/dashboard/src/service/metrics.ts +++ b/components/dashboard/src/service/metrics.ts @@ -4,7 +4,6 @@ * See License.AGPL.txt in the project root for license information. */ -import { GitpodHostUrl } from "@gitpod/gitpod-protocol/lib/util/gitpod-host-url"; import { MetricsReporter } from "@gitpod/public-api/lib/metrics"; import { getExperimentsClient } from "../experiments/client"; import { v4 } from "uuid"; @@ -13,7 +12,7 @@ const commit = require("./config.json").commit; const originalConsoleError = console.error; const metricsReporter = new MetricsReporter({ - gitpodUrl: new GitpodHostUrl(window.location.href).withoutWorkspacePrefix().toString(), + gitpodUrl: window.location.href, clientName: "dashboard", clientVersion: commit, log: { diff --git a/components/server/src/api/server.ts b/components/server/src/api/server.ts index 9b38f5bf3a5223..89930599862012 100644 --- a/components/server/src/api/server.ts +++ b/components/server/src/api/server.ts @@ -104,10 +104,11 @@ export class API { return { get(target, prop) { return (...args: any[]) => { + const startedAt = performance.now(); const method = type.methods[prop as any]; if (!method) { // Increment metrics for unknown method attempts - console.warn("public api: unknown method", grpc_service, prop); + log.warn("public api: unknown method", grpc_service, prop); const code = Code.Unimplemented; grpcServerStarted.labels(grpc_service, "unknown", "unknown").inc(); grpcServerHandled.labels(grpc_service, "unknown", "unknown", Code[code]).inc(); @@ -134,11 +135,24 @@ export class API { const grpc_code = err ? Code[err.code] : "OK"; grpcServerHandled.labels(grpc_service, grpc_method, grpc_type, grpc_code).inc(); stopTimer({ grpc_code }); + let callDuration; + if (callStartedAt) { + callDuration = performance.now() - callStartedAt; + } + withRequestContext(log.debug, log, [ + "public api: done", + { + grpc_code, + duration: performance.now() - startedAt, + verifyDuration, + callDuration, + }, + ]); }; const handleError = (reason: unknown) => { let err = ConnectError.from(reason, Code.Internal); if (reason != err && err.code === Code.Internal) { - console.error("public api: unexpected internal error", reason); + withRequestContext(log.error, log, [`public api: unexpected internal error`, reason]); err = ConnectError.from( `Oops! Something went wrong. Please quote the request ID ${requestId} when reaching out to Gitpod Support.`, Code.Internal, @@ -149,6 +163,7 @@ export class API { }; let verifyDuration: number | undefined; + let callStartedAt: number | undefined; const context = args[1] as HandlerContext; function withRequestContext( target: Function, @@ -162,7 +177,6 @@ export class API { requestId, grpc_service, grpc_method, - verifyDuration, }, () => Reflect.apply(target, thisArgument, argumentsList), ); @@ -174,6 +188,7 @@ export class API { verifyDuration = performance.now() - verifyStartedAt; context.user = user; + callStartedAt = performance.now(); if (grpc_type === "unary" || grpc_type === "client_stream") { return withRequestContext(target[prop as any], target, args); }