Skip to content

Conversation

nanorth
Copy link
Contributor

@nanorth nanorth commented Aug 13, 2025

What problem does this PR solve?

This PR introduces Prometheus for go-client monitoring, and adds multiple metric collection points to enhance observability of the system.

What is changed and how does it work?

This PR integrates the Prometheus client libraries (github.com/prometheus/client_golang and github.com/prometheus/client_model) as tools for metric instrumentation and data reporting.

Checklist

Tests
  • Manual test (add detailed scripts or steps below)
    Use go-client to invoke several interfaces, and the metrics were verified to be correctly reported on Prometheus monitoring services.
image
Code changes
  • Has exported function/method change
    Added metric collection for operation counts and latencies in func (p *pegasusTableConnector) runPartitionOp.
    Added RPC request size metric collection in func (n *nodeSession) writeRequest.
  • Has exported variable/fields change
    Added a new field enablePerfCounter in nodeSession to distinguish between meta and replica nodes. Performance metrics are collected only for replica nodes. The constructor has been updated accordingly.
  • Package structure change
    The Config struct has been moved into a separate package to avoid circular dependencies.
Related changes
  • Need to update the documentation
    Since the Config struct has been moved to a separate package, the example code has also been updated to reflect this change.

@nanorth nanorth changed the title feat: Introduced Prometheus and Falcon for monitoring and added multiple metric collection sites [WIP] feat: Introduced Prometheus and Falcon for monitoring and added multiple metric collection sites Aug 13, 2025
@nanorth nanorth changed the title [WIP] feat: Introduced Prometheus and Falcon for monitoring and added multiple metric collection sites [WIP] feat: Introduced Prometheus and Falcon for go-client monitoring and added multiple metric collection sites Aug 14, 2025
@nanorth nanorth changed the title [WIP] feat: Introduced Prometheus and Falcon for go-client monitoring and added multiple metric collection sites [WIP] feat(go-client): Introduced Prometheus and Falcon for go-client monitoring and added multiple metric collection sites Aug 18, 2025
@nanorth nanorth changed the title [WIP] feat(go-client): Introduced Prometheus and Falcon for go-client monitoring and added multiple metric collection sites [WIP] feat(go-client): Introduced Prometheus for go-client monitoring and added multiple metric collection sites Sep 1, 2025
@nanorth nanorth changed the title [WIP] feat(go-client): Introduced Prometheus for go-client monitoring and added multiple metric collection sites feat(go-client): Introduced Prometheus for go-client monitoring and added multiple metric collection sites Sep 1, 2025
@nanorth nanorth marked this pull request as ready for review September 1, 2025 07:50
@nanorth nanorth requested a review from acelyc111 September 1, 2025 07:53
@nanorth nanorth requested a review from acelyc111 September 9, 2025 08:26
@acelyc111 acelyc111 requested a review from Copilot September 19, 2025 06:29
Copy link

@Copilot 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 integrates Prometheus monitoring into the go-client by adding metric collection capabilities and refactoring the configuration structure to support observability features.

  • Adds Prometheus client libraries for metrics collection including operation counts, latencies, and RPC message sizes
  • Refactors configuration by moving the Config struct to a separate package to avoid circular dependencies
  • Introduces metrics collection at multiple points in the client execution flow

Reviewed Changes

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

Show a summary per file
File Description
go-client/session/session_test.go Updates test cases to include the new enableMetrics parameter in session constructors
go-client/session/session.go Adds metrics collection for RPC message sizes and updates function signatures to support metrics configuration
go-client/session/replica_session.go Updates replica manager to support metrics configuration through constructor parameters
go-client/session/meta_session.go Adds getter method for meta IP addresses and updates session creation to disable metrics for meta nodes
go-client/session/meta_call.go Updates meta session creation to disable metrics for new meta nodes
go-client/pegasus/table_connector_test.go Updates import and config usage to reference the new config package
go-client/pegasus/table_connector.go Adds comprehensive metrics collection for operation counts and latencies with detailed labeling
go-client/pegasus/config.go Removes the original Config struct (moved to separate package)
go-client/pegasus/client_test.go Updates all test cases to use the new config package
go-client/pegasus/client.go Integrates Prometheus initialization and updates client creation to support metrics configuration
go-client/metrics/prometheus_test.go Adds unit tests for concurrent metrics operations and singleton behavior
go-client/metrics/prometheus.go Implements the core Prometheus metrics functionality with thread-safe metric creation and collection
go-client/integration/failover-test/main.go Updates import to use the new config package
go-client/go.mod Adds Prometheus client dependencies and updates related package versions
go-client/example/pegasus-client-config.json Adds Prometheus configuration options to the example configuration
go-client/example/main.go Updates import to use the new config package
go-client/example/full_scan.md Updates documentation example to use the new config package
go-client/config/config.go Introduces the new configuration package with Prometheus support and option pattern
go-client/admin/remote_cmd_client.go Updates session creation to disable metrics for admin operations
go-client/admin/client_test.go Updates import to use the new config package
go-client/admin/client.go Fixes struct formatting in create table request

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nanorth nanorth requested a review from acelyc111 September 22, 2025 09:12
Copy link
Member

@acelyc111 acelyc111 left a comment

Choose a reason for hiding this comment

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

@nanorth Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants