Skip to content

feat(elevenlabs): instrument Agents WebSocket conversations - #20843

Draft
ZStriker19 wants to merge 1 commit into
mainfrom
codex/elevenlabs-agents-websocket
Draft

ZStriker19 wants to merge 1 commit into
mainfrom
codex/elevenlabs-agents-websocket

Conversation

@ZStriker19

Copy link
Copy Markdown
Collaborator

Description

Adds LLM Observability instrumentation for ElevenLabs Python Agents over WebSocket, including synchronous and asynchronous conversations with default or custom audio interfaces.

Each provider event ID produces a workflow turn with direct response, speech-phase, and client-tool children. Transcripts and negotiated PCM16 audio are attached to response messages for full conversation playback. Repeated phrases stay separate, interrupted responses accept late transcripts, and optional completion events are not required. Typed user messages are captured even when no transcript is echoed.

Speech phases annotate meta.metadata.ttfa_eligible: false because transport timing and projected playback are estimates. Input and output share the existing 4 MiB encoded audio budget; unsupported or oversized audio preserves text.

Testing

  • 34 tests pass on each of Python 3.10 and 3.12 with ElevenLabs 2.70.0, using scripts/run-tests.
  • Covers real SDK sync/async worker loops, default/custom interfaces, ordinary event subscriptions, concurrent conversations, explicit parenting, client-tool success/failure, transport errors, typed input, interruption, missing completion events, patch/unpatch, disabled instrumentation, and audio limits.
  • Replay fixtures retain protocol ordering with entirely synthetic audio, transcripts, and identifiers.
  • scripts/lint checks passes. Import analysis finds no cycle involving the new modules.
  • New integration configuration and supported-version data are registered; a release note is included.

Risks

This instruments SDK internals and is currently tested against 2.70.0. Playback placement and interruption trimming are estimates. The bounded two-turn window may omit transcripts arriving more than one subsequent turn late. Live validation of the production instrumentation remains pending.

Additional Notes

Scope is Python Agents WebSocket conversations. Standalone STT/TTS and browser transports are excluded. This PR is draft while coordinated rollout and live validation are completed.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

.claude/skills/apm-integrations/references/reference-integrations.md    @DataDog/python-guild
.claude/skills/llmobs-integrations/references/implementation-guide.md   @DataDog/python-guild
.riot/requirements/1c1de90.txt                                          @DataDog/apm-python
.riot/requirements/fe9b763.txt                                          @DataDog/apm-python
ddtrace/_monkey.py                                                      @DataDog/python-guild @DataDog/apm-idm-python
ddtrace/contrib/internal/elevenlabs/__init__.py                         @DataDog/python-guild @DataDog/apm-idm-python
ddtrace/contrib/internal/elevenlabs/_state.py                           @DataDog/python-guild @DataDog/apm-idm-python
ddtrace/contrib/internal/elevenlabs/patch.py                            @DataDog/python-guild @DataDog/apm-idm-python
ddtrace/internal/settings/_config.py                                    @DataDog/python-guild @DataDog/apm-sdk-capabilities-python
ddtrace/internal/settings/_supported_configurations.py                  @DataDog/apm-python
ddtrace/llmobs/_constants.py                                            @DataDog/ml-observability
ddtrace/llmobs/_integrations/__init__.py                                @DataDog/ml-observability
ddtrace/llmobs/_integrations/elevenlabs.py                              @DataDog/ml-observability
docs/configuration.rst                                                  @DataDog/python-guild
docs/integrations.rst                                                   @DataDog/python-guild
releasenotes/notes/elevenlabs-agents-websocket-962d7ca6a5358676.yaml    @DataDog/apm-python
scripts/integration_registry/registry.yaml                              @DataDog/apm-idm-python
supported-configurations.json                                           @DataDog/apm-python
supported_versions.json                                                 @DataDog/python-guild @DataDog/apm-idm-python
tests/contrib/elevenlabs/__init__.py                                    @DataDog/python-guild @DataDog/apm-idm-python
tests/contrib/elevenlabs/conftest.py                                    @DataDog/python-guild
tests/contrib/elevenlabs/data/conversation.json                         @DataDog/python-guild @DataDog/apm-idm-python
tests/contrib/elevenlabs/test_elevenlabs_llmobs.py                      @DataDog/python-guild @DataDog/apm-idm-python
tests/llmobs/suitespec.yml                                              @DataDog/ml-observability

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 1 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Dependency direction analysis

🚨 New dependency direction violations detected 🚨

5 new violation(s) of the dependency direction rules have been introduced by this PR:

ddtrace.llmobs._integrations.elevenlabs -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133)
ddtrace.contrib.internal.elevenlabs._state -×-> ddtrace.llmobs.types  (contrib -> product:llmobs, score=37)
ddtrace.contrib.internal.elevenlabs._state -×-> ddtrace.llmobs._integrations.audio_utils  (contrib -> product:llmobs, score=5)
ddtrace.contrib.internal.elevenlabs.patch -×-> ddtrace.llmobs._integrations.elevenlabs  (contrib -> product:llmobs, score=4)
ddtrace.contrib.internal.elevenlabs._state -×-> ddtrace.llmobs._integrations.elevenlabs  (contrib -> product:llmobs, score=4)

