diff --git a/agentops/instrumentation/agentic/haystack/instrumentor.py b/agentops/instrumentation/agentic/haystack/instrumentor.py index 4e371c09d..669bf42ff 100644 --- a/agentops/instrumentation/agentic/haystack/instrumentor.py +++ b/agentops/instrumentation/agentic/haystack/instrumentor.py @@ -32,7 +32,9 @@ def __init__(self): 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, ar tracer, "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.py index 560043ad5..cc502b6d0 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, Optional import os from functools import wraps import 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 UUID iat: int # Issued At: When the token was created exp: int # Expiration Time: When the token expires diff --git a/app/api/agentops/common/environment.py b/app/api/agentops/common/environment.py index ff073216f..390b0be8b 100644 --- a/app/api/agentops/common/environment.py +++ b/app/api/agentops/common/environment.py @@ -33,6 +33,7 @@ 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 defaults diff --git a/app/api/agentops/common/postgres.py b/app/api/agentops/common/postgres.py index 815092be3..1063e674d 100644 --- a/app/api/agentops/common/postgres.py +++ b/app/api/agentops/common/postgres.py @@ -10,6 +10,7 @@ SUPABASE_PASSWORD, SUPABASE_MIN_POOL_SIZE, SUPABASE_MAX_POOL_SIZE, + SUPABASE_SSLMODE, ) logger = logging.getLogger(__name__) @@ -36,7 +37,7 @@ def __init__(self) -> None: @classmethod def 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.yaml index c5b9c5b02..765c28990 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}