-
Notifications
You must be signed in to change notification settings - Fork 316
feat(go-client): Introduced Prometheus for go-client monitoring and added multiple metric collection sites #2285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ple metric collection sites.
There was a problem hiding this 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.
There was a problem hiding this 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!
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
Use go-client to invoke several interfaces, and the metrics were verified to be correctly reported on Prometheus monitoring services.
Code changes
Added metric collection for operation counts and latencies in
func (p *pegasusTableConnector) runPartitionOp
.Added RPC request size metric collection in
func (n *nodeSession) writeRequest
.Added a new field
enablePerfCounter
innodeSession
to distinguish between meta and replica nodes. Performance metrics are collected only for replica nodes. The constructor has been updated accordingly.The
Config
struct has been moved into a separate package to avoid circular dependencies.Related changes
Since the
Config
struct has been moved to a separate package, the example code has also been updated to reflect this change.