Skip to content
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

chore(llmobs): better span linking logic for langchain integration #12386

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

sabrenner
Copy link
Contributor

@sabrenner sabrenner commented Feb 18, 2025

refines the beta span linking logic for llmobs langchain spans to reduce memory

removes the _spans mapping of instance IDs to spans. instead, since we really only used this for steps in chains, and the same runnable (e.g. chat model) could be used in different chains, we want to do this mapping by chain instance.

when "recording" an instance we trace, we always do the span --> instance mapping. however, now the instance --> span mapping is only done as a temporary property on chains, as steps outside of chains will be defaulted to their parent span for linkage. this also makes cleanup easier, as we can delete the property and let GC take care of getting rid of the mapping that's unreferenced.

MLOB-2245

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, 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

@sabrenner sabrenner added the changelog/no-changelog A changelog entry is not required for this PR. label Feb 18, 2025
Copy link
Contributor

CODEOWNERS have been resolved as:

ddtrace/llmobs/_integrations/langchain.py                               @DataDog/ml-observability

@sabrenner sabrenner marked this pull request as ready for review February 18, 2025 15:49
@sabrenner sabrenner requested a review from a team as a code owner February 18, 2025 15:49
@pr-commenter
Copy link

pr-commenter bot commented Feb 19, 2025

Benchmarks

Benchmark execution time: 2025-02-19 16:20:34

Comparing candidate commit 22bfb79 in PR branch sabrenner/langchain-span-linking-improvement with baseline commit 0c7fc1b in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 418 metrics, 2 unstable metrics.

@sabrenner sabrenner enabled auto-merge (squash) February 19, 2025 17:52
@sabrenner sabrenner merged commit 6ee0cd1 into main Feb 19, 2025
325 checks passed
@sabrenner sabrenner deleted the sabrenner/langchain-span-linking-improvement branch February 19, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants