feat(electrobun): multi-machine relay + OTEL telemetry
Multi-machine relay: - relay-client.ts: WebSocket client for agor-relay with token auth, exponential backoff (1s-30s), TCP probe, heartbeat (15s ping) - machines-store.svelte.ts: remote machine state tracking - RemoteMachinesSettings.svelte: machine list, add/connect/disconnect UI - 7 RPC types (remote.connect/disconnect/list/send/status + events) Telemetry: - telemetry.ts: OTEL spans + OTLP/HTTP export to Tempo, controlled by AGOR_OTLP_ENDPOINT env var - telemetry-bridge.ts: tel.info/warn/error frontend convenience API - telemetry.log RPC for frontend→Bun tracing
This commit is contained in:
parent
ec30c69c3e
commit
88206205fe
11 changed files with 1458 additions and 15 deletions
45
ui-electrobun/src/mainview/telemetry-bridge.ts
Normal file
45
ui-electrobun/src/mainview/telemetry-bridge.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* Frontend telemetry bridge.
|
||||
*
|
||||
* Provides tel.info(), tel.warn(), tel.error() convenience methods that
|
||||
* forward structured log events to the Bun process via RPC for tracing.
|
||||
* No browser OTEL SDK needed (WebKitGTK incompatible).
|
||||
*/
|
||||
|
||||
import { appRpc } from "./rpc.ts";
|
||||
|
||||
type LogLevel = "info" | "warn" | "error";
|
||||
type Attributes = Record<string, string | number | boolean>;
|
||||
|
||||
function sendLog(level: LogLevel, message: string, attributes?: Attributes): void {
|
||||
try {
|
||||
appRpc?.request["telemetry.log"]({
|
||||
level,
|
||||
message,
|
||||
attributes: attributes ?? {},
|
||||
}).catch((err: unknown) => {
|
||||
// Best-effort — never block the caller
|
||||
console.warn("[tel-bridge] RPC failed:", err);
|
||||
});
|
||||
} catch {
|
||||
// RPC not yet initialized — swallow silently
|
||||
}
|
||||
}
|
||||
|
||||
/** Frontend telemetry API. All calls are fire-and-forget. */
|
||||
export const tel = {
|
||||
/** Log an informational event. */
|
||||
info(message: string, attributes?: Attributes): void {
|
||||
sendLog("info", message, attributes);
|
||||
},
|
||||
|
||||
/** Log a warning event. */
|
||||
warn(message: string, attributes?: Attributes): void {
|
||||
sendLog("warn", message, attributes);
|
||||
},
|
||||
|
||||
/** Log an error event. */
|
||||
error(message: string, attributes?: Attributes): void {
|
||||
sendLog("error", message, attributes);
|
||||
},
|
||||
} as const;
|
||||
Loading…
Add table
Add a link
Reference in a new issue