-
Notifications
You must be signed in to change notification settings - Fork 151
🔥 feat: Prometheus middleware #1610
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: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @gaby, 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 improves the Prometheus middleware by enabling it to accurately track and report metrics for HTTP HEAD requests. By aliasing HEAD requests to their GET counterparts, the middleware ensures that all relevant metrics, such as request counts, durations, and in-flight requests, are correctly captured. This provides a more robust and complete monitoring solution for applications using Fiber, ensuring no traffic goes unmeasured. Highlights
Ignored Files
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
|
|
/gemini review |
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.
Code Review
This pull request introduces a new Prometheus middleware for Fiber v3 and enhances it to correctly handle HEAD requests by aliasing them to GET routes for instrumentation. The implementation is robust and accompanied by a comprehensive test suite, which is excellent.
My review focuses on improving the usability and maintainability of the new middleware. I've provided two main points of feedback:
- A high-severity comment on the
README.mdto correct the usage example. The current example is misleading and would not instrument application routes as intended. I've suggested a corrected pattern that will help users adopt this middleware correctly. - A medium-severity comment in
config.gowith a suggestion to refactor the configuration initialization logic to reduce code duplication, improving maintainability.
Overall, this is a great contribution. Once the documentation is updated, this will be a very useful addition to the contrib repository.
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 introduces a new Prometheus middleware for Fiber v3 that provides comprehensive HTTP metrics collection and exposure. The middleware instruments incoming HTTP traffic and exposes metrics via a configurable endpoint.
Key Changes:
- Implements a Prometheus middleware that records request/response metrics including counters, histograms, and gauges
- Provides configurable options for custom registries, histogram buckets, OpenMetrics support, and selective metric filtering
- Includes comprehensive test coverage with 22 test cases covering various configuration scenarios
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| v3/prometheus/prometheus.go | Core middleware implementation with metrics collection, route tracking, and OpenTelemetry trace exemplar support |
| v3/prometheus/config.go | Configuration structure with default values and validation for middleware customization |
| v3/prometheus/prometheus_test.go | Comprehensive test suite covering all major features and edge cases |
| v3/prometheus/README.md | User documentation with usage examples and configuration options |
| v3/prometheus/go.mod | Module definition with dependency declarations |
| v3/prometheus/go.sum | Dependency checksums |
| .github/workflows/test-prometheus.yml | CI workflow for automated testing |
| v3/README.md | Updated to list the new prometheus middleware |
| README.md | Updated to list the new prometheus middleware |
| go.work | Added prometheus module to workspace |
💡 Add Copilot custom instructions for smarter, more guided reviews. 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.
Code Review
This pull request introduces a new Prometheus middleware for Fiber v3. The implementation is comprehensive, including a wide range of metrics, configuration options, and thorough tests. My review focuses on a critical issue in the documentation's usage example which would prevent the middleware from working as intended, and a suggestion to modernize the code in the configuration handling by using newer standard library packages for better readability.
Summary