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

End-to-End Tracing for Financial Transactions: From One Transfer to Three Slow Calls

Financial transaction chains span many systems, making per-transaction debugging hard. This post covers propagating a unified Trace ID, tail-based sampling, and a label scheme that pinpoints slow calls in one pass.

Three Pain Points in Finance

The transaction chain is long: a single transfer flows from channel to core, payment, settlement, and reconciliation — across five or more systems, each of which may also call message queues, caches, and external payment channels. With that many hops, two things hurt most when something goes wrong: you don't know which hop is slow, and after digging around you find each system's logs don't line up with the same transaction. Compliance also demands that any issue be traceable to a single transaction, with an audit trail.

The Approach: One Trace ID Across the Chain

Generate a traceparent header at the gateway following the W3C Trace Context standard, and have every system propagate it untouched — nobody is allowed to modify it. At the same time, map the transaction ID to the trace ID at the entry point and store it as a label. When ops gets a transaction number, they reverse-look up the trace ID and see the entire call chain — this solves the "logs don't line up" problem at its root.

Sampling is layered three ways: normal transactions are sampled at 10%; slow transactions over 500ms are sampled at 100% (tail-based sampling); and errored transactions are always sampled. This keeps storage costs under control while guaranteeing that anything worth investigating has definitely been captured.

Key Configuration

Inject the same settings at the gateway and in every service:

trace:
  propagate: [traceparent, tracestate]
  sampling:
    default: 0.1
    tail:
      enabled: true
      latency_threshold: 500ms
    on_error: always

Pair this with Jujing's label scheme: txn_id (transaction ID), channel, amount (amount band), and product (product line) for filtering during investigations. Alerts reuse the same labels, so an alert like "payment channel P99 over threshold" links directly to concrete transaction samples.

Results and Recommendations

After rollout, a transfer is visible end to end from acceptance to completion, and it's obvious which hop is slow. One typical case: a payment channel's P99 latency sat at 1.2 seconds. The trace pinpointed retries caused by upstream timeouts; after switching to the backup channel, P99 dropped to 300ms — without opening a single log line.

Roll out in three steps: first wire up the core and payment systems (they carry ninety percent of transaction volume and show results fastest), then cover channels and reconciliation. Start sampling loose and tighten it once data volume is manageable. Finally, write the trace ID into business logs and response headers, so a customer report can be located from a single order number — saving a lot of back-and-forth.