Skip to content

Commit 59c574e

Browse files
jsonbaileyclaude
andcommitted
chore: Include track data in at-most-once warning logs
All six at-most-once guard warnings in tracker.py now log the track data dict (runId, configKey, etc.) to aid debugging duplicate-track scenarios. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a6e9612 commit 59c574e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def track_duration(self, duration: int) -> None:
155155
:param duration: Duration in milliseconds.
156156
"""
157157
if self._summary.duration is not None:
158-
logger.warning("Duration has already been tracked for this execution.")
158+
logger.warning("Duration has already been tracked for this execution. %s", self.__get_track_data())
159159
return
160160
self._summary._duration = duration
161161
self._ld_client.track(
@@ -169,7 +169,10 @@ def track_time_to_first_token(self, time_to_first_token: int) -> None:
169169
:param time_to_first_token: Time to first token in milliseconds.
170170
"""
171171
if self._summary.time_to_first_token is not None:
172-
logger.warning("Time to first token has already been tracked for this execution.")
172+
logger.warning(
173+
"Time to first token has already been tracked for this execution. %s",
174+
self.__get_track_data(),
175+
)
173176
return
174177
self._summary._time_to_first_token = time_to_first_token
175178
self._ld_client.track(
@@ -297,7 +300,7 @@ def track_feedback(self, feedback: Dict[str, FeedbackKind]) -> None:
297300
:param feedback: Dictionary containing feedback kind.
298301
"""
299302
if self._summary.feedback is not None:
300-
logger.warning("Feedback has already been tracked for this execution.")
303+
logger.warning("Feedback has already been tracked for this execution. %s", self.__get_track_data())
301304
return
302305
self._summary._feedback = feedback
303306
if feedback["kind"] == FeedbackKind.Positive:
@@ -320,7 +323,7 @@ def track_success(self) -> None:
320323
Track a successful AI generation.
321324
"""
322325
if self._summary.success is not None:
323-
logger.warning("Success has already been tracked for this execution.")
326+
logger.warning("Success has already been tracked for this execution. %s", self.__get_track_data())
324327
return
325328
self._summary._success = True
326329
self._ld_client.track(
@@ -332,7 +335,7 @@ def track_error(self) -> None:
332335
Track an unsuccessful AI generation attempt.
333336
"""
334337
if self._summary.success is not None:
335-
logger.warning("Success has already been tracked for this execution.")
338+
logger.warning("Success has already been tracked for this execution. %s", self.__get_track_data())
336339
return
337340
self._summary._success = False
338341
self._ld_client.track(
@@ -401,7 +404,7 @@ def track_tokens(self, tokens: TokenUsage) -> None:
401404
:param tokens: Token usage data from either custom, OpenAI, or Bedrock sources.
402405
"""
403406
if self._summary.usage is not None:
404-
logger.warning("Tokens have already been tracked for this execution.")
407+
logger.warning("Tokens have already been tracked for this execution. %s", self.__get_track_data())
405408
return
406409
self._summary._usage = tokens
407410
td = self.__get_track_data()

0 commit comments

Comments
 (0)