diff --git a/components/ws-manager-bridge/ee/src/bridge.ts b/components/ws-manager-bridge/ee/src/bridge.ts index 73dfcfcd232c09..d67b48e4759517 100644 --- a/components/ws-manager-bridge/ee/src/bridge.ts +++ b/components/ws-manager-bridge/ee/src/bridge.ts @@ -56,6 +56,12 @@ export class WorkspaceManagerBridgeEE extends WorkspaceManagerBridge { return } span.setTag("updatePrebuiltWorkspace.prebuildId", prebuild.id); + span.setTag("updatePrebuiltWorkspace.workspaceInstance.statusVersion", status.statusVersion); + + if (prebuild.statusVersion <= status.statusVersion) { + this.prometheusExporter.recordStalePrebuildEvent() + } + prebuild.statusVersion = status.statusVersion if (prebuild.state === 'queued') { // We've received an update from ws-man for this workspace, hence it must be running. diff --git a/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts b/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts index 6be619e515ef6f..54ad63fa90f0d8 100644 --- a/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts +++ b/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts @@ -16,6 +16,7 @@ export class PrometheusMetricsExporter { protected readonly clusterScore: prom.Gauge; protected readonly clusterCordoned: prom.Gauge; protected readonly statusUpdatesTotal: prom.Counter; + protected readonly stalePrebuildEventsTotal: prom.Counter; protected activeClusterNames = new Set(); @@ -47,6 +48,10 @@ export class PrometheusMetricsExporter { help: 'Total workspace status updates received', labelNames: ["workspace_cluster", "known_instance"] }); + this.stalePrebuildEventsTotal = new prom.Counter({ + name: "gitpod_ws_manager_bridge_stale_prebuild_events_total", + help: "Total count of stale prebuild events received by workspace manager bridge" + }) } observeWorkspaceStartupTime(instance: WorkspaceInstance): void { @@ -87,5 +92,9 @@ export class PrometheusMetricsExporter { statusUpdateReceived(installation: string, knownInstance: boolean): void { this.statusUpdatesTotal.labels(installation, knownInstance ? "true" : "false").inc(); } + + recordStalePrebuildEvent(): void { + this.stalePrebuildEventsTotal.inc(); + } }