ddtrace.internal and ddtrace.contrib must not depend on product code, and products must not depend on each other directly. See the dependency-direction-analysis skill for how to fix this.

📈 Existing violations got worse

55 pre-existing violation(s) increased in severity (e.g. their target became more depended-on, or got pulled into an import cycle), though the edge itself isn't new:

Show violations that got worse (showing 5 of 55 highest severity)
ddtrace.internal.openfeature._span_enrichment -×-> ddtrace.trace  (product:openfeature -> product:tracing, score=133, +3 vs base)
ddtrace.appsec._contrib.django -×-> ddtrace.trace  (product:appsec -> product:tracing, score=133, +3 vs base)
ddtrace.llmobs._integrations.vertexai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133, +3 vs base)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=135, +3 vs base)
ddtrace.llmobs._integrations.crewai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133, +3 vs base)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

⚠️ Existing dependency direction violations

There are 201 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 201 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=135)
ddtrace.llmobs._integrations.openai_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133)
ddtrace.appsec._listeners -×-> ddtrace.trace  (product:appsec -> product:tracing, score=133)
ddtrace.aiguard._api_client -×-> ddtrace.trace  (product:aiguard -> product:tracing, score=133)
ddtrace.llmobs._integrations.bedrock -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 4 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build_docs — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | detect_layering_violations — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | validate_supported_configurations_v2_local_file — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 4 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3054cc9 | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Oct 6, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-10-06 20:30:29

Comparing candidate commit 3054cc9 in PR branch codex/elevenlabs-agents-websocket with baseline commit 8385955 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 7 performance regressions! Performance is the same for 595 metrics, 10 unstable metrics, 6 known flaky benchmarks, 18 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:httppropagationextract-empty_headers

  • 🟥 execution_time [+109.301ns; +133.376ns] or [+14.906%; +18.190%]

scenario:httppropagationextract-tracecontext_headers

  • 🟥 execution_time [+3.157µs; +3.377µs] or [+10.404%; +11.128%]

scenario:iastaspectsremodule-re_expand_aspect

  • 🟥 execution_time [+68.826µs; +78.958µs] or [+10.921%; +12.529%]

scenario:msgpackencoderscenario-simple_one_span

  • 🟥 execution_time [+514.536ns; +562.757ns] or [+12.541%; +13.716%]

scenario:openfeatureflagevaluation-hook-enqueue-typical

  • 🟥 execution_time [+1.594µs; +1.734µs] or [+7.328%; +7.972%]

scenario:otelspan-start

  • 🟥 execution_time [+1.972ms; +2.794ms] or [+8.033%; +11.385%]

scenario:recursivecomputation-shallow

  • 🟥 execution_time [+52.130µs; +55.417µs] or [+7.481%; +7.952%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:coreapiscenario-context_with_data_listeners

  • unstable execution_time [-736.596ns; +740.430ns] or [-7.033%; +7.070%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-34.507ns; +43.669ns] or [-5.167%; +6.539%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1915.540ns; +1941.138ns] or [-9.565%; +9.693%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1894.833ns; +2109.849ns] or [-9.806%; +10.919%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-383.807ns; +380.341ns] or [-8.948%; +8.867%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-235.518ns; +224.327ns] or [-8.672%; +8.260%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-100.329ns; +90.242ns] or [-7.197%; +6.474%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-4621.476ns; +4743.118ns] or [-9.508%; +9.758%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-1073.858ns; +830.971ns] or [-10.388%; +8.038%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-61.790µs; +46.764µs] or [-10.820%; +8.189%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+3.069µs; +3.200µs] or [+21.779%; +22.705%]

scenario:iastaspects-translate_aspect

  • 🟥 execution_time [+108.583µs; +112.985µs] or [+16.226%; +16.884%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+152.305µs; +159.385µs] or [+41.699%; +43.638%]

scenario:span-start

  • 🟥 execution_time [+1.079ms; +1.521ms] or [+8.409%; +11.850%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+240.068ns; +276.132ns] or [+12.290%; +14.136%]

scenario:tracer-small

  • 🟥 execution_time [+40.952µs; +42.475µs] or [+16.331%; +16.938%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-casefold_noaspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-ljust_noaspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-rstrip_aspect
  • scenario:iastaspects-swapcase_aspect
  • scenario:iastaspects-title_noaspect
  • scenario:iastaspects-translate_noaspect
  • scenario:iastaspects-upper_noaspect
  • scenario:iastaspectssplit-rsplit_aspect
  • scenario:packagespackageforrootmodulemapping-cache_off
  • scenario:packagespackageforrootmodulemapping-cache_on
  • scenario:sethttpmeta-all-enabled
  • scenario:telemetryaddmetric-record-100-metrics

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