Skip to content

Commit ff14518

Browse files
committed
ensure we always track duration
1 parent cb8d3c8 commit ff14518

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/sdk/server-ai/src/LDAIConfigTrackerImpl.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ export class LDAIConfigTrackerImpl implements LDAIConfigTracker {
151151
// Wait for metrics to be available
152152
const metrics = await metricsExtractor(stream);
153153

154-
// Track final duration
155-
const duration = Date.now() - startTime;
156-
this.trackDuration(duration);
157-
158154
// Track success/error based on metrics
159155
if (metrics.success) {
160156
this.trackSuccess();
@@ -168,8 +164,10 @@ export class LDAIConfigTrackerImpl implements LDAIConfigTracker {
168164
}
169165
} catch (error) {
170166
// If metrics extraction fails, track error
171-
// but don't throw - stream consumption should not be affected
172167
this.trackError();
168+
} finally {
169+
// Track duration regardless of success/error
170+
this.trackDuration(Date.now() - startTime);
173171
}
174172
}
175173

0 commit comments

Comments
 (0)