Skip to content

Transaction lifecycle metrics#424

Merged
dimriou merged 6 commits intodevelopfrom
transaction_lifecycle_metrics
Apr 20, 2026
Merged

Transaction lifecycle metrics#424
dimriou merged 6 commits intodevelopfrom
transaction_lifecycle_metrics

Conversation

@dimriou
Copy link
Copy Markdown
Contributor

@dimriou dimriou commented Apr 16, 2026

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

⚠️ API Diff Results - github.com/smartcontractkit/chainlink-evm

⚠️ Breaking Changes (6)

pkg/transmitter (1)
  • NewOCRDualContractTransmitter — Type changed:
func(
  context.Context, 
  github.com/ethereum/go-ethereum/common.Address, 
  contractReader, 
  github.com/ethereum/go-ethereum/accounts/abi.ABI, 
  Transmitter, 
  github.com/smartcontractkit/chainlink-evm/pkg/logpoller.LogPoller, 
  github.com/smartcontractkit/chainlink-common/pkg/logger.Logger, 
  github.com/smartcontractkit/chainlink-evm/pkg/keys.Locker, 
  + *math/big.Int, 
  ...OCRTransmitterOption
)
(*dualContractTransmitter, error)
pkg/txm (2)
  • NewTxm — Type changed:
func(
  github.com/smartcontractkit/chainlink-common/pkg/logger.Logger, 
  *math/big.Int, 
  Client, 
  AttemptBuilder, 
  TxStore, 
  StuckTxDetector, 
  Config, 
  github.com/smartcontractkit/chainlink-evm/pkg/keys.AddressLister, 
  ErrorHandler, 
  + Metrics
)
*Txm
  • NewTxmMetrics — Type changed:
func(
  + github.com/smartcontractkit/chainlink-common/pkg/logger.Logger, 
  *math/big.Int
)
- (*txmMetrics, error)
+ Metrics
pkg/txm.Txm (1)
  • Metrics — 🗑️ Removed
pkg/txm/clientwrappers/dualbroadcast (2)
  • NewMetaClient — Type changed:
func(
  github.com/smartcontractkit/chainlink-common/pkg/logger.Logger, 
  MetaClientRPC, 
  MetaClientKeystore, 
  *net/url.URL, 
  *math/big.Int, 
  MetaClientTxStore, 
  *time.Duration, 
  + github.com/smartcontractkit/chainlink-evm/pkg/txm.Metrics
)
(*MetaClient, error)
  • SelectClient — Type changed:
func(
  github.com/smartcontractkit/chainlink-common/pkg/logger.Logger, 
  github.com/smartcontractkit/chainlink-evm/pkg/client.Client, 
  github.com/smartcontractkit/chainlink-evm/pkg/keys.ChainStore, 
  *net/url.URL, 
  *math/big.Int, 
  github.com/smartcontractkit/chainlink-evm/pkg/txm.TxStore, 
  bool, 
  *bool, 
  *time.Duration, 
  + github.com/smartcontractkit/chainlink-evm/pkg/txm.Metrics
)
(github.com/smartcontractkit/chainlink-evm/pkg/txm.Client, github.com/smartcontractkit/chainlink-evm/pkg/txm.ErrorHandler, error)

✅ Compatible Changes (10)

pkg/txm (10)
  • LifecycleFailureStage — ➕ Added

  • Metrics — ➕ Added

  • NewNoopTxmMetrics — ➕ Added

  • StageAuction — ➕ Added

  • StageBroadcast — ➕ Added

  • StageCreate — ➕ Added

  • StageCreatePrimary — ➕ Added

  • StageInFlightSubset — ➕ Added

  • StageMaxInFlight — ➕ Added

  • StageNonceAt — ➕ Added


📄 View full apidiff report

@dimriou dimriou marked this pull request as ready for review April 20, 2026 11:03
@dimriou dimriou requested a review from a team as a code owner April 20, 2026 11:03
Copilot AI review requested due to automatic review settings April 20, 2026 11:03
@dimriou dimriou requested review from a team as code owners April 20, 2026 11:03
Copy link
Copy Markdown
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 introduces transaction lifecycle metrics for TXMv2 by injecting a metrics recorder into TXM construction and surfacing lifecycle-failure counters across key broadcast/backfill and dual-broadcast paths.

