Skip to content

Conversation

@ogtownsend
Copy link
Collaborator

Adds:

  1. ton_txm_broadcast_latency_seconds
  2. ton_txm_confirmation_latency_seconds
  3. ton_txm_finalization_latency_seconds

@ogtownsend ogtownsend marked this pull request as ready for review December 19, 2025 17:27
@ogtownsend ogtownsend requested a review from a team as a code owner December 19, 2025 17:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive latency tracking metrics for transaction lifecycle stages in the TON transaction manager. The changes introduce three new timestamp fields to track when transactions are broadcast, confirmed, and finalized, along with corresponding Prometheus and OpenTelemetry metrics to measure the time intervals between these stages.

Key changes:

  • Added timestamp fields (BroadcastAt, ConfirmedAt, FinalizedAt) to the Tx struct to track transaction lifecycle events
  • Implemented three new latency metrics: broadcast latency (enqueue to broadcast), confirmation latency (broadcast to confirmation), and finalization latency (confirmation to finalization)
  • Integrated latency recording into the transaction broadcast and status checking logic

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/txm/tx.go Added three timestamp fields to track broadcast, confirmation, and finalization times
pkg/txm/metrics.go Defined new Prometheus and OpenTelemetry metrics for latency tracking and implemented recording methods
pkg/txm/txm.go Integrated latency recording at broadcast and status transition points

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jadepark-dev
jadepark-dev previously approved these changes Dec 23, 2025
Copy link
Collaborator

@jadepark-dev jadepark-dev left a comment

Choose a reason for hiding this comment

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

LGTM, left a few nit comments

}

// IsConfirmed checks if the message has reached a confirmed state, which we consider Received or Cascading.
func (m *ReceivedMessage) IsConfirmed() bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ReceivedMessage is already confirmed. It has already been included in a TX where it is the inMsg: it has been received.

pkg/txm/txm.go Outdated
t.logger.Debugf("Msg sequence diagram:\n%s\n", debug.NewDebuggerSequenceTrace(knownAddresses, sequenceDiagram.OutputFmtURL).DumpReceived(&receivedMessage))

// Track confirmation latency when first confirmed (Received or Cascading)
if tx.ConfirmedAt.IsZero() && receivedMessage.IsConfirmed() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The WaitForTrace() above already waits for the confirmation of every message in the trace. I am not sure this is the metric you want to take. If you want to measure the time it takes from us calling the rpc, to the external msg being delivered to the wallet, that is done here. If you want to measure the time between a message is enqueued (internal message contract-to-contract) and it gets delivered, that's going to be more challenging. You may want to use the timestamp of TXs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeaaaah, I don't think we need this ConfirmedAt metric, BroadcastAt and FinalizedAt give us what we care about most. Thanks for pointing this out, will remove

@ogtownsend ogtownsend force-pushed the ogt/add-txm-latency-metrics branch from 2c3724b to d9260fa Compare December 27, 2025 01:00
@ogtownsend
Copy link
Collaborator Author

@patricios-space this should be good for another pass 🙏

@ogtownsend ogtownsend merged commit 61bbbbd into main Jan 1, 2026
35 checks passed
@ogtownsend ogtownsend deleted the ogt/add-txm-latency-metrics branch January 1, 2026 21:10
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.

3 participants