fix(llma): trace not found due to bad starting timestamp (#39283)

This commit is contained in:
Radu Raicea
2025-10-07 17:04:44 -04:00
committed by GitHub
parent 2d9c048ce6
commit 819de7f570
3 changed files with 9 additions and 4 deletions

View File

@@ -56,6 +56,7 @@ import {
formatLLMUsage,
getEventType,
getSessionID,
getTraceTimestamp,
hasSessionID,
isLLMTraceEvent,
normalizeMessages,
@@ -367,7 +368,7 @@ const TreeNode = React.memo(function TraceNode({
<Link
to={urls.llmAnalyticsTrace(topLevelTrace.id, {
event: item.id,
timestamp: removeMilliseconds(topLevelTrace.createdAt),
timestamp: getTraceTimestamp(topLevelTrace.createdAt),
...(searchQuery?.trim() && { search: searchQuery }),
})}
className={classNames(

View File

@@ -14,7 +14,7 @@ import { isTracesQuery } from '~/queries/utils'
import { LLMMessageDisplay } from './ConversationDisplay/ConversationMessagesDisplay'
import { llmAnalyticsLogic } from './llmAnalyticsLogic'
import { formatLLMCost, formatLLMLatency, formatLLMUsage, normalizeMessages, removeMilliseconds } from './utils'
import { formatLLMCost, formatLLMLatency, formatLLMUsage, getTraceTimestamp, normalizeMessages } from './utils'
export function LLMAnalyticsTraces(): JSX.Element {
const { setDates, setShouldFilterTestAccounts, setPropertyFilters, setTracesQuery } = useActions(llmAnalyticsLogic)
@@ -88,7 +88,7 @@ const IDColumn: QueryContextColumnComponent = ({ record }) => {
<Tooltip title={row.id}>
<Link
className="ph-no-capture"
to={urls.llmAnalyticsTrace(row.id, { timestamp: removeMilliseconds(row.createdAt) })}
to={urls.llmAnalyticsTrace(row.id, { timestamp: getTraceTimestamp(row.createdAt) })}
>
{row.id.slice(0, 4)}...{row.id.slice(-4)}
</Link>
@@ -103,7 +103,7 @@ const TraceNameColumn: QueryContextColumnComponent = ({ record }) => {
<strong>
<Link
className="ph-no-capture"
to={urls.llmAnalyticsTrace(row.id, { timestamp: removeMilliseconds(row.createdAt) })}
to={urls.llmAnalyticsTrace(row.id, { timestamp: getTraceTimestamp(row.createdAt) })}
>
{row.traceName || ''}
</Link>

View File

@@ -500,6 +500,10 @@ export function removeMilliseconds(timestamp: string): string {
return dayjs(timestamp).utc().format('YYYY-MM-DDTHH:mm:ss[Z]')
}
export function getTraceTimestamp(timestamp: string): string {
return dayjs(timestamp).utc().subtract(5, 'minutes').format('YYYY-MM-DDTHH:mm:ss[Z]')
}
export function formatLLMEventTitle(event: LLMTrace | LLMTraceEvent): string {
if (isLLMTraceEvent(event)) {
if (event.event === '$ai_generation') {