Skip to content

Enable LLM Observability with agentless_enabled=True by default with a parsed API key #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2025
Merged
Changes from 1 commit
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
11 changes: 10 additions & 1 deletion datadog_lambda/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@
if profiling_env_var:
from ddtrace.profiling import profiler

llmobs_api_key = None
llmobs_env_var = os.environ.get("DD_LLMOBS_ENABLED", "false").lower() in ("true", "1")
if llmobs_env_var:
from datadog_lambda.api import init_api
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice use of lazy loading here!

from datadog import api
from ddtrace.llmobs import LLMObs

init_api()
llmobs_api_key = api._api_key

logger = logging.getLogger(__name__)

DD_FLUSH_TO_LOG = "DD_FLUSH_TO_LOG"
Expand Down Expand Up @@ -229,7 +235,10 @@ def __init__(self, func):

# Enable LLM Observability
if llmobs_env_var:
LLMObs.enable()
LLMObs.enable(
agentless_enabled=True,
api_key=llmobs_api_key,
)

logger.debug("datadog_lambda_wrapper initialized")
except Exception as e:
Expand Down
Loading