Skip to content

Commit

Permalink
[ws-manager-bridge] Publish metrics with stale prebuild events
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ committed Apr 5, 2022
1 parent 4e02038 commit 894c265
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/ws-manager-bridge/ee/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class PrometheusMetricsExporter {
protected readonly clusterScore: prom.Gauge<string>;
protected readonly clusterCordoned: prom.Gauge<string>;
protected readonly statusUpdatesTotal: prom.Counter<string>;
protected readonly stalePrebuildEventsTotal: prom.Counter<string>;

protected activeClusterNames = new Set<string>();

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 894c265

Please sign in to comment.