Skip to content

Commit 48531fd

Browse files
jsonbaileyclaude
andcommitted
feat!: rename track_latency to track_duration on AIGraphTracker, update event key to $ld:ai:duration:total
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 39ccda7 commit 48531fd

7 files changed

Lines changed: 15 additions & 15 deletions

File tree

packages/ai-providers/server-ai-langchain/src/ldai_langchain/langgraph_agent_graph_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ async def run(self, input: Any) -> AgentGraphResult:
305305
# Graph-level metrics
306306
if tracker:
307307
tracker.track_path(handler.path)
308-
tracker.track_latency(duration)
308+
tracker.track_duration(duration)
309309
tracker.track_invocation_success()
310310
tracker.track_total_tokens(sum_token_usage_from_messages(messages))
311311

@@ -325,7 +325,7 @@ async def run(self, input: Any) -> AgentGraphResult:
325325
log.warning(f'LangGraphAgentGraphRunner run failed: {exc}')
326326
duration = (time.perf_counter_ns() - start_ns) // 1_000_000
327327
if tracker:
328-
tracker.track_latency(duration)
328+
tracker.track_duration(duration)
329329
tracker.track_invocation_failure()
330330
return AgentGraphResult(
331331
output='',

packages/ai-providers/server-ai-langchain/tests/test_langgraph_agent_graph_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def test_langgraph_runner_run_tracks_failure_on_exception():
8686

8787
assert result.metrics.success is False
8888
tracker.track_invocation_failure.assert_called_once()
89-
tracker.track_latency.assert_called_once()
89+
tracker.track_duration.assert_called_once()
9090

9191

9292
@pytest.mark.asyncio
@@ -148,4 +148,4 @@ async def test_langgraph_runner_run_success():
148148
assert result.metrics.success is True
149149
tracker.track_path.assert_called_once_with([])
150150
tracker.track_invocation_success.assert_called_once()
151-
tracker.track_latency.assert_called_once()
151+
tracker.track_duration.assert_called_once()

packages/ai-providers/server-ai-langchain/tests/test_tracking_langgraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ async def test_tracks_node_and_graph_tokens_on_success():
256256
ev = _events(mock_ld_client)
257257
assert ev['$ld:ai:graph:total_tokens'][0][1] == 15
258258
assert ev['$ld:ai:graph:invocation_success'][0][1] == 1
259-
assert '$ld:ai:graph:latency' in ev
259+
assert '$ld:ai:duration:total' in ev
260260
assert '$ld:ai:graph:path' in ev
261261

262262

@@ -428,7 +428,7 @@ async def test_tracks_failure_and_latency_on_model_error():
428428

429429
ev = _events(mock_ld_client)
430430
assert '$ld:ai:graph:invocation_failure' in ev
431-
assert '$ld:ai:graph:latency' in ev
431+
assert '$ld:ai:duration:total' in ev
432432
assert '$ld:ai:graph:invocation_success' not in ev
433433

434434

packages/ai-providers/server-ai-openai/src/ldai_openai/openai_agent_graph_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def run(self, input: Any) -> AgentGraphResult:
8989

9090
if tracker:
9191
tracker.track_path(path)
92-
tracker.track_latency(duration)
92+
tracker.track_duration(duration)
9393
tracker.track_invocation_success()
9494
token_usage = get_ai_usage_from_response(result)
9595
if token_usage is not None:
@@ -110,7 +110,7 @@ async def run(self, input: Any) -> AgentGraphResult:
110110
log.warning(f'OpenAIAgentGraphRunner run failed: {exc}')
111111
duration = (time.perf_counter_ns() - start_ns) // 1_000_000
112112
if tracker:
113-
tracker.track_latency(duration)
113+
tracker.track_duration(duration)
114114
tracker.track_invocation_failure()
115115
return AgentGraphResult(
116116
output='',

packages/ai-providers/server-ai-openai/tests/test_openai_agent_graph_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def test_openai_agent_graph_runner_run_tracks_invocation_failure_on_except
8989

9090
assert result.metrics.success is False
9191
tracker.track_invocation_failure.assert_called_once()
92-
tracker.track_latency.assert_called_once()
92+
tracker.track_duration.assert_called_once()
9393

9494

9595
@pytest.mark.asyncio
@@ -134,7 +134,7 @@ async def test_openai_agent_graph_runner_run_success():
134134
assert result.metrics.success is True
135135
tracker.track_invocation_success.assert_called_once()
136136
tracker.track_path.assert_called_once()
137-
tracker.track_latency.assert_called_once()
137+
tracker.track_duration.assert_called_once()
138138

139139
root_tracker = graph.get_node('root-agent').get_config().tracker
140140
root_tracker.track_duration.assert_called_once()

packages/ai-providers/server-ai-openai/tests/test_tracking_openai_agents.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ async def test_tracks_graph_invocation_success_and_latency():
266266

267267
ev = _events(mock_ld_client)
268268
assert ev['$ld:ai:graph:invocation_success'][0][1] == 1
269-
assert '$ld:ai:graph:latency' in ev
269+
assert '$ld:ai:duration:total' in ev
270270
assert '$ld:ai:graph:path' in ev
271271

272272

@@ -404,7 +404,7 @@ async def test_tracks_failure_and_latency_on_runner_error():
404404

405405
ev = _events(mock_ld_client)
406406
assert '$ld:ai:graph:invocation_failure' in ev
407-
assert '$ld:ai:graph:latency' in ev
407+
assert '$ld:ai:duration:total' in ev
408408
assert '$ld:ai:graph:invocation_success' not in ev
409409

410410

packages/sdk/server-ai/src/ldai/tracker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,14 @@ def track_invocation_failure(self) -> None:
508508
1,
509509
)
510510

511-
def track_latency(self, duration: int) -> None:
511+
def track_duration(self, duration: int) -> None:
512512
"""
513-
Track the total latency of graph execution.
513+
Track the total duration of graph execution.
514514
515515
:param duration: Duration in milliseconds.
516516
"""
517517
self._ld_client.track(
518-
"$ld:ai:graph:latency",
518+
"$ld:ai:duration:total",
519519
self._context,
520520
self.__get_track_data(),
521521
duration,

0 commit comments

Comments
 (0)