Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
Add self-hosted Supabase support for local development (#1239)
devin-ai-integration[bot]9e289601606e
diff --git a/agentops/instrumentation/agentic/haystack/instrumentor.py b/agentops/instrumentation/agentic/haystack/instrumentor.pyindex 4e371c09..669bf42f 100644--- a/agentops/instrumentation/agentic/haystack/instrumentor.py+++ b/agentops/instrumentation/agentic/haystack/instrumentor.py@@ -32,7 +32,9 @@ class HaystackInstrumentor(CommonInstrumentor):def _initialize(self, **kwargs):application_name = kwargs.get("application_name", "default_application")environment = kwargs.get("environment", "default_environment")- self._attribute_manager = SpanAttributeManager(service_name=application_name, deployment_environment=environment)+ self._attribute_manager = SpanAttributeManager(+ service_name=application_name, deployment_environment=environment+ )def _create_metrics(self, meter) -> Dict[str, Any]:return StandardMetrics.create_standard_metrics(meter)@@ -123,7 +125,11 @@ def _wrap_haystack_run_impl(tracer, metrics, attr_manager, wrapped, instance, artracer,"haystack.generator.run",kind=SpanKind.CLIENT,- attributes={SpanAttributes.LLM_SYSTEM: "haystack", "gen_ai.model": model, SpanAttributes.LLM_REQUEST_STREAMING: False},+ attributes={+ SpanAttributes.LLM_SYSTEM: "haystack",+ "gen_ai.model": model,+ SpanAttributes.LLM_REQUEST_STREAMING: False,+ },attribute_manager=attr_manager,) as span:prompt = _extract_prompt(args, kwargs)@@ -153,7 +159,11 @@ def _wrap_haystack_stream_impl(tracer, metrics, attr_manager, wrapped, instance,tracer,"haystack.generator.stream",kind=SpanKind.CLIENT,- attributes={SpanAttributes.LLM_SYSTEM: "haystack", "gen_ai.model": model, SpanAttributes.LLM_REQUEST_STREAMING: True},+ attributes={+ SpanAttributes.LLM_SYSTEM: "haystack",+ "gen_ai.model": model,+ SpanAttributes.LLM_REQUEST_STREAMING: True,+ },attribute_manager=attr_manager,) as span:prompt = _extract_prompt(args, kwargs)diff --git a/app/api/agentops/auth/views.py b/app/api/agentops/auth/views.pyindex 560043ad..cc502b6d 100644--- a/app/api/agentops/auth/views.py+++ b/app/api/agentops/auth/views.py@@ -24,7 +24,7 @@# JWTs can be set to expire after a certain amount of time, but not extendable,# not invalidatable from a central location# can be used across domains, which is useful but also XSS risk-from typing import Union, Callable+from typing import Union, Callable, Optionalimport osfrom functools import wrapsimport inspect@@ -112,7 +112,7 @@ class SupabaseUserData(pydantic.BaseModel):model_config = {'extra': 'ignore'}- iss: str # Issuer: The URL of your Supabase project+ iss: Optional[str] = None # Issuer: The URL of your Supabase project (optional for local dev)sub: str # Subject: The user's UUIDiat: int # Issued At: When the token was createdexp: int # Expiration Time: When the token expiresdiff --git a/app/api/agentops/common/environment.py b/app/api/agentops/common/environment.pyindex ff073216..390b0be8 100644--- a/app/api/agentops/common/environment.py+++ b/app/api/agentops/common/environment.py@@ -33,6 +33,7 @@ SUPABASE_PORT = os.getenv('SUPABASE_PORT')SUPABASE_DATABASE = os.getenv('SUPABASE_DATABASE')SUPABASE_USER = os.getenv('SUPABASE_USER')SUPABASE_PASSWORD = os.getenv('SUPABASE_PASSWORD')+SUPABASE_SSLMODE = os.getenv('SUPABASE_SSLMODE', 'prefer')# Supabase allows up to 20 pool connections and 1000 max connections.# Since we share connections with other instances (dev, staging) these defaultsdiff --git a/app/api/agentops/common/postgres.py b/app/api/agentops/common/postgres.pyindex 815092be..1063e674 100644--- a/app/api/agentops/common/postgres.py+++ b/app/api/agentops/common/postgres.py@@ -10,6 +10,7 @@ from .environment import (SUPABASE_PASSWORD,SUPABASE_MIN_POOL_SIZE,SUPABASE_MAX_POOL_SIZE,+ SUPABASE_SSLMODE,)logger = logging.getLogger(__name__)@@ -36,7 +37,7 @@ class ConnectionConfig:@classmethoddef to_connection_string(cls, protocol: str = "postgresql") -> str:"""Format config as a URL connection string."""- return f"{protocol}://{cls.user}:{cls.password}@{cls.host}:{cls.port}/{cls.database}"+ return f"{protocol}://{cls.user}:{cls.password}@{cls.host}:{cls.port}/{cls.database}?sslmode={SUPABASE_SSLMODE}"def _cleanup_handler(signum=None, frame=None):diff --git a/app/compose.yaml b/app/compose.yamlindex c5b9c5b0..765c2899 100644--- a/app/compose.yaml+++ b/app/compose.yaml@@ -15,6 +15,15 @@ services:API_DOMAIN: ${API_DOMAIN}APP_DOMAIN: ${APP_DOMAIN}+ # Supabase PostgreSQL Direct Connection+ SUPABASE_HOST: ${SUPABASE_HOST}+ SUPABASE_PORT: ${SUPABASE_PORT}+ SUPABASE_DATABASE: ${SUPABASE_DATABASE}+ SUPABASE_USER: ${SUPABASE_USER}+ SUPABASE_PASSWORD: ${SUPABASE_PASSWORD}+ SUPABASE_MAX_POOL_SIZE: ${SUPABASE_MAX_POOL_SIZE}+ SUPABASE_SSLMODE: ${SUPABASE_SSLMODE}+SENTRY_DSN: ${SENTRY_DSN}SENTRY_ENVIRONMENT: ${SENTRY_ENVIRONMENT}LOGGING_LEVEL: ${LOGGING_LEVEL}