ServicesPhoenix SearchOperate

API Debugging

Debug Phoenix Search requests from browser request to HyperDX trace and Elasticsearch query

👤 Sai Tharun

API Debugging

Phoenix Search is easiest to debug from the request trace. Start at the browser Network tab, copy the X-Trace-Id, open that trace in HyperDX, and inspect the API, auth/scope, and Elasticsearch spans for the same request.

Request-to-Trace Flow

StepWhere to CheckWhat to Look For
1Browser Network tabPOST https://phoenix-search-in.crelio.solutions/api/v1/users/search returns 200 or the actual failing status
2Response headersX-Trace-Id is present and can be copied into HyperDX
3HyperDX trace searchTrace opens for POST /api/v1/users/search
4Trace timelineAPI route, child spans, duration, and error count
5Elasticsearch spandb.system.name=elasticsearch, db.operation.name=search, db.operation.parameter.index=user_details, db.query.text, and db.response.status_code
6Phoenix Search attributessearch.lab_id, search.search_key, search.query_shape, search.routing, search.hit_count, and search.zero_results when emitted on the search span

This gives one debugging line from frontend request to backend search behavior. For a slow search, the trace shows whether time is spent in Phoenix Search code, MySQL scope/session work, Elasticsearch, or runtime/network overhead. For an empty search, the ES span and search attributes show the query shape and target index used by the real request.

Browser network request for Phoenix Search showing a successful search response and X-Trace-Id header

HyperDX Trace Timeline

Open the trace ID from the browser response in HyperDX. The trace timeline should show POST /api/v1/users/search, child spans, total duration, and error count.

Trace SignalHealthy Read
RoutePOST /api/v1/users/search
Error count0 for a successful search
Child spansAPI span plus dependency spans for search work
DurationCompare route duration with ES span duration to understand non-ES overhead
Trace IDSame value copied from X-Trace-Id
HyperDX trace timeline for POST /api/v1/users/search showing child spans and no trace errors

Elasticsearch Query Span

Open the Elasticsearch child span when the issue is search latency, empty results, wrong bucket ordering, or suspected query-shape behavior.

ES Span FieldWhy It Matters
db.operation.nameConfirms this span is an Elasticsearch search
db.operation.parameter.indexConfirms the request hit user_details
db.query.textShows the generated ES query body for the real user input
db.response.status_codeSeparates ES failures from API-level failures
Span durationShows raw ES time for the request
Trace correlationPhoenix Search also sends the active trace ID as Elasticsearch opaque_id
HyperDX Elasticsearch span details showing the user_details search operation and query body

Debugging Checklist

SymptomFirst CheckNext Check
Search is slowCompare API trace duration with ES span durationIf ES is fast, inspect auth/session, scope lookup, response shaping, and frontend network time
Search returns emptyInspect search.search_key, search.query_shape, search.routing, and db.query.textVerify lab scope and Elasticsearch routing by lab_id
Browser gets 401Check ephemeral token request and Phoenix Search auth span/logsConfirm token TTL, session_id, lab_id, and Redis session lookup
Browser gets 5xxUse X-Trace-Id to inspect the failed traceCheck search.app.errors.total, Sentry, and service logs for the same trace ID
Data looks staleCheck search.data.age and search.cdc.healthyThen follow the CDC runbook in Operations

On this page