Commit 9ae11b8
fix(langfuse): fix latency display showing incorrect huge hours value
## 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 <noreply@anthropic.com>1 parent 1f91f54 commit 9ae11b8
File tree
3 files changed
+35
-9
lines changed- callbacks/langfuse
- libs/acl/langfuse
3 files changed
+35
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
| 201 | + | |
200 | 202 | | |
201 | 203 | | |
202 | 204 | | |
| |||
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
209 | | - | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
| |||
222 | 224 | | |
223 | 225 | | |
224 | 226 | | |
| 227 | + | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
| |||
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
| 236 | + | |
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
| |||
238 | 242 | | |
239 | 243 | | |
240 | 244 | | |
241 | | - | |
| 245 | + | |
242 | 246 | | |
243 | 247 | | |
244 | 248 | | |
| |||
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
| 255 | + | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| |||
264 | 269 | | |
265 | 270 | | |
266 | 271 | | |
| 272 | + | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
270 | 276 | | |
271 | 277 | | |
272 | 278 | | |
| 279 | + | |
273 | 280 | | |
274 | 281 | | |
275 | | - | |
276 | | - | |
| 282 | + | |
| 283 | + | |
277 | 284 | | |
278 | 285 | | |
279 | 286 | | |
| |||
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
286 | 299 | | |
287 | 300 | | |
288 | 301 | | |
| |||
295 | 308 | | |
296 | 309 | | |
297 | 310 | | |
298 | | - | |
| 311 | + | |
| 312 | + | |
299 | 313 | | |
300 | 314 | | |
301 | 315 | | |
302 | 316 | | |
303 | | - | |
| 317 | + | |
| 318 | + | |
304 | 319 | | |
305 | | - | |
306 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
307 | 329 | | |
308 | 330 | | |
309 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
| 230 | + | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
| 251 | + | |
250 | 252 | | |
251 | 253 | | |
252 | 254 | | |
| |||
0 commit comments