Skip to content

Conversation

@jadepark-dev
Copy link
Collaborator

@jadepark-dev jadepark-dev commented Dec 8, 2025

This PR implements initial observability metrics for the TON LogPoller service, following the dual-write pattern established by TXM (Prometheus + OpenTelemetry/Beholder).

Primary Changes

Core Metrics Implementation (pkg/logpoller/metrics.go)

  • Poll Duration: Gauge tracking duration of each poll iteration
  • Poll Errors: Counter for poll iteration failures
  • Blocks Behind: Gauge showing latest_block - last_processed_block
  • Last Processed Block: Gauge with the last processed masterchain sequence number
  • Blocks Processed: Counter for total blocks processed
  • Logs Inserted: Counter for total logs inserted to database
  • Loader Errors: Counter for transaction loading failures
  • Parse Errors: Counter for log parsing failures

Database Query Metrics (Observed Stores)

  • Query Duration: Gauge tracking database operation latency by query type
  • Addresses Monitored: Gauge for number of addresses being monitored
  • Query Result Size: Gauge for rows returned by queries

Observed Store Wrappers

  • ObservedFilterStore: Wraps FilterStore with query duration and result metrics
  • ObservedLogStore: Wraps LogStore with insertion and query metrics

Breaking Changes

  • logpoller.NewService now returns (Service, error) to handle metric initialization errors

Others

@jadepark-dev jadepark-dev added the build-publish-docker Build and publish a Docker image to staging ECR label Dec 8, 2025
// TODO Consider move chainlink core AnyMsgSentEvent and CCIPSendReqConfig to CLDF?

// TonSendRequest is a simplified CCIP send request structure.
// Deprecated: Use router.CCIPSend directly with SendCCIPMessage for new code.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jadepark-dev jadepark-dev added build-publish-docker Build and publish a Docker image to staging ECR and removed build-publish-docker Build and publish a Docker image to staging ECR labels Dec 9, 2025
@jadepark-dev jadepark-dev marked this pull request as ready for review December 9, 2025 19:44
@jadepark-dev jadepark-dev requested a review from a team as a code owner December 9, 2025 19:44
Copilot AI review requested due to automatic review settings December 9, 2025 19:44
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 implements observability metrics for the TON LogPoller service, following the dual-write pattern (Prometheus + OpenTelemetry) used by the TXM service. The metrics cover core polling operations, database queries, and error tracking to enable monitoring of LogPoller health and performance.

Key Changes:

  • Added comprehensive metrics instrumentation to the LogPoller service including poll duration, blocks processed, logs inserted, and error counters
  • Implemented observed store wrappers (ObservedFilterStore, ObservedLogStore) that add metrics to database operations
  • Updated NewService to return (Service, error) for proper metric initialization error handling

Reviewed changes

Copilot reviewed 18 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/logpoller/metrics.go Defines Prometheus and OpenTelemetry metrics for LogPoller operations, database queries, and error tracking
pkg/logpoller/service.go Integrates metrics into the service, wraps stores with observed versions, updates signature to handle initialization errors
pkg/logpoller/observed_filter_store.go Wrapper for FilterStore that records query duration and result metrics
pkg/logpoller/observed_log_store.go Wrapper for LogStore that records insertion and query metrics
pkg/txm/metrics.go Renames internal types and methods for consistency (tonTxmMetrics → txmMetrics, GetOtelAttributes → getOtelAttributes)
pkg/txm/txm.go Updates to use renamed metrics types
pkg/relay/chain.go Updates NewService call to handle error return value
integration-tests/smoke/logpoller/log_poller_test.go Adds error handling for NewService calls
integration-tests/smoke/chainaccessor/accessor_test.go Adds error handling for NewService calls
integration-tests/deployment/ccip/cs_test.go Adds error handling for NewService calls
deployment/ccip/cs_test_helpers.go Removes deprecated SendTonRequest and TonSendRequest in favor of SendCCIPMessage
go.mod, staging-monitor/go.mod, integration-tests/go.mod, deployment/go.mod Adds chainlink-framework/metrics dependency and updates golang.org/x/* dependencies
go.md Updates dependency graph to include chainlink-framework/metrics
scripts/.core_version Updates core version reference
cmd/chainlink-ton/lock.nix Updates Nix lock hash

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

Copy link
Collaborator

@ogtownsend ogtownsend left a comment

Choose a reason for hiding this comment

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

lgtm

@jadepark-dev jadepark-dev merged commit f56790a into main Dec 11, 2025
35 checks passed
@jadepark-dev jadepark-dev deleted the jade/lp-metrics-base branch December 11, 2025 00:30
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.

2 participants