Skip to content

chore(llmobs): dac strip io from OpenAI #13791

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 27 commits into from
Jul 17, 2025

Conversation

jsimpher
Copy link
Contributor

@jsimpher jsimpher commented Jun 26, 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.

This one does a lot that the others don't. I've left things like audio transcript and image/file retrieval that we don't duplicate.

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 26, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/remove-io-data-from-apm-span-openai-integration-81f3ae914a5d2faf.yaml  @DataDog/apm-python
ddtrace/contrib/internal/openai/_endpoint_hooks.py                      @DataDog/ml-observability
ddtrace/contrib/internal/openai/patch.py                                @DataDog/ml-observability
ddtrace/contrib/internal/openai/utils.py                                @DataDog/ml-observability
ddtrace/llmobs/_integrations/openai.py                                  @DataDog/ml-observability
ddtrace/llmobs/_integrations/utils.py                                   @DataDog/ml-observability
ddtrace/llmobs/_utils.py                                                @DataDog/ml-observability
tests/contrib/openai/test_openai_llmobs.py                              @DataDog/ml-observability
tests/contrib/openai/test_openai_v1.py                                  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_acompletion.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_azure_openai_chat_completion.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_azure_openai_completion.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_azure_openai_embedding.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_chat_completion.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_chat_completion_function_calling.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_chat_completion_image_input.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_chat_completion_stream.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_completion.json   @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_completion_stream.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_create_moderation.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_embedding.json    @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_embedding_array_of_token_arrays.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_embedding_string_array.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_embedding_token_array.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_file_create.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_file_delete.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_file_download.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_file_list.json    @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_file_retrieve.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_image_b64_json_response.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_image_create.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_misuse.json       @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_model_delete.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_model_list.json   @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_model_retrieve.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_response.json     @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_response_error.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_response_stream.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_response_tools.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_response_tools_stream.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai.test_span_finish_on_stream_error.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_completion_stream_est_tokens.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_empty_streamed_chat_completion_resp_returns.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_empty_streamed_completion_resp_returns.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_empty_streamed_response_resp_returns.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_async.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_service_name[None-None].json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_service_name[None-v0].json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_service_name[None-v1].json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_service_name[mysvc-None].json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_service_name[mysvc-v0].json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_service_name[mysvc-v1].json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_v1.test_integration_sync.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai_agents.test_openai_agents.test_openai_agents.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai_agents.test_openai_agents.test_openai_agents_streaming.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai_agents.test_openai_agents.test_openai_agents_sync.json  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai_agents.test_openai_agents.test_openai_agents_with_tool_error.json  @DataDog/ml-observability

Copy link
Contributor

github-actions bot commented Jun 26, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

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

The average import time from base is: 283 ± 7 ms.

The import time difference between this PR and base is: -4.8 ± 0.2 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 2.205 ms (0.79%)
ddtrace.bootstrap.sitecustomize 1.520 ms (0.55%)
ddtrace.bootstrap.preload 1.520 ms (0.55%)
ddtrace.internal.remoteconfig.client 0.703 ms (0.25%)
ddtrace 0.685 ms (0.25%)
ddtrace.internal._unpatched 0.034 ms (0.01%)
json 0.034 ms (0.01%)
json.decoder 0.034 ms (0.01%)
re 0.034 ms (0.01%)
enum 0.034 ms (0.01%)
types 0.034 ms (0.01%)

@pr-commenter
Copy link

pr-commenter bot commented Jun 26, 2025

Benchmarks

Benchmark execution time: 2025-07-15 19:37:22

Comparing candidate commit 94ab642 in PR branch jsimpher/dac-strip-io-from-openai with baseline commit c81e594 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 508 metrics, 2 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 P403n1x87 and quinna-h 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.

Looking good, left some comments / questions! Lmk when you need another review!

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.

Thanks for addressing my previous comments! In general, things look good, I am just wondering whether we should be even more heavy-handed removing tags from the APM spans that probably never needed to be there anyway. That might be outside the scope of this PR, but would be a good opportunity to clean things up even more. Lmk if any of that is unclear!

jsimpher and others added 3 commits July 11, 2025 09:06
…tion-81f3ae914a5d2faf.yaml

Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com>
@jsimpher jsimpher requested review from Yun-Kim and ncybul July 14, 2025 13:49
Copy link
Contributor

@Yun-Kim Yun-Kim left a comment

Choose a reason for hiding this comment

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

One last question

…tion-81f3ae914a5d2faf.yaml

Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com>
@jsimpher
Copy link
Contributor Author

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Jul 17, 2025

View all feedbacks in Devflow UI.

2025-07-17 13:14:55 UTC ℹ️ Start processing command /merge


2025-07-17 13:15:15 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-07-17 13:17:25 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 2h (p90).


2025-07-17 15:03:46 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit f13a126 into main Jul 17, 2025
470 checks passed
@dd-mergequeue dd-mergequeue bot deleted the jsimpher/dac-strip-io-from-openai branch July 17, 2025 15:03
brettlangdon pushed a commit that referenced this pull request Jul 18, 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.

This one does a lot that the others don't. I've left things like audio
transcript and image/file retrieval that we don't duplicate.

## Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com>
alyshawang pushed a commit that referenced this pull request Jul 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.

This one does a lot that the others don't. I've left things like audio
transcript and image/file retrieval that we don't duplicate.

## Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants