Skip to content

Commit 96163c6

Browse files
committed
rolled back to trace_id ordering
1 parent 58022cc commit 96163c6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

apps/webapp/app/presenters/v3/LogsListPresenter.server.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ type LogCursor = {
8484
organizationId: string;
8585
environmentId: string;
8686
triggeredTimestamp: string; // DateTime64(9) string
87-
spanId: string;
87+
traceId: string;
8888
};
8989

9090
const LogCursorSchema = z.object({
9191
organizationId: z.string(),
9292
environmentId: z.string(),
9393
triggeredTimestamp: z.string(),
94-
spanId: z.string(),
94+
traceId: z.string(),
9595
});
9696

9797
function encodeCursor(cursor: LogCursor): string {
@@ -321,19 +321,19 @@ export class LogsListPresenter extends BasePresenter {
321321
}
322322

323323
// Cursor pagination using explicit lexicographic comparison
324-
// Must mirror the ORDER BY columns: (organization_id DESC, environment_id DESC, triggered_timestamp DESC, span_id DESC)
324+
// Must mirror the ORDER BY columns: (organization_id, environment_id, triggered_timestamp, trace_id)
325325
const decodedCursor = cursor ? decodeCursor(cursor) : null;
326326
if (decodedCursor) {
327327
queryBuilder.where(
328-
`(triggered_timestamp < {cursorTriggeredTimestamp: String} OR (triggered_timestamp = {cursorTriggeredTimestamp: String} AND span_id < {cursorSpanId: String}))`,
328+
`(triggered_timestamp < {cursorTriggeredTimestamp: String} OR (triggered_timestamp = {cursorTriggeredTimestamp: String} AND trace_id < {cursorTraceId: String}))`,
329329
{
330330
cursorTriggeredTimestamp: decodedCursor.triggeredTimestamp,
331-
cursorSpanId: decodedCursor.spanId,
331+
cursorTraceId: decodedCursor.traceId,
332332
}
333333
);
334334
}
335335

336-
queryBuilder.orderBy("triggered_timestamp DESC, span_id DESC");
336+
queryBuilder.orderBy("triggered_timestamp DESC, trace_id DESC");
337337
// Limit + 1 to check if there are more results
338338
queryBuilder.limit(pageSize + 1);
339339

@@ -355,7 +355,7 @@ export class LogsListPresenter extends BasePresenter {
355355
organizationId,
356356
environmentId,
357357
triggeredTimestamp: lastLog.triggered_timestamp,
358-
spanId: lastLog.span_id,
358+
traceId: lastLog.trace_id,
359359
});
360360
}
361361

internal-packages/clickhouse/schema/016_add_task_events_search_v1.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS trigger_dev.task_events_search_v1
2424
)
2525
ENGINE = MergeTree
2626
PARTITION BY toDate(triggered_timestamp)
27-
ORDER BY (organization_id, environment_id, triggered_timestamp, span_id)
27+
ORDER BY (organization_id, environment_id, triggered_timestamp, trace_id)
2828
--Right now we have maximum retention of up to 30 days based on plan.
2929
--We put a logical limit for now, the 90 DAY TTL is just a backup
3030
--This might need to be updated for longer retention periods
@@ -48,7 +48,7 @@ SELECT
4848
status,
4949
duration,
5050
parent_span_id,
51-
toJSONString(attributes) AS attributes_text,
51+
attributes_text,
5252
fromUnixTimestamp64Nano(toUnixTimestamp64Nano(start_time) + toInt64(duration)) AS triggered_timestamp
5353
FROM trigger_dev.task_events_v2
5454
WHERE

0 commit comments

Comments
 (0)