> ## Documentation Index
> Fetch the complete documentation index at: https://www.voiceflow.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Monitor latency and errors

> Measure Voiceflow application request latency and separate transport errors from unsuccessful business operations in your monitoring platform.

Start with a developer who owns the application's request instrumentation and a monitoring owner who can create numeric measures. This guide builds operation-level latency and error views from measured attempts.

The worked example contains five custom Chat requests and three return-lookups. It does not represent Voiceflow's internal model timings or streaming voice performance.

## Before you begin

- Choose the boundary you can actually measure. For custom non-streaming Chat, use the [Datadog request wrapper](/docs/guides/integrations/datadog/overview#tracing-chat-requests).
- Record operation name, attempt ID, opaque conversation ID, duration, HTTP status and application result. Retain project, Environment and release context.
- Download the [CX worked examples](/docs/examples/monitoring/cx-guides.zip) and complete the monitoring connection. Your developer supplies equivalent measured records for real traffic.

## Measure comparable operations

### 1. Name the clock and unit

Define where timing starts and stops before choosing a target:

| Measurement | Boundary |
| --- | --- |
| `chat.turn` in the example | Server sends a non-streaming Chat action → completed JSON response is read. |
| `returns.lookup` | Backend starts the provider request → its result is read. |
| Time to first text/audio | A separately instrumented streaming delivery boundary. This sample does not measure it. |
| Session or call duration | Lifecycle elapsed time; use the [lifecycle guide](/docs/guides/integrations/datadog/overview#tracking-conversations), not a response-latency chart. |

Export `cx_duration_ms` in milliseconds. Keep different operations and clocks in separate series, and distinguish customer-experienced latency from the sum of potentially overlapping tool calls.

### 2. Export attempts and both result levels

Have the developer map the measurement into `requests.json`. With the Chat wrapper, `result.span.duration / 1000000` supplies the measured duration and `result.status` the HTTP status. Derive business result only from the current application's result contract; leave it unknown when that evidence is absent.

| Field | Meaning |
| --- | --- |
| `cx_request_id` | Unique attempt ID. A transport replay preserves it; a genuinely new attempt gets another ID. |
| `cx_operation` | The measured boundary, such as `chat.turn`. |
| `cx_http_status` | Actual response status; `0` means the caller obtained no final HTTP response. |
| `cx_result` | `success`, `failure` or `unknown` for the application operation. HTTP 200 alone cannot fill this in. |
| `cx_duration_ms` | The elapsed time of that attempt, including failures/timeouts. |

Keep failure records. Excluding slow timeouts can make the healthy-looking latency chart least representative during an incident. Preserve the application's real response/error when telemetry delivery fails.

### 3. Validate and inspect the worked requests

From the extracted examples' `cx` directory, run:

```bash
node publish.mjs requests.json
```

After checking data and server-held Datadog settings, your developer can add `--send` for staging. In **Logs → Explorer**, use:

```text
service:voiceflow-agent env:staging @cx_environment:main @cx_project_id:northstar @cx_review_id:"returns-after" @cx_kind:request @cx_operation:chat.turn
```

Create a numeric measure for `cx_duration_ms` with the correct millisecond unit. Show request count and latency distribution together. The sample's Chat durations are **400, 600, 800, 1000 and 2000 ms**; its nearest-rank P95 is 2000 ms. Your platform's interpolation can differ on tiny samples; five requests are a demonstration, not a production baseline.

### 4. Chart failures without losing business meaning

For each operation, count unique `cx_request_id`. Define `cx_http_status` as an integer facet before numerical range searches. A transport-error query selects HTTP status `0` or a status from `400` to `599`; divide by all attempts of the same operation/window. The five Chat requests contain one HTTP 500, giving **1 / 5 = 20%** transport errors.

Keep a separate view of `cx_result:failure` and `cx_result:unknown`. Among the three return-lookups, one HTTP 200 reports application failure and one attempt has no final HTTP response. Treat that unknown state as an investigation, not proof that the underlying work never happened.

Use [Datadog Log Analytics](https://docs.datadoghq.com/logs/explorer/analytics/) for the ratio and percentile controls, then export the chosen view to a dashboard.

## Verify the instrumentation

In a sandbox, exercise one successful request, a known non-2xx response, a controlled timeout and a 2xx application-level rejection. Confirm their attempt IDs, durations and result classifications in the source and monitor. Repeat while monitoring intake is unavailable; the customer's action must not run again to repair telemetry.

Inspect an individual outlier through [cross-system investigation](/docs/guides/integrations/monitoring/investigate-cross-system-failures). Set [alerts](/docs/guides/integrations/monitoring/alert-on-cx-regressions) only after the population and measurement boundary are stable.

## Troubleshoot the chart

### Latency improves during an outage

Look for missing failed attempts or changed request mix.

Check that timeouts and network failures still produce measurements, then compare operation mix and request count. Do not calculate an overall percentile by averaging per-operation or per-window percentiles. Query the underlying matching measurements at the scope you intend to report.

### The voice experience is slow but HTTP looks healthy

Instrument the audio boundary before applying an HTTP target.

This sample measures non-streaming Chat and backend calls. Voice can involve separate connection, recognition, agent and audio-delivery timing. Use an actual supported signal for each boundary and the [voice connection guidance](/docs/api-reference/conversations-api/interact-socket#client-start) before creating a voice-specific service objective.
