Skip to content

Conversation

@favbox
Copy link

@favbox favbox commented Feb 10, 2026

Problem

Langfuse UI was displaying incorrect latency values like "17751749h 37m 57s"
instead of the actual duration in milliseconds (e.g., "854ms").

Root Cause

The callback handler was not preserving the original startTime when
updating spans/generations in OnEnd. This caused the startTime to be
reset to zero value ("0001-01-01T00:00:00Z"), which Langfuse backend
uses to calculate latency as endTime - startTime, resulting in a
massive time difference.

Solution

  1. Add Duration field (milliseconds) to SpanEventBody and
    GenerationEventBody in event data model
  2. Store startTime in callback state during OnStart
  3. Preserve original startTime and calculate duration in OnEnd

Changes

  • libs/acl/langfuse/event.go: Add Duration *int64 field (milliseconds)
  • callbacks/langfuse/langfuse.go: Track startTime and compute duration

Testing

Before fix: Latency: 17751749h 37m 57s
After fix: Latency: 854ms


Co-Authored-By: Claude Opus 4.6 [email protected]

## Problem
Langfuse UI was displaying incorrect latency values like "17751749h"
instead of the actual duration in milliseconds (e.g., "854ms").

## Root Cause
The callback handler was not preserving the original `startTime` when
updating spans/generations in `OnEnd`. This caused the `startTime` to be
reset to zero value ("0001-01-01T00:00:00Z"), which Langfuse backend
uses to calculate latency as `endTime - startTime`, resulting in a
massive time difference.

## Solution
1. Add `Duration` field (milliseconds) to `SpanEventBody` and
   `GenerationEventBody` in event data model
2. Store `startTime` in callback state during `OnStart`
3. Preserve original `startTime` and calculate `duration` in `OnEnd`

## Changes
- `libs/acl/langfuse/event.go`: Add `Duration *int64` field
- `callbacks/langfuse/langfuse.go`: Track startTime and compute duration
- `callbacks/langfuse/go.mod`: Add local replace for development

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Feb 10, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants