Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(llmobs): fix langchain nested llm spans (#9354)
- Fix nested LLM Spans for LLMObs langchain integration when openai/bedrock is enabled - If the LLMObs integration detects that one of our supported LLM integrations is enabled (bedrock or openai) and also detects that the user is using a Langchain plugin for these llm integrations (which we detect using the `model_provider` tag set by the langchain integration), then the llm operation is not marked as a workflow span. If not, the llm operation is marked as a an llm span. We also add a `TestLangchainTraceStructureWithLlmIntegrations` class to allow us to assert on the "trace structure" (where structure is defined by the order of span kinds enqueued to the LLM Obs trace writer) to verify the changes above ## Bedrock ### With bedrock enabled <img width="908" alt="image" src="https://github.com/DataDog/dd-trace-py/assets/42917263/74b89b5e-a3a4-462f-a457-265c29182619"> ### Without bedrock enabled <img width="965" alt="image" src="https://github.com/DataDog/dd-trace-py/assets/42917263/48fba486-41ee-4370-9603-0202d6651fd8"> ## OpenAI ### With openai enabled: <img width="930" alt="image" src="https://github.com/DataDog/dd-trace-py/assets/42917263/69a97429-04e5-429e-a506-e8d676b95568"> ### Without openai enabled <img width="844" alt="image" src="https://github.com/DataDog/dd-trace-py/assets/42917263/42f99bec-a457-45e0-8e80-75a5d545b73d"> ## 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 - [ ] Title is accurate - [ ] All changes are related to the pull request's stated goal - [ ] Description motivates each change - [ ] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [ ] Testing strategy adequately addresses listed risks - [ ] Change is maintainable (easy to change, telemetry, documentation) - [ ] Release note makes sense to a user of the library - [ ] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [ ] 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 <[email protected]> Co-authored-by: Brett Langdon <[email protected]>
- Loading branch information