feat(keeper): support metrics v2 interface, which is memory mode.#34665
feat(keeper): support metrics v2 interface, which is memory mode.#34665sheyanjie-qq wants to merge 2 commits intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the metrics collection and exposure capabilities by introducing a new 'metrics v2' interface. This new approach leverages an in-memory cache to store and serve frequently requested metrics, thereby reducing database overhead and improving response times. It also integrates real-time performance schema queries for critical insights, making the monitoring system more robust and efficient. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant feature: a v2 metrics interface that uses an in-memory cache for improved performance. The implementation is comprehensive, including data ingestion middleware, a metric parser, an in-memory store, and a new Prometheus collector, all accompanied by extensive tests. My review focuses on enhancing robustness, performance, and configurability. Key suggestions include replacing a fragile time.Sleep with a more reliable synchronization mechanism, making cache settings configurable, and optimizing string handling and type conversions for better performance and safety.
Note: Security Review did not run due to the size of the PR.
There was a problem hiding this comment.
Pull request overview
Adds a new “metrics v2” path that serves Prometheus metrics from an in-memory cache (populated from incoming metric POSTs) and augments it with real-time performance_schema query metrics.
Changes:
- Introduces an in-memory metric store + Prometheus collector to expose cached metrics via
/metrics/v2. - Adds request middleware + parser to synchronously cache selected POST payloads (
/general-metric,/taosd-cluster-basic,/adapter_report, etc.), with a config option to re-include default-excluded tables. - Adds a performance_schema collector to
/metrics/v2, plus gzip support in the HTTP server.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/keeper/system/program.go | Enables gzip and wires up v2 memory cache + middleware; updates NodeExporter construction. |
| tools/keeper/system/program.go | Adds global gzip middleware and v2 memory-mode initialization. |
| tools/keeper/process/memory_store.go | New in-memory metric storage with TTL cleanup and stats. |
| tools/keeper/process/memory_store_test.go | Unit tests for MemoryStore behavior. |
| tools/keeper/process/memory_collector.go | New Prometheus collector that emits metrics from MemoryStore. |
| tools/keeper/process/memory_collector_test.go | Tests for MemoryStoreCollector behavior. |
| tools/keeper/infrastructure/config/metrics.go | Adds metrics.includeTables config/env/flag for v2 cache inclusion. |
| tools/keeper/api/metric_middleware.go | New Gin middleware to intercept metric POSTs and cache them. |
| tools/keeper/api/metric_middleware_test.go | Tests for caching middleware path/method behavior. |
| tools/keeper/api/metric_parser.go | New parser that filters tables and stores metrics into MemoryStore. |
| tools/keeper/api/metric_parser_test.go | Parser tests for multiple endpoints and include/exclude behavior. |
| tools/keeper/api/nodeexporter.go | Adds /metrics/v2 endpoint and registers memory + perf collectors. |
| tools/keeper/api/performance_collector.go | New collector querying performance_schema.perf_queries for slow-query counts. |
| tools/keeper/api/performance_collector_test.go | Tests for performance collector Describe and toInt64. |
| tools/keeper/api/v2_integration_test.go | End-to-end tests for v2: cache -> collector -> promhttp output. |
| tools/keeper/api/exporter_test.go | Updates NodeExporter constructor usage for new v2 dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
68730c3 to
39c9c1e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 12 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0d42dbb to
9f81f32
Compare
9f81f32 to
a5d5a25
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
support metrics v2 interface, which is memory mode.
Issue(s)
Checklist
Please check the items in the checklist if applicable.