← Back to blog
Solution 4 min read 炬鲸团队

Distributed Tracing for Financial Transactions: Finding the Slow Hop

Why is one order slow? A real case of locating a transaction latency bottleneck with distributed tracing, including instrumentation rules, a sampling strategy for financial workloads and P99 alerting advice that found the root cause in under 30 minutes.

Why is one order slow

The classic question in financial systems: a user says "checkout is slow", but slow where? The gateway? Risk control? Accounts? Clearing? The database? Without tracing you guess layer by layer from logs, and a single chain crossing a dozen services costs half a day of manual work.

Distributed tracing turns one transaction into a chain of per-hop timings, so you see at a glance where the bottleneck sits — and, just as importantly, where it doesn't.

Metrics that matter in trading

Finance demands more from observability than a typical web service:

  • Latency: not averages, but P99/P999 percentiles. Averages hide the rare slow requests that ruin a handful of users — and in trading, those users are often your largest.
  • Success rate: order success and payment success, broken down by channel and card type.
  • Correlation: a transaction must be linkable to a specific user, order id and merchant id, so you can work backwards from a complaint.

Observe lets you attach business tags to spans (order_id, user_id, merchant_id), tying technical traces to business entities. This is what turns "some request was slow" into "order 884213 from merchant 7 stalled in risk control".

Golden signals to watch first

Before digging into any single transaction, check four signals per service: latency (P99), traffic (requests per second), errors (rate), and saturation (queue depth, connection-pool usage). Together they usually tell you which service to zoom into. In the case below, the first thing that looked wrong was a latency spike at 14:00 with a flat error rate — a pattern that pointed at a resource bottleneck rather than a code bug.

Once you've picked the service, tracing takes over. Sort spans by duration to find the long poles, then diff a slow trace against a normal one. The span that is dramatically longer in the slow trace is almost always where the time is going; everything downstream of it is usually just waiting on that one call.

A real failure, located

A real trading team's incident (anonymized):

Symptom: "order success rate drops one point around 14:00 every day." Monitoring shows P99 latency at 14:00 jumping from 300ms to 4s, but only on certain channels.

How they found it:

  1. Filter traces around 14:00 and select transactions with success=false.
  2. Compare span durations between slow and normal transactions — the slow ones all stall on the "risk-control query" span, taking 3.5s.
  3. Follow that into the risk-control service logs and find a cron job at 14:00 refreshing the cache, saturating the connection pool.
  4. Move the cron job to the early morning. Problem gone.

From "something is wrong" to root cause took under 30 minutes, because every span's duration and error status was recorded in the trace. Without tracing, step 2 — knowing the stall was in risk control, not the gateway or the database — would have been a day of log archaeology.

Instrumentation that pays off

  1. Instrument every hop: gateway, RPC framework, DB, MQ, cache, third-party APIs — each jump needs a span. A missing hop is a blind spot in the middle of your chain.
  2. Carry business IDs: put order_id and user_id into span attributes, not just technical fields.
  3. Mark errors properly: write the exception type and stack into span events on failure, rather than only logging a line.
  4. Sample with intent: full capture is expensive, but financial transactions can't afford 1% sampling. Capture 100% of success=false transactions and sample successful ones at 10%.

Advice for trading teams

  • Stop reading averages; P99 is the truth of user experience, and P999 is the truth of your worst case.
  • Write the trace id into business logs and support tickets, so a user complaint maps straight to their transaction.
  • Build dedicated dashboards for the core paths (order, payment, clearing) and set P1 thresholds on P99, not averages.