Skip to content

Commit f3534c4

Browse files
committed
Review fixes
1 parent 51d5852 commit f3534c4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function decodeCursor(cursor: string): LogCursor | null {
116116
function levelToKindsAndStatuses(level: LogLevel): { kinds?: string[]; statuses?: string[] } {
117117
switch (level) {
118118
case "DEBUG":
119-
return { kinds: ["DEBUG_EVENT", "LOG_DEBUG"] };
119+
return { kinds: ["LOG_DEBUG"] };
120120
case "INFO":
121121
return { kinds: ["LOG_INFO", "LOG_LOG"] };
122122
case "WARN":
@@ -352,18 +352,18 @@ export class LogsListPresenter extends BasePresenter {
352352
// Must mirror the ORDER BY columns: (organization_id DESC, environment_id DESC, triggered_timestamp DESC, span_id DESC)
353353
const decodedCursor = cursor ? decodeCursor(cursor) : null;
354354
if (decodedCursor) {
355+
// organization_id and environment_id are already pinned by equality filters above,
356+
// so cursor only needs to compare triggered_timestamp and span_id
355357
queryBuilder.where(
356-
`((organization_id = {cursorOrgId: String} AND environment_id = {cursorEnvId: String} AND triggered_timestamp = {cursorTriggeredTimestamp: String} AND span_id < {cursorSpanId: String}) OR (organization_id = {cursorOrgId: String} AND environment_id = {cursorEnvId: String} AND triggered_timestamp < {cursorTriggeredTimestamp: String}) OR (organization_id = {cursorOrgId: String} AND environment_id < {cursorEnvId: String}) OR (organization_id < {cursorOrgId: String}))`,
358+
`(triggered_timestamp < {cursorTriggeredTimestamp: String} OR (triggered_timestamp = {cursorTriggeredTimestamp: String} AND span_id < {cursorSpanId: String}))`,
357359
{
358-
cursorOrgId: decodedCursor.organizationId,
359-
cursorEnvId: decodedCursor.environmentId,
360360
cursorTriggeredTimestamp: decodedCursor.triggeredTimestamp,
361361
cursorSpanId: decodedCursor.spanId,
362362
}
363363
);
364364
}
365365

366-
queryBuilder.orderBy("organization_id DESC, environment_id DESC, triggered_timestamp DESC, span_id DESC");
366+
queryBuilder.orderBy("triggered_timestamp DESC, span_id DESC");
367367
// Limit + 1 to check if there are more results
368368
queryBuilder.limit(pageSize + 1);
369369

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.logs.$logId.spans.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { EnvironmentParamSchema } from "~/utils/pathBuilder";
55
import { findProjectBySlug } from "~/models/project.server";
66
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
77
import { clickhouseClient } from "~/services/clickhouseInstance.server";
8+
import { convertClickhouseDateTime64ToJsDate } from "~/v3/eventRepository/clickhouseEventRepository.server";
89

910
// Convert ClickHouse kind to display level
1011
function kindToLevel(
1112
kind: string
1213
): "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG" {
1314
switch (kind) {
14-
case "DEBUG_EVENT":
1515
case "LOG_DEBUG":
1616
return "DEBUG";
1717
case "LOG_INFO":
@@ -23,7 +23,6 @@ function kindToLevel(
2323
case "LOG_LOG":
2424
return "LOG";
2525
case "SPAN":
26-
case "ANCESTOR_OVERRIDE":
2726
case "SPAN_EVENT":
2827
default:
2928
return "TRACE";
@@ -91,7 +90,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
9190
kind: row.kind,
9291
level: kindToLevel(row.kind),
9392
status: row.status,
94-
startTime: new Date(Number(row.start_time) / 1_000_000).toISOString(),
93+
startTime: convertClickhouseDateTime64ToJsDate(row.start_time).toISOString(),
9594
duration: Number(row.duration),
9695
isCurrent: row.span_id === currentSpanId,
9796
}));

0 commit comments

Comments
 (0)