Changes:

  • Add a txm.Metrics interface with a default implementation, a noop fallback, and a new lifecycle-failure counter with stage labels.
  • Thread metrics through TXM/dual-broadcast constructors and record lifecycle-failure increments at several failure/limit stages.
  • Update TXM unit/integration tests and OCR dual contract transmitter wiring to pass chain ID and metrics instances.

Reviewed changes

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

Show a summary per file
File Description
pkg/txmgr/builder.go Creates a TXM metrics instance and passes it into TXMv2 + dual-broadcast client selection.
pkg/txm/txm.go Injects metrics into Txm, records lifecycle failures, and switches TXM metrics init responsibility to callers.
pkg/txm/metrics.go Introduces Metrics interface, adds lifecycle-failure counter + stages, and provides noop metrics fallback.
pkg/txm/metrics_test.go Updates metrics tests for new constructor signature and adds noop metrics test.
pkg/txm/txm_test.go Updates TXM tests to pass noop metrics and removes direct mutation of tm.Metrics.
pkg/txm/integration-tests/integration_test.go Wires metrics into integration TXM setup.
pkg/txm/clientwrappers/dualbroadcast/selector.go Threads lifecycle metrics into meta-client construction.
pkg/txm/clientwrappers/dualbroadcast/meta_client.go Records auction-stage lifecycle failure on Meta send-request errors.
pkg/transmitter/util.go Passes chain ID into OCR dual contract transmitter construction.
pkg/transmitter/dual_contract_transmitter.go Creates lifecycle metrics and records create-stage failures for primary/secondary transmissions.
pkg/transmitter/dual_contract_transmitter_test.go Updates transmitter tests for the new chainID parameter.

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

Comment thread pkg/txm/txm.go
}
t.SetNonce(address, pendingNonce)
t.lggr.Debugf("Set initial nonce for address: %v to %d", address, pendingNonce)
t.lggr.Infof("Set initial nonce for address: %v to %d", address, pendingNonce)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

initializeNonce log level was changed from Debug to Info. Since this runs on every TXM start for every enabled address, this can noticeably increase log volume in production. Consider keeping this at Debug (or gating it behind a config / sampling) unless operators explicitly need it at Info.

Suggested change
t.lggr.Infof("Set initial nonce for address: %v to %d", address, pendingNonce)
t.lggr.Debugf("Set initial nonce for address: %v to %d", address, pendingNonce)

Copilot uses AI. Check for mistakes.
Comment thread pkg/txm/txm.go
Comment on lines 280 to 283
if unconfirmedCount > MaxInFlightTransactions {
t.metrics.IncrementLifecycleFailure(ctx, StageMaxInFlight)
t.lggr.Warnf("Reached transaction limit: %d for unconfirmed transactions", MaxInFlightTransactions)
return true, nil
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

New lifecycle-failure metric increments were added to core TXM control-flow branches (e.g., max-in-flight early returns). There are no unit tests asserting these counters are incremented for the relevant paths; since Metrics is now an interface, consider injecting a mock Metrics implementation in tests to verify the new instrumentation behaves as intended.

Copilot uses AI. Check for mistakes.
Comment on lines 200 to 202
a.metrics.emitAtlasError(ctx, "send_request", a.customURL, err, tx)
a.lifecycleMetrics.IncrementLifecycleFailure(ctx, txm.StageAuction)
return fmt.Errorf("error sending request for transactionID(%d): %w", tx.ID, errors.Join(err, ErrAuction))
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This new StageAuction lifecycle-failure increment isn’t covered by existing tests for MetaClient behavior. Consider adding a unit test for MetaClient.SendTransaction error paths that asserts the injected lifecycleMetrics is invoked (now that it’s a txm.Metrics interface).

Copilot uses AI. Check for mistakes.
@dimriou dimriou enabled auto-merge (squash) April 20, 2026 14:39
@dimriou dimriou merged commit 079df03 into develop Apr 20, 2026
41 of 43 checks passed
@dimriou dimriou deleted the transaction_lifecycle_metrics branch April 20, 2026 14:51
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.

4 participants