Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/sdk/server-ai/__tests__/LDGraphTrackerImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ it('tracks invocation failure', () => {
);
});

it('tracks latency', () => {
it('tracks duration', () => {
const tracker = new LDGraphTrackerImpl(
mockLdClient,
graphKey,
variationKey,
version,
testContext,
);
tracker.trackLatency(1500);
tracker.trackDuration(1500);

expect(mockTrack).toHaveBeenCalledWith(
'$ld:ai:graph:latency',
'$ld:ai:graph:duration:total',
testContext,
getExpectedTrackData(),
1500,
Expand Down Expand Up @@ -265,7 +265,7 @@ it('summarizes tracked graph metrics', () => {
);

tracker.trackInvocationSuccess();
tracker.trackLatency(2000);
tracker.trackDuration(2000);
tracker.trackTotalTokens({ total: 300, input: 100, output: 200 });
tracker.trackPath(['node-a', 'node-b']);

Expand Down Expand Up @@ -312,20 +312,20 @@ describe('at-most-once semantics for graph-level metrics', () => {
);
});

it('drops duplicate trackLatency calls', () => {
it('drops duplicate trackDuration calls', () => {
const tracker = new LDGraphTrackerImpl(
mockLdClient,
graphKey,
variationKey,
version,
testContext,
);
tracker.trackLatency(1000);
tracker.trackLatency(2000);
tracker.trackDuration(1000);
tracker.trackDuration(2000);

expect(mockTrack).toHaveBeenCalledTimes(1);
expect(mockTrack).toHaveBeenCalledWith(
'$ld:ai:graph:latency',
'$ld:ai:graph:duration:total',
testContext,
getExpectedTrackData(),
1000,
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/server-ai/src/LDGraphTrackerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
this._ldClient.track('$ld:ai:graph:invocation_failure', this._context, this.getTrackData(), 1);
}

trackLatency(durationMs: number): void {
trackDuration(durationMs: number): void {
if (this._trackedMetrics.durationMs !== undefined) {
return;
}
this._trackedMetrics.durationMs = durationMs;
this._ldClient.track('$ld:ai:graph:latency', this._context, this.getTrackData(), durationMs);
this._ldClient.track('$ld:ai:graph:duration:total', this._context, this.getTrackData(), durationMs);

Check failure on line 52 in packages/sdk/server-ai/src/LDGraphTrackerImpl.ts

View workflow job for this annotation

GitHub Actions / build-test-server-sdk-ai

Replace `'$ld:ai:graph:duration:total',·this._context,·this.getTrackData(),·durationMs` with `⏎······'$ld:ai:graph:duration:total',⏎······this._context,⏎······this.getTrackData(),⏎······durationMs,⏎····`
Comment thread
jsonbailey marked this conversation as resolved.
}

trackTotalTokens(tokens: LDTokenUsage): void {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/server-ai/src/api/graph/LDGraphTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ export interface LDGraphTracker {
trackInvocationFailure(): void;

/**
* Track the total latency of graph execution.
* Track the total duration of graph execution.
*
* At-most-once per tracker instance. Subsequent calls are dropped.
*
* @param durationMs Duration in milliseconds.
*/
trackLatency(durationMs: number): void;
trackDuration(durationMs: number): void;

/**
* Track aggregated token usage across the entire graph invocation.
Expand Down
Loading