Skip to content

Adds Call Traces — per-turn STT/LLM/TTS latency for voice agent calls. - #123

Open
MSami625 wants to merge 59 commits into
mainfrom
otel-traces
Open

Adds Call Traces — per-turn STT/LLM/TTS latency for voice agent calls.#123
MSami625 wants to merge 59 commits into
mainfrom
otel-traces

Conversation

@MSami625

@MSami625 MSami625 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

What Changed?

Adds Call Traces — per-turn STT/LLM/TTS latency for voice agent calls.

  • New /api/v1/observability/traces API (session create, OTLP ingest, list/detail, close)
  • DB tables for trace storage (078_synthetic_call_traces)
  • Pipecat integration SDK (efficientai.integrations.efficientai_traces) for external bots
  • In-process OTLP export for playground voice agents
  • Call Traces UI with waterfall, charts, and turn breakdown
  • Trace panels on evaluator results, playground calls, and observability views
  • Pipecat example bots + local test scripts

Why?

Reviewers need per-turn latency (STT / LLM / TTS) during playground runs, phone evals, and external Pipecat agents. This adds OTLP-based trace ingest correlated by call_short_id, so latency is visible in one place in the UI.

How to Test?

  1. Run eai start-all and confirm migration 078 applied.
  2. API smoke test:
    export EFFICIENTAI_API_KEY="..." EFFICIENTAI_WORKSPACE_ID="..."
    uv run python scripts/test_local_pipecat_trace.py
  3. Pipecat WebRTC: follow docs/synthetic-call-traces-pipecat.md → talk 2–3 turns → check Call Traces UI.
  4. Playground: run a voice agent call → confirm trace panel on call detail.
  5. Evaluator: run a trace-enabled eval → confirm trace on result detail.
  6. Run tests:
    uv run pytest tests/test_synthetic_trace_*.py tests/test_efficientai_traces_correlation.py tests/test_services/test_playground_tracing.py -q

Release Label

Select one semantic version bump intent for this PR:

  • major - breaking change, next release bumps major version
  • minor - backward-compatible feature, next release bumps minor version
  • fix - backward-compatible bug fix, next release bumps patch version
  • No label (defaults to patch release)

Intended release label: minor

Checklist

  • [x ] I have read the CONTRIBUTING.md guide.
  • [x ] My code follows the project's style guidelines.
  • [x ] I have added tests that prove my fix is effective or my feature works.
  • [x ] I have updated documentation where needed.

MSami625 and others added 30 commits August 7, 2026 19:02
…sage pricing routes; enhance usage snapshot billability checks
…eamline cost calculations for pending usage deltas
…ations; enforce CSP and adjust token lifetimes
… API keys; refactor local storage clearing logic
…orm logouts; streamline local storage clearing
…or evaluator results and metric studio runs; improve CSP policy for voice provider connections
…n events and audio billing; enhance CSP policy for frame sources
…g evaluator result creation and usage tracking;
…oducing patching for blob storage and integrating new storage stubs
…processing; improve error handling during database commits
…call usage tracking; update test to reflect new behavior
… tests; update configuration and service logic to prevent external API calls
… conversation tracking in test agents and voice agents
…and update configuration for Flexprice setup
…icense features to canonical meters with dry-run option
…ribe functionality and updating configuration options
…pt partial AI assistance, enhancing tracking for generated prompts and scenarios
…information and updating event handling for playground calls and fix sarvam ai flooding logs
@MSami625

MSami625 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown

Greptile Summary

Adds end-to-end synthetic call tracing, including OTLP ingestion, persistent trace and turn storage, SDK and playground instrumentation, and trace visualization throughout the frontend.

  • Introduces trace session, ingest, list, detail, and close APIs with migration-backed storage.
  • Adds Pipecat integration helpers and in-process playground span export.
  • Adds waterfall, latency chart, recording, and turn-detail interfaces across call and evaluator views.

Confidence Score: 2/5

The PR should not merge until concurrent playground tracing is isolated per call and evaluator-result trace reads stop mutating other workspaces.

Shared mutable exporter state can persist call telemetry under the wrong tenant or trace, while organization-wide backfilling from a workspace-scoped read changes trace records outside the caller's selected workspace.

Files Needing Attention: app/services/voice_agent/playground_tracing.py, app/services/synthetic_traces/internal_otlp_exporter.py, app/api/v1/routes/synthetic_traces.py, app/services/synthetic_traces/trace_service.py

Security Review

The shared in-process playground exporter can apply one concurrent call's tenant and call identifiers to another call's queued spans, allowing cross-call and potentially cross-tenant trace contamination.

Important Files Changed

Filename Overview
app/services/voice_agent/playground_tracing.py Adds in-process playground tracing but stores per-call correlation state in process-global mutable tracing components, allowing concurrent calls to be misattributed.
app/services/synthetic_traces/internal_otlp_exporter.py Persists exported spans using mutable exporter-level tenant and call identifiers rather than immutable span-owned context.
app/api/v1/routes/synthetic_traces.py Adds the trace API surface, but a workspace-scoped detail request invokes organization-wide trace backfilling.
app/services/synthetic_traces/trace_service.py Implements correlation, persistence, backfill, and lifecycle handling; the backfill path lacks workspace scoping.
app/migrations/078_synthetic_call_traces.py Adds trace, payload, and turn persistence structures with indexes for trace correlation and lookup.
frontend/src/components/call-recordings/SyntheticCallTracePanel.tsx Adds the primary trace presentation panel for latency summaries, turns, charts, and waterfall details.
src/efficientai/integrations/efficientai_traces/setup.py Adds SDK-side tracing setup and correlation support for external Pipecat agents.

Reviews (1): Last reviewed commit: "feat(api): enhance Agent trace ingestion..." | Re-trigger Greptile

Comment on lines +107 to +120
provider = trace.get_tracer_provider()
if isinstance(provider, TracerProvider):
if _correlation_processor is None:
_correlation_processor = CorrelationSpanProcessor(attrs)
provider.add_span_processor(_correlation_processor)
else:
_correlation_processor.update_attributes(attrs)

_mutable_internal_exporter.configure(
organization_id=org_uuid,
workspace_id=ws_uuid,
call_short_id=call_short_id,
agent_id=agent_id,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security If playground voice calls overlap in one process, each call reconfigures the process-global span processor and exporter, so queued spans are persisted with the latest call's organization, workspace, and correlation identifiers, causing missing traces, incorrect latency data, or cross-tenant telemetry disclosure.

How this was verified: The shared exporter is mutated per call and reads its current tenant and call identifiers only when the asynchronous export executes.

Knowledge Base Used:

Comment on lines +320 to +322
backfill_missing_traces_from_call_recordings(
db, organization_id=organization_id, limit=5
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 When a user requests an evaluator-result trace in one workspace, this call backfills by organization alone, creating and finalizing traces for recent Vobiz recordings in other workspaces and thereby mutating data outside the selected workspace.

Knowledge Base Used:

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