diff --git a/agentops/meta_client.py b/agentops/meta_client.py index b95973fa..68b84060 100644 --- a/agentops/meta_client.py +++ b/agentops/meta_client.py @@ -19,7 +19,7 @@ def __new__(cls, name, bases, dct): return super().__new__(cls, name, bases, dct) - def send_exception_to_server(cls, exception, api_key): + def send_exception_to_server(cls, exception, api_key, session): """Class method to send exception to server.""" if api_key: exception_type = type(exception).__name__ @@ -33,6 +33,9 @@ def send_exception_to_server(cls, exception, api_key): "host_env": get_host_env() } + if session: + developer_error["session_id"] = session.session_id + HttpClient.post("https://api.agentops.ai/developer_errors", safe_serialize(developer_error).encode("utf-8"), api_key=api_key) @@ -48,7 +51,7 @@ def wrapper(self, *args, **kwargs): logger.warning(f"🖇 AgentOps: Error: {e}") config = getattr(self, 'config', None) if config is not None: - type(self).send_exception_to_server(e, self.config._api_key) + type(self).send_exception_to_server(e, self.config._api_key, self._session) raise e return wrapper