Skip to content

feat(llmobs): [MLOB-2680] add apm span for openai responses endpoint #13285

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

Closed
wants to merge 5 commits into from

Conversation

XG-xin
Copy link
Contributor

@XG-xin XG-xin commented Apr 28, 2025

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

print("record request is called")

def _record_response(self, pin, integration, span, args, kwargs, resp, error):
resp = super()._record_response(pin, integration, span, args, kwargs, resp, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

Copy link
Contributor

github-actions bot commented Apr 28, 2025

CODEOWNERS have been resolved as:

tests/contrib/openai/cassettes/v1/response_create.yaml                  @DataDog/ml-observability
tests/snapshots/tests.contrib.openai.test_openai_llmobs.test_response_completion.json  @DataDog/apm-python
ddtrace/contrib/internal/openai/_endpoint_hooks.py                      @DataDog/ml-observability
ddtrace/contrib/internal/openai/patch.py                                @DataDog/ml-observability
tests/contrib/openai/test_openai_llmobs.py                              @DataDog/ml-observability

Copy link
Contributor

github-actions bot commented Apr 28, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 229 ± 2 ms.

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

The import time difference between this PR and base is: -3.8 ± 0.09 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 2.173 ms (0.95%)
ddtrace.bootstrap.sitecustomize 1.419 ms (0.62%)
ddtrace.bootstrap.preload 1.419 ms (0.62%)
ddtrace.internal.products 1.419 ms (0.62%)
ddtrace.internal.remoteconfig.client 0.656 ms (0.29%)
ddtrace 0.754 ms (0.33%)
ddtrace._logger 0.081 ms (0.04%)
logging 0.045 ms (0.02%)
traceback 0.045 ms (0.02%)
contextlib 0.045 ms (0.02%)
ddtrace.internal.telemetry 0.036 ms (0.02%)
ddtrace.internal.telemetry.writer 0.036 ms (0.02%)
ddtrace.internal.periodic 0.036 ms (0.02%)
ddtrace.internal._threads 0.036 ms (0.02%)

@XG-xin XG-xin changed the title feat(llmobs): [MLOB-2635] add support for openai responses endpoint feat(llmobs): [MLOB-2635] add apm span for openai responses endpoint Apr 28, 2025
@XG-xin XG-xin changed the title feat(llmobs): [MLOB-2635] add apm span for openai responses endpoint feat(llmobs): [MLOB-2680] add apm span for openai responses endpoint Apr 29, 2025
@XG-xin XG-xin marked this pull request as ready for review April 29, 2025 21:54
@XG-xin XG-xin requested review from a team as code owners April 29, 2025 21:54
@pr-commenter
Copy link

pr-commenter bot commented Apr 30, 2025

Benchmarks

Benchmark execution time: 2025-04-30 14:41:26

Comparing candidate commit f928b0f in PR branch xinyuan/openai-responses with baseline commit 6bbb551 in branch main.

Found 14 performance improvements and 1 performance regressions! Performance is the same for 482 metrics, 3 unstable metrics.

scenario:iast_aspects-lower_aspect

  • 🟥 execution_time [+207.505ns; +255.262ns] or [+9.154%; +11.260%]

scenario:packagesupdateimporteddependencies-import_many

  • 🟩 execution_time [-27.254ms; -27.153ms] or [-99.618%; -99.251%]

scenario:packagesupdateimporteddependencies-import_many_cached

  • 🟩 execution_time [-27.932µs; -26.344µs] or [-18.867%; -17.794%]

scenario:packagesupdateimporteddependencies-import_many_stdlib

  • 🟩 execution_time [-731.857ms; -728.222ms] or [-100.148%; -99.651%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • 🟩 execution_time [-730.359ms; -726.657ms] or [-100.231%; -99.723%]

scenario:packagesupdateimporteddependencies-import_many_unknown

  • 🟩 execution_time [-30.034ms; -29.921ms] or [-97.491%; -97.125%]

scenario:packagesupdateimporteddependencies-import_many_unknown_cached

  • 🟩 execution_time [-251.324µs; -234.297µs] or [-24.311%; -22.664%]

scenario:packagesupdateimporteddependencies-import_one

  • 🟩 execution_time [-11.298ms; -11.227ms] or [-100.139%; -99.511%]

scenario:packagesupdateimporteddependencies-import_one_cache

  • 🟩 execution_time [-787.277ns; -718.496ns] or [-11.207%; -10.228%]

scenario:packagesupdateimporteddependencies-import_one_stdlib

  • 🟩 execution_time [-10.345ms; -10.302ms] or [-100.028%; -99.610%]

scenario:packagesupdateimporteddependencies-import_one_stdlib_cache

  • 🟩 execution_time [-646.281ns; -578.189ns] or [-9.374%; -8.386%]

scenario:packagesupdateimporteddependencies-import_one_unknown

  • 🟩 execution_time [-19.721ms; -19.639ms] or [-99.978%; -99.561%]

scenario:packagesupdateimporteddependencies-import_one_unknown_cache

  • 🟩 execution_time [-846.313ns; -755.410ns] or [-11.998%; -10.709%]

scenario:samplingrules-average_match

  • 🟩 execution_time [-187.801µs; -183.599µs] or [-36.167%; -35.358%]

scenario:samplingrules-low_match

  • 🟩 execution_time [-347.516µs; -344.182µs] or [-67.487%; -66.840%]

@XG-xin XG-xin closed this Apr 30, 2025
@XG-xin
Copy link
Contributor Author

XG-xin commented Apr 30, 2025

Closing this because because I'm working on #13304

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.

1 participant