From 4276daced50e6cc66327ec4c4502246860ee3e1c Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Mon, 25 Mar 2024 18:03:07 -0700 Subject: [PATCH] record_function uses singleton (#118) --- agentops/decorators.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/agentops/decorators.py b/agentops/decorators.py index 165512ac..abd5702d 100644 --- a/agentops/decorators.py +++ b/agentops/decorators.py @@ -15,20 +15,18 @@ def record_function(event_name: str): event_name (str): The name of the event to record. """ - ao_client = Client() - def decorator(func): if inspect.iscoroutinefunction(func): @functools.wraps(func) async def async_wrapper(*args, **kwargs): - return await ao_client._record_event_async(func, event_name, *args, **kwargs) + return await Client()._record_event_async(func, event_name, *args, **kwargs) return async_wrapper else: @functools.wraps(func) def sync_wrapper(*args, **kwargs): - return ao_client._record_event_sync(func, event_name, *args, **kwargs) + return Client()._record_event_sync(func, event_name, *args, **kwargs) return sync_wrapper