-
Notifications
You must be signed in to change notification settings - Fork 394
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
feat(llmobs): support in-code config for llmobs [backport 2.9] #9366
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Support in-code configuration for LLMObs users, to enable LLMObs and specify the following configurations that currently require environment variable configuration. - ml_app - list of integrations to patch (will patch all LLMObs integrations by default) - dd_llmobs_no_apm (turn off APM, telemetry, remote config, metrics) - DD site, DD env, DD service (will override config/env vars) ``` from ddtrace.llmobs import LLMObs LLMObs.enable( ml_app="comms/langchain", integrations=["openai"], llmobs_agentless_enabled=True, # api_key =... # site=... # env=... # service=... # _tracer=None ) ``` Allowing in-code setup also improves the dev experience for people tracing experimental apps with LLMObs. It also abstracts away a long list of environment variables non-APM customers are required to set to turn off all APM related features. This PR should not break _any_ previous way of setting up the Python SDK (e.g. using env vars and `ddtrace-run`). Arguments passed to enable() should take precedence over environment variables, with the exception of `DD_LLMOBS_ENABLED`. This PR also does a couple minor things: - If `DD_LLMOBS_NO_APM` env var is detected or configured through LLMObs.enable(), the OpenAI and LangChain integrations will disable submitting metrics unless the corresponding env vars `DD_{OPENAI,LANGCHAIN}_METRICS_ENABLED` is set to True. - We also automatically disable both telemetry writer and remote config pollers if `DD_LLMOBS_NO_APM` is detected or configured through LLMObs.enable(). - We automatically patch the LLMObs integrations on LLMObs.enable(). - Removes all LLMObs.enable() references in individual integration patch code (openai, botocore, langchain) Note: - This change (only for LLMObs users) will override `config.service, config.env` if these are passed in to `LLMObs.enable()`. - If a user runs via `ddtrace-run`, they cannot use `LLMObs.enable()` to configure their settings. ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) --------- Co-authored-by: lievan <evan.li@datadoqhq.com> Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com> Co-authored-by: Yun Kim <yun.kim@datadoghq.com> (cherry picked from commit bf858f7)
Yun-Kim
approved these changes
May 23, 2024
Datadog ReportBranch report: ✅ 0 Failed, 3531 Passed, 165 Skipped, 1h 33m 23.32s Total duration (37.1s time saved) |
erikayasuda
approved these changes
May 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport bf858f7 from #9172 to 2.9.
Support in-code configuration for LLMObs users, to enable LLMObs and specify the following configurations that currently require environment variable configuration.
Allowing in-code setup also improves the dev experience for people tracing experimental apps with LLMObs. It also abstracts away a long list of environment variables non-APM customers are required to set to turn off all APM related features.
This PR should not break any previous way of setting up the Python SDK (e.g. using env vars and
ddtrace-run
).Arguments passed to enable() should take precedence over environment variables, with the exception of
DD_LLMOBS_ENABLED
.This PR also does a couple minor things:
DD_LLMOBS_NO_APM
env var is detected or configured through LLMObs.enable(), the OpenAI and LangChain integrations will disable submitting metrics unless the corresponding env varsDD_{OPENAI,LANGCHAIN}_METRICS_ENABLED
is set to True.DD_LLMOBS_NO_APM
is detected or configured through LLMObs.enable().Note:
config.service, config.env
if these are passed in toLLMObs.enable()
.ddtrace-run
, they cannot useLLMObs.enable()
to configure their settings.Checklist
changelog/no-changelog
is set@DataDog/apm-tees
.Reviewer Checklist