Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions components/server/src/prometheus-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,16 @@ const httpRequestDuration = new prometheusClient.Histogram({
export function observeHttpRequestDuration(method: string, route: string, statusCode: number, durationInSeconds: number) {
httpRequestDuration.observe({ method, route, statusCode }, durationInSeconds);
}

const messagebusTopicReads = new prometheusClient.Counter({
name: 'gitpod_server_topic_reads_total',
help: 'The amount of reads from messagebus topics.',
labelNames: ['topic'],
registers: [prometheusClient.register]
});

export function increaseMessagebusTopicReads(topic: string) {
messagebusTopicReads.inc({
topic,
})
}
4 changes: 4 additions & 0 deletions components/server/src/workspace/messagebus-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Channel, Message } from "amqplib";
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing";
import * as opentracing from "opentracing";
import { CancellationTokenSource } from "vscode-ws-jsonrpc";
import { increaseMessagebusTopicReads } from '../prometheus-metrics';

export class WorkspaceInstanceUpdateListener extends AbstractTopicListener<WorkspaceInstance> {

Expand Down Expand Up @@ -117,20 +118,23 @@ export class MessageBusIntegration extends AbstractMessageBusIntegration {
const listener = new HeadlessWorkspaceLogListener(this.messageBusHelper, callback, workspaceID);
const cancellationTokenSource = new CancellationTokenSource()
this.listen(listener, cancellationTokenSource.token);
increaseMessagebusTopicReads('headless_workspace_log')
return Disposable.create(() => cancellationTokenSource.cancel())
}

listenForPrebuildUpdatableQueue(callback: (ctx: TraceContext, evt: HeadlessLogEvent) => void): Disposable {
const listener = new PrebuildUpdatableQueueListener(callback);
const cancellationTokenSource = new CancellationTokenSource()
this.listen(listener, cancellationTokenSource.token);
increaseMessagebusTopicReads('prebuild_updatable_queue');
return Disposable.create(() => cancellationTokenSource.cancel())
}

listenForWorkspaceInstanceUpdates(userId: string | undefined, callback: (ctx: TraceContext, workspaceInstance: WorkspaceInstance) => void): Disposable {
const listener = new WorkspaceInstanceUpdateListener(this.messageBusHelper, callback, userId);
const cancellationTokenSource = new CancellationTokenSource()
this.listen(listener, cancellationTokenSource.token);
increaseMessagebusTopicReads('workspace_instance_update');
return Disposable.create(() => cancellationTokenSource.cancel())
}

Expand Down