Skip to content

Commit 2cf1434

Browse files
committed
make it clear we are tracking events, not transactions
1 parent 3a7ed77 commit 2cf1434

File tree

3 files changed

+14
-91
lines changed

3 files changed

+14
-91
lines changed

apps/webapp/app/services/runsReplicationService.server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class RunsReplicationService {
121121
private _taskRunsInsertedCounter: Counter;
122122
private _payloadsInsertedCounter: Counter;
123123
private _insertRetriesCounter: Counter;
124-
private _transactionsProcessedCounter: Counter;
124+
private _eventsProcessedCounter: Counter;
125125
private _flushDurationHistogram: Histogram;
126126

127127
public readonly events: EventEmitter<RunsReplicationServiceEvents>;
@@ -171,10 +171,10 @@ export class RunsReplicationService {
171171
description: "Insert retry attempts",
172172
});
173173

174-
this._transactionsProcessedCounter = this._meter.createCounter(
175-
"runs_replication.transactions_processed",
174+
this._eventsProcessedCounter = this._meter.createCounter(
175+
"runs_replication.events_processed",
176176
{
177-
description: "Transactions received from replication",
177+
description: "Replication events processed (inserts, updates, deletes)",
178178
}
179179
);
180180

@@ -503,7 +503,7 @@ export class RunsReplicationService {
503503

504504
// Count events by type
505505
for (const event of transaction.events) {
506-
this._transactionsProcessedCounter.add(1, { event_type: event.tag });
506+
this._eventsProcessedCounter.add(1, { event_type: event.tag });
507507
}
508508

509509
this.logger.info("handle_transaction", {

apps/webapp/test/runsReplicationService.part1.test.ts

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,36 +1258,6 @@ describe("RunsReplicationService (part 1/2)", () => {
12581258
return metric.dataPoints.reduce((sum: number, dp: any) => sum + (dp.value || 0), 0);
12591259
}
12601260

1261-
function getCounterValueByAttributes(
1262-
metric: any,
1263-
attributes: Record<string, unknown>
1264-
): number {
1265-
if (!metric?.dataPoints) return 0;
1266-
for (const dp of metric.dataPoints) {
1267-
const dpAttrs = dp.attributes || {};
1268-
const matches = Object.entries(attributes).every(
1269-
([key, value]) => String(dpAttrs[key]) === String(value)
1270-
);
1271-
if (matches) {
1272-
return dp.value || 0;
1273-
}
1274-
}
1275-
return 0;
1276-
}
1277-
1278-
function getHistogramCount(metric: any): number {
1279-
if (!metric?.dataPoints) return 0;
1280-
return metric.dataPoints.reduce((sum: number, dp: any) => {
1281-
if (typeof dp.count === "number") return sum + dp.count;
1282-
if (typeof dp.value?.count === "number") return sum + dp.value.count;
1283-
if (typeof dp.zeroCount === "number") return sum + dp.zeroCount;
1284-
if (dp.buckets?.counts) {
1285-
return sum + dp.buckets.counts.reduce((s: number, c: number) => s + c, 0);
1286-
}
1287-
return sum;
1288-
}, 0);
1289-
}
1290-
12911261
function histogramHasData(metric: any): boolean {
12921262
if (!metric?.dataPoints || metric.dataPoints.length === 0) return false;
12931263
return metric.dataPoints.some((dp: any) => {
@@ -1327,12 +1297,12 @@ describe("RunsReplicationService (part 1/2)", () => {
13271297
const totalPayloadsInserted = sumCounterValues(payloadsInserted);
13281298
expect(totalPayloadsInserted).toBeGreaterThanOrEqual(1);
13291299

1330-
const transactionsProcessed = getMetricData("runs_replication.transactions_processed");
1331-
expect(transactionsProcessed).not.toBeNull();
1332-
const totalTransactionsProcessed = sumCounterValues(transactionsProcessed);
1333-
expect(totalTransactionsProcessed).toBeGreaterThanOrEqual(1);
1300+
const eventsProcessed = getMetricData("runs_replication.events_processed");
1301+
expect(eventsProcessed).not.toBeNull();
1302+
const totalEventsProcessed = sumCounterValues(eventsProcessed);
1303+
expect(totalEventsProcessed).toBeGreaterThanOrEqual(1);
13341304

1335-
const eventTypes = getCounterAttributeValues(transactionsProcessed, "event_type");
1305+
const eventTypes = getCounterAttributeValues(eventsProcessed, "event_type");
13361306
expect(eventTypes.length).toBeGreaterThanOrEqual(1);
13371307
expect(eventTypes).toContain("insert");
13381308

docker/config/grafana/provisioning/dashboards/runs-replication.json

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@
191191
},
192192
"targets": [
193193
{
194-
"expr": "sum(rate(triggerdotdev_runs_replication_transactions_processed_total[5m])) by (event_type)",
194+
"expr": "sum(rate(triggerdotdev_runs_replication_events_processed_total[5m])) by (event_type)",
195195
"legendFormat": "{{event_type}}",
196196
"refId": "A"
197197
}
198198
],
199-
"title": "Transactions Processed by Event Type",
199+
"title": "Events Processed by Type",
200200
"type": "timeseries"
201201
},
202202
{
@@ -412,54 +412,7 @@
412412
},
413413
"overrides": []
414414
},
415-
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 25 },
416-
"id": 12,
417-
"options": {
418-
"legend": { "calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true },
419-
"tooltip": { "mode": "multi", "sort": "desc" }
420-
},
421-
"targets": [
422-
{
423-
"expr": "triggerdotdev_runs_replication_flush_queue_depth",
424-
"legendFormat": "Queue Depth",
425-
"refId": "A"
426-
}
427-
],
428-
"title": "Flush Queue Depth",
429-
"type": "timeseries"
430-
},
431-
{
432-
"datasource": { "type": "prometheus", "uid": "prometheus" },
433-
"fieldConfig": {
434-
"defaults": {
435-
"color": { "mode": "palette-classic" },
436-
"custom": {
437-
"axisBorderShow": false,
438-
"axisCenteredZero": false,
439-
"axisColorMode": "text",
440-
"axisLabel": "",
441-
"axisPlacement": "auto",
442-
"barAlignment": 0,
443-
"drawStyle": "line",
444-
"fillOpacity": 10,
445-
"gradientMode": "none",
446-
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
447-
"lineInterpolation": "linear",
448-
"lineWidth": 1,
449-
"pointSize": 5,
450-
"scaleDistribution": { "type": "linear" },
451-
"showPoints": "never",
452-
"spanNulls": false,
453-
"stacking": { "group": "A", "mode": "none" },
454-
"thresholdsStyle": { "mode": "off" }
455-
},
456-
"mappings": [],
457-
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
458-
"unit": "short"
459-
},
460-
"overrides": []
461-
},
462-
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 25 },
415+
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 25 },
463416
"id": 13,
464417
"options": {
465418
"legend": { "calcs": ["mean", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true },
@@ -503,7 +456,7 @@
503456
},
504457
"overrides": []
505458
},
506-
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 25 },
459+
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 25 },
507460
"id": 14,
508461
"options": {
509462
"colorMode": "value",

0 commit comments

Comments
 (0)