Skip to content

Commit bff84ef

Browse files
author
Daniel OBrien
committed
change duration tracker implementation type
1 parent fe50860 commit bff84ef

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

ldai/tracker.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ def get_track_data(self):
1919
def track_duration(self, duration: int) -> None:
2020
self.ld_client.track('$ld:ai:duration:total', self.context, self.get_track_data(), duration)
2121

22-
def track_duration_of(self, func):
23-
def wrapper(*args, **kwargs):
24-
start_time = time.time()
25-
result = func(*args, **kwargs)
26-
end_time = time.time()
27-
duration = int((end_time - start_time) * 1000) # duration in milliseconds
28-
self.track_duration(duration)
29-
return result
30-
return wrapper
22+
def track_duration_of(self, func, *args, **kwargs):
23+
start_time = time.time()
24+
result = func(*args, **kwargs)
25+
end_time = time.time()
26+
duration = int((end_time - start_time) * 1000) # duration in milliseconds
27+
self.track_duration(duration)
28+
return result
3129

3230
def track_tokens(self, tokens: Union[TokenUsage, UnderscoreTokenUsage, BedrockTokenUsage]) -> None:
3331
token_metrics = tokens.to_metrics()

0 commit comments

Comments
 (0)