Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/oss/src/core/auth/supertokens/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Dict, List, Any
from urllib.parse import urlparse

from supertokens_python.recipe.emailpassword.types import InputFormField
from supertokens_python import init, InputAppInfo, SupertokensConfig
from supertokens_python.recipe import (
emailpassword,
Expand Down Expand Up @@ -300,6 +301,14 @@ def init_supertokens():
validate=validate_actual_email,
optional=True,
),
InputFormField(
id="password",
validate=lambda value: (
"Password must be at least 8 characters long"
if len(value) < 8
else None
),
),
]
),
override=EmailPasswordInputOverrideConfig(
Expand Down
14 changes: 12 additions & 2 deletions sdk/agenta/sdk/agenta_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ def init(
)

if self.api_key is None:
log.info(
"Agenta - API key: missing (if needed, set AGENTA_API_KEY environment variable or pass api_key parameter in ag.init())"
log.warning(
"Agenta API key is not set. Some features may not work properly. "
"Set AGENTA_API_KEY or pass api_key to ag.init()."
)

log.info("Agenta - API URL: %s", self.api_url)
Expand Down Expand Up @@ -220,6 +221,7 @@ def resolve_scopes(self) -> Optional[tuple[str, str, str]]:
)

return None



def init(
Expand Down Expand Up @@ -263,3 +265,11 @@ def init(
)

set_global(tracing=singleton.tracing)
def _warn_if_not_initialized(func_name: str):
singleton = AgentaSingleton()
if singleton.tracing is None:
log.warning(
f"{func_name} called before ag.init(). "
"Call ag.init() before using instrumentation."
)

21 changes: 20 additions & 1 deletion sdk/agenta/sdk/engines/tracing/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


from agenta.sdk.utils.singleton import Singleton
from agenta.sdk.utils.globals import get_global
from agenta.sdk.utils.exceptions import suppress
from agenta.sdk.utils.logging import get_module_logger
from agenta.sdk.engines.tracing.processors import (
Expand All @@ -31,9 +32,22 @@
from agenta.sdk.engines.tracing.propagation import extract, inject
from agenta.sdk.utils.cache import TTLLRUCache


log = get_module_logger(__name__)

_warned = False

def _warn_if_not_initialized(func_name: str):
global _warned

# Get tracing from global state
tracing = get_global("tracing", default=None)

if tracing is None and not _warned:
log.warning(
f"{func_name} called before ag.init(). "
"👉 Call ag.init() at the start of your application."
)
_warned = True

_original_init = trace.TracerProvider.__init__

Expand Down Expand Up @@ -135,6 +149,7 @@ def configure(
self.tracer: Tracer = self.tracer_provider.get_tracer("agenta.tracer")

def get_current_span(self):
_warn_if_not_initialized("Tracing.get_current_span")
_span = None

with suppress():
Expand All @@ -150,6 +165,7 @@ def store_internals(
attributes: Dict[str, Any],
span: Optional[Span] = None,
):
_warn_if_not_initialized("Tracing.store_internals")
with suppress():
if span is None:
span = self.get_current_span()
Expand All @@ -164,6 +180,7 @@ def store_refs(
refs: Dict[str, str],
span: Optional[Span] = None,
):
_warn_if_not_initialized("Tracing.store_refs")
with suppress():
if span is None:
span = self.get_current_span()
Expand All @@ -186,6 +203,7 @@ def store_meta(
meta: Dict[str, Any],
span: Optional[Span] = None,
):
_warn_if_not_initialized("Tracing.store_meta")
with suppress():
if span is None:
span = self.get_current_span()
Expand All @@ -203,6 +221,7 @@ def store_metrics(
metrics: Dict[str, Any],
span: Optional[Span] = None,
):
_warn_if_not_initialized("Tracing.store_metrics")
with suppress():
if span is None:
span = self.get_current_span()
Expand Down