Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit a3c94bb

Browse files
committed
add metrics for events processed and tweak k8s service roles
1 parent 401b199 commit a3c94bb

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

deployments/index.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,11 @@ const role = new k8s.rbac.v1.Role(
175175
resources: ["jobs"],
176176
verbs: ["create", "update", "get", "list", "watch", "delete"],
177177
},
178-
// Uncomment this if you need to manage Pods/Services/Deployments
179-
// {
180-
// apiGroups: [""], // "" indicates the core API group
181-
// resources: ["services"],
182-
// verbs: ["create", "update", "get", "list", "watch", "delete"],
183-
// },
178+
{
179+
apiGroups: [""], // "" indicates the core API group
180+
resources: ["services"],
181+
verbs: ["create", "update", "get", "list", "watch", "delete"],
182+
},
184183
],
185184
},
186185
{ provider },

substream-listener/src/index.mts

+9
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ emitter.on("cursor", async (cursor) => {
129129
// Stream Blocks
130130
emitter.on("anyMessage", async (message) => {
131131
const transfers = (message.transfers || []) as any[];
132+
const messageCount = transfers.length;
132133

133134
const events = transfers.map((transfer) => {
134135
return svix.message.create(APP_ID, {
@@ -142,7 +143,15 @@ emitter.on("anyMessage", async (message) => {
142143

143144
try {
144145
await Promise.all(events);
146+
prometheus.substream_listener_processed_messages.inc(
147+
{ app_id: APP_ID, status: "success" },
148+
messageCount,
149+
);
145150
} catch (e) {
151+
prometheus.substream_listener_processed_messages.inc(
152+
{ app_id: APP_ID, status: "error" },
153+
messageCount,
154+
);
146155
logger.error({ error: e }, "Error sending events to Svix");
147156
}
148157
});

substream-listener/src/prometheus.mts

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ const sessionGauge = new promClient.Gauge({
9999
],
100100
});
101101

102+
export const substream_listener_processed_messages = new promClient.Gauge({
103+
name: "substream_listener_processed_messages",
104+
help: "The number of messages processed by the emitter",
105+
labelNames: ["app_id", "status"],
106+
});
107+
102108
// ------------------------------------------------------------------
103109

104110
export function onPrometheusMetrics(

0 commit comments

Comments
 (0)