Skip to content

fix(llmobs): reuse shared conn #13339

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
May 7, 2025
Merged

fix(llmobs): reuse shared conn #13339

merged 3 commits into from
May 7, 2025

Conversation

Yun-Kim
Copy link
Contributor

@Yun-Kim Yun-Kim commented May 6, 2025

Resolves #13336. Credit to @IAL32 and a cherry-pick from #13338.

When we made the jump from using the shared HTTPWriter to our own BaseLLMObsWriter class to submit spans and evals #12966, we used our own _get_connection() to return HTTP/HTTPS connections. However we forgot to include UDSHTTP connection (for the unix socket case), which means we broke UDS support until now.

Why was this a problem in the first place?

We used our own _get_connection() in #12966 because of an issue where creating the shared HTTPConnection helper class was leading to MRO superclass constructor issues in our tests. At the time we thought this was due to the shared HTTPConnection helper class having multiple superclasses and an issue with Python 3.10 in general, but this turns out to be due to vcrpy mocking HTTPConnection entirely and only being an issue in tests that rely on vcrpy. This PR makes some changes to avoid using vcrpy when not necessary, and making better assertions to ensure that spans are being sent (not necessary in most tests to have them be accepted).

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

Copy link
Contributor

github-actions bot commented May 6, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/fix-llmobs-unix-agent-2b959d436e6474c3.yaml          @DataDog/apm-python
ddtrace/llmobs/_writer.py                                               @DataDog/ml-observability
tests/llmobs/test_llmobs_eval_metric_agent_writer.py                    @DataDog/ml-observability
tests/llmobs/test_llmobs_eval_metric_agentless_writer.py                @DataDog/ml-observability
tests/llmobs/test_llmobs_evaluator_runner.py                            @DataDog/ml-observability
tests/llmobs/test_llmobs_span_agent_writer.py                           @DataDog/ml-observability
tests/llmobs/test_llmobs_span_agentless_writer.py                       @DataDog/ml-observability

Copy link
Contributor

github-actions bot commented May 6, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 234 ± 3 ms.

The average import time from base is: 235 ± 2 ms.

The import time difference between this PR and base is: -0.8 ± 0.1 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.844 ms (0.79%)
ddtrace.bootstrap.sitecustomize 1.174 ms (0.50%)
ddtrace.bootstrap.preload 1.174 ms (0.50%)
ddtrace.internal.products 1.174 ms (0.50%)
ddtrace.internal.remoteconfig.client 0.614 ms (0.26%)
ddtrace 0.670 ms (0.29%)

@Yun-Kim Yun-Kim force-pushed the yunkim/llmobs-writer-fix-conn branch from fa940f2 to 31c134a Compare May 6, 2025 16:42
@Yun-Kim Yun-Kim marked this pull request as ready for review May 6, 2025 16:47
@Yun-Kim Yun-Kim requested review from a team as code owners May 6, 2025 16:47
@Yun-Kim Yun-Kim requested review from wantsui and sabrenner May 6, 2025 16:47
@pr-commenter
Copy link

pr-commenter bot commented May 6, 2025

Benchmarks

Benchmark execution time: 2025-05-06 23:31:11

Comparing candidate commit 3fdca66 in PR branch yunkim/llmobs-writer-fix-conn with baseline commit ea27de2 in branch main.

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

scenario:iast_aspects-format_map_aspect

  • 🟥 execution_time [+503.240ns; +567.383ns] or [+15.293%; +17.242%]

scenario:iast_aspects-ospathsplitdrive_aspect

  • 🟥 execution_time [+400.478ns; +539.554ns] or [+11.070%; +14.914%]

@Yun-Kim Yun-Kim force-pushed the yunkim/llmobs-writer-fix-conn branch 2 times, most recently from 7fedfed to cd7be33 Compare May 6, 2025 20:20
Copy link
Member

@Kyle-Verhoog Kyle-Verhoog left a comment

Choose a reason for hiding this comment

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

just a thought about the change in logs and the implication it might have. It'd also be good to have a better validation than logs for successful transmission but that's a bit larger of an ask outside the scope here

Co-authored-by: IAL32 <[email protected]>
@Yun-Kim Yun-Kim force-pushed the yunkim/llmobs-writer-fix-conn branch from cd7be33 to 3fdca66 Compare May 6, 2025 22:40
@Yun-Kim Yun-Kim merged commit 479699d into main May 7, 2025
335 checks passed
@Yun-Kim Yun-Kim deleted the yunkim/llmobs-writer-fix-conn branch May 7, 2025 17:30
Copy link
Contributor

github-actions bot commented May 7, 2025

The backport to 2.21 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.21 2.21
# Navigate to the new working tree
cd .worktrees/backport-2.21
# Create a new branch
git switch --create backport-13339-to-2.21
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 479699d87a4794d808d854435f3df6ba0e83fb33
# Push it to GitHub
git push --set-upstream origin backport-13339-to-2.21
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.21

Then, create a pull request where the base branch is 2.21 and the compare/head branch is backport-13339-to-2.21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: BaseLLMObsWriter does not support Unix socket
2 participants