Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(logs): correct log details timestamp; enable new drawer view (#12624)

Aditya Singh52ec7bf128ba
diff --git a/frontend/src/components/LogDetail/LogDetailsHeader/LogDetailsHeader.tsx b/frontend/src/components/LogDetail/LogDetailsHeader/LogDetailsHeader.tsx
index 2883c0e9a9..de7697fd72 100644
--- a/frontend/src/components/LogDetail/LogDetailsHeader/LogDetailsHeader.tsx
+++ b/frontend/src/components/LogDetail/LogDetailsHeader/LogDetailsHeader.tsx
@@ -16,6 +16,7 @@ import {
Link,
} from '@signozhq/icons';
import { useTimezone } from 'providers/Timezone';
+import { normalizeTimeToMs } from 'utils/timeUtils';
import { ILog } from 'types/api/logs/log';
import { MouseEvent, MouseEventHandler } from 'react';
import { useCopyToClipboard } from 'react-use';
@@ -67,6 +68,11 @@ function LogDetailsHeader({
},
];
+ const rawTimestamp = log.date ?? log.timestamp;
+ const displayTimestamp = Number.isNaN(Number(rawTimestamp))
+ ? rawTimestamp
+ : normalizeTimeToMs(rawTimestamp);
+
return (
<div className={styles.header} data-log-detail-ignore="true">
<div className={styles.leftSection}>
@@ -76,7 +82,7 @@ function LogDetailsHeader({
data-testid="log-details-header-timestamp"
>
{formatTimezoneAdjustedTimestamp(
- log.date ?? log.timestamp,
+ displayTimestamp,
DATE_TIME_FORMATS.DASH_DATETIME,
)}
</Typography.Text>
diff --git a/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx b/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx
index 20a44c648b..01d81d050d 100644
--- a/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx
+++ b/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx
@@ -91,6 +91,24 @@ describe('LogDetail drawer — header (isLogDetailsV2)', () => {
);
});
+ it('normalizes a nanosecond-epoch timestamp in the header', () => {
+ localStorage.setItem(LOCALSTORAGE.PREFERRED_TIMEZONE, 'UTC');
+
+ // Same instant as mockLog but as epoch nanoseconds (e.g. dashboard list panel).
+ // Must scale to ms, not render a wildly wrong date.
+ renderDrawer({
+ log: {
+ ...mockLog,
+ date: '1705311930000000000',
+ timestamp: 1705311930000000000,
+ },
+ });
+
+ expect(screen.getByTestId('log-details-header-timestamp')).toHaveTextContent(
+ 'Jan 15, 2024 ⎯ 09:45:30',
+ );
+ });
+
it('copies the log link from the ⋯ menu', async () => {
const user = userEvent.setup({ pointerEventsCheck: 0 });
diff --git a/frontend/src/components/LogDetail/useIsLogDetailsV2.ts b/frontend/src/components/LogDetail/useIsLogDetailsV2.ts
index 24f18f57e6..36282647bc 100644
--- a/frontend/src/components/LogDetail/useIsLogDetailsV2.ts
+++ b/frontend/src/components/LogDetail/useIsLogDetailsV2.ts
@@ -5,6 +5,7 @@ export function useIsLogDetailsV2(): boolean {
const { pathname } = useLocation();
return (
pathname === ROUTES.LOGS_EXPLORER ||
- pathname.startsWith(ROUTES.INFRASTRUCTURE_MONITORING_BASE)
+ pathname.startsWith(ROUTES.INFRASTRUCTURE_MONITORING_BASE) ||
+ pathname.startsWith(`${ROUTES.ALL_DASHBOARD}/`)
);
}