-
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.
node grpc spike dashboard to server (#18691)
* [public-api] add dummy service for testing * [public-api] proxy dummy to server * [public-api] hello service server impl * [server] fix API contribution bindings * [dashboard] emulate unary call * only if actually called * [dummy] auth * fix tests * [server] add interceptor to public api * add server side observability * fix port name * change to unimplemented for unknown methods * [public-api] client metrics * fix metrics imports * align server metrics * actually fix metrics * add feature flags * fix server side streams * [dashboard] hook error reporting * rebase and fix imports * feature flagged metrics from dashboard * revert GRPC_TYPE * address feedback
- Loading branch information
Showing
33 changed files
with
1,891 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Copyright (c) 2023 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 { GitpodHostUrl } from "@gitpod/gitpod-protocol/lib/util/gitpod-host-url"; | ||
import { MetricsReporter } from "@gitpod/public-api/lib/metrics"; | ||
import { getExperimentsClient } from "../experiments/client"; | ||
|
||
const originalConsoleError = console.error; | ||
|
||
const options = { | ||
gitpodUrl: new GitpodHostUrl(window.location.href).withoutWorkspacePrefix().toString(), | ||
clientName: "dashboard", | ||
clientVersion: "", | ||
logError: originalConsoleError.bind(console), | ||
isEnabled: () => getExperimentsClient().getValueAsync("dashboard_metrics_enabled", false, {}), | ||
}; | ||
fetch("/api/version").then(async (res) => { | ||
const version = await res.text(); | ||
options.clientVersion = version; | ||
}); | ||
const metricsReporter = new MetricsReporter(options); | ||
metricsReporter.startReporting(); | ||
|
||
window.addEventListener("unhandledrejection", (event) => { | ||
reportError("Unhandled promise rejection", event.reason); | ||
}); | ||
window.addEventListener("error", (event) => { | ||
let message = "Unhandled error"; | ||
if (event.message) { | ||
message += ": " + event.message; | ||
} | ||
reportError(message, event.error); | ||
}); | ||
|
||
console.error = function (...args) { | ||
originalConsoleError.apply(console, args); | ||
reportError(...args); | ||
}; | ||
|
||
function reportError(...args: any[]) { | ||
let err = undefined; | ||
let details = undefined; | ||
if (args[0] instanceof Error) { | ||
err = args[0]; | ||
details = args[1]; | ||
} else if (typeof args[0] === "string") { | ||
err = new Error(args[0]); | ||
if (args[1] instanceof Error) { | ||
err.message += ": " + args[1].message; | ||
err.name = args[1].name; | ||
err.stack = args[1].stack; | ||
details = args[2]; | ||
} else if (typeof args[1] === "string") { | ||
err.message += ": " + args[1]; | ||
details = args[2]; | ||
} else { | ||
details = args[1]; | ||
} | ||
} | ||
|
||
let data = undefined; | ||
if (details && typeof details === "object") { | ||
data = Object.fromEntries( | ||
Object.entries(details) | ||
.filter(([key, value]) => { | ||
return ( | ||
typeof value === "string" || | ||
typeof value === "number" || | ||
typeof value === "boolean" || | ||
value === null || | ||
typeof value === "undefined" | ||
); | ||
}) | ||
.map(([key, value]) => [key, String(value)]), | ||
); | ||
} | ||
|
||
if (err) { | ||
metricsReporter.reportError(err, data); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
syntax = "proto3"; | ||
|
||
package gitpod.experimental.v1; | ||
|
||
option go_package = "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1"; | ||
|
||
// HelloService is a dummy service that says hello. It is used for reliability | ||
// testing. | ||
service HelloService { | ||
// Unary RPCs where the client sends a single request to the server and gets a | ||
// single response back, just like a normal function call. | ||
rpc SayHello(SayHelloRequest) returns (SayHelloResponse); | ||
// Server streaming RPCs where the client sends a request to the server and | ||
// gets a stream to read a sequence of messages back. | ||
rpc LotsOfReplies(LotsOfRepliesRequest) | ||
returns (stream LotsOfRepliesResponse); | ||
} | ||
|
||
message SayHelloRequest {} | ||
message SayHelloResponse { string reply = 1; } | ||
|
||
message LotsOfRepliesRequest { | ||
int32 previous_count = 1; | ||
} | ||
message LotsOfRepliesResponse { | ||
string reply = 1; | ||
int32 count = 2; | ||
} |
Oops, something went wrong.