Skip to content

Commit

Permalink
record_function uses singleton (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 authored Mar 26, 2024
1 parent 3c4df49 commit 4276dac
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions agentops/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4276dac

Please sign in to comment.