Skip to content

chore(llmobs): dac strip io from anthropic #13767

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jsimpher
Copy link
Contributor

@jsimpher jsimpher commented Jun 25, 2025

Remove potentially sensitive i/o data from apm spans. This way, prompt and completion data will only appear on the llm obs spans, which are/will be subject to data access controls.

Mostly, this just removes io tag sets. A few things (mostly metrics) have llmobs tags dependent on span tags, so there is a bit more refactoring there.

Let me know if I removed anything that should really stay, or if I missed something that should be restricted.

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 Jun 25, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/remove-io-data-from-span-anthropic-integration-a8b9ccdd3ac1d22d.yaml  @DataDog/apm-python
ddtrace/contrib/internal/anthropic/_streaming.py                        @DataDog/ml-observability
ddtrace/contrib/internal/anthropic/patch.py                             @DataDog/ml-observability
ddtrace/contrib/internal/anthropic/utils.py                             @DataDog/ml-observability
ddtrace/llmobs/_integrations/anthropic.py                               @DataDog/ml-observability
tests/contrib/anthropic/test_anthropic.py                               @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_create_image.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_error.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_multiple_prompts.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_multiple_prompts_with_chat_history.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_stream.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_stream_helper.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_tools.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_tools_full_use.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_tools_full_use_stream.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_tools_stream.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_tools_stream_helper.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.anthropic.test_anthropic.test_anthropic_llm_unserializable_arg.json  @DataDog/ml-observability

@jsimpher jsimpher changed the title dac strip io from anthropic chore(llmobs): dac strip io from anthropic Jun 25, 2025
Copy link
Contributor

github-actions bot commented Jun 25, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

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

The average import time from base is: 286 ± 3 ms.

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

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 2.310 ms (0.82%)
ddtrace.bootstrap.sitecustomize 1.544 ms (0.55%)
ddtrace.bootstrap.preload 1.544 ms (0.55%)
ddtrace.internal.remoteconfig.client 0.714 ms (0.25%)
ddtrace 0.766 ms (0.27%)
ddtrace.internal._unpatched 0.116 ms (0.04%)
subprocess 0.083 ms (0.03%)
contextlib 0.083 ms (0.03%)
json 0.033 ms (0.01%)
json.decoder 0.033 ms (0.01%)
re 0.033 ms (0.01%)
enum 0.033 ms (0.01%)
types 0.033 ms (0.01%)

@pr-commenter
Copy link

pr-commenter bot commented Jun 25, 2025

Benchmarks

Benchmark execution time: 2025-07-01 19:08:50

Comparing candidate commit 7aeb95f in PR branch jsimpher/dac-strip-io-from-anthropic with baseline commit b47c205 in branch main.

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

@jsimpher jsimpher marked this pull request as ready for review June 27, 2025 16:42
@jsimpher jsimpher requested review from a team as code owners June 27, 2025 16:42
@jsimpher jsimpher requested review from wantsui and nsrip-dd June 27, 2025 16:42
Copy link
Contributor

@ncybul ncybul 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 few comments, but glad the integration code was trimmed down so much! Looks great!

@@ -155,7 +154,7 @@ def _process_finished_stream(integration, span, args, kwargs, streamed_chunks):
try:
resp_message = _construct_message(streamed_chunks)
if integration.is_pc_sampled_span(span):
_tag_streamed_chat_completion_response(integration, span, resp_message)
_tag_streamed_chat_completion_usage(integration, span, resp_message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this depend on integration.is_pc_sampled_span?

Copy link
Contributor

@ncybul ncybul left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants