chore: Integrate prometheus for metrics WPB-21843#46
Conversation
- Refactor KtorInstallation.kt to have better readability.
- Update dependency injection
PR Review: Prometheus Metrics IntegrationThanks for implementing metrics tracking! This is a solid foundation for monitoring Poll App usage. Here's my detailed review: ✅ Strengths
🔍 Code Quality & Best Practices1. Missing Metrics for Key Operations (Priority: Medium)You're tracking
Recommendation: Add metrics for these commands to get a complete picture of usage patterns. 2. Metric Naming Convention (Priority: Low)Your metric names follow Prometheus conventions well (
3. Code Organization in KtorInstallation.kt (Priority: Low)The refactoring into separate functions (
Current: fun Application.setupHealthEndpoint() {
routing { get("/health") { ... } }
}
fun Application.setupMetrics() {
install(MicrometerMetrics) { ... }
routing { get("/metrics") { ... } }
}Suggested: fun Application.setupRouting() {
routing {
get("/health") { call.response.status(HttpStatusCode.OK) }
get("/metrics") {
val prometheusRegistry by closestDI().instance<PrometheusMeterRegistry>()
call.respond(prometheusRegistry.scrape())
}
}
}🐛 Potential Issues1. ServiceMonitor Port Reference (Priority: High)In
Action: Please verify the Deployment has 2. No Error Handling in Metrics Endpoint (Priority: Medium)The 🔒 Security Considerations
⚡ Performance Considerations
🧪 Test CoverageExcellent work here! The test updates are thorough:
Minor suggestion: Consider adding a dedicated test for
📝 Additional Recommendations
🎯 SummaryThis is a well-implemented PR that adds valuable observability to the Poll App. The code quality is good, tests are comprehensive, and the integration is clean. Required before merge:
Recommended improvements:
Approval Status: Approved with minor recommendations Great work! 🎉 Review generated with assistance from Claude Code |
| import io.micrometer.core.instrument.Counter | ||
| import io.micrometer.core.instrument.MeterRegistry | ||
|
|
||
| class UsageMetrics( |
There was a problem hiding this comment.
Also add a counter for buttons being clicked ? Differentiate between a Delete button and clicking on an option
There was a problem hiding this comment.
@spoonman01
For now, I am adding the very basic custom metrics of basic actions user take.
Regarding voting action: I thought about it but then I was not convinced about the benefit of it. Because people will vote they can change the vote and this means another voting action. So the metric will not show sth very clear. --> Maybe later we can find more meaningful reason for that. Wdyt?
Regarding delete poll: At the moment we don't have Delete functionality, but actually I can add the metric now, so it can be used when the feature implemented.
There was a problem hiding this comment.
📣 Custom metric for "delete poll" is added although we don't have the functionality yet. Maybe this is not a good proactice to add unneeded things but since we are introducing the custom metrics first time in this app, I just wanted to make it ready from now.
There was a problem hiding this comment.
You are right it's total votes and not by person, still better than nothing I think.
I will leave the decision to you
There was a problem hiding this comment.
I prefer not adding a metric for voting for now. Because it will not tell us anything meaningful. We can send metrics with the information of the pool itself (such as poll-id) but then it will be out of the purpose of metrics. Metrics are for general overview not for every instance of polls created.
Also just to keep here updated: I reverted the "delete poll" as we agreed as a team.
| } | ||
|
|
||
| routing { | ||
| get("/metrics") { |
There was a problem hiding this comment.
This is good, apart from the business metrics you have defined, does the /metrics now export JVM or server data?
There was a problem hiding this comment.
Yes, this automatically emits JVM and system metrics (https://micrometer.io/docs/ref/jvm) and also http metrics.
Some more info:
Also: https://chatgpt.com/s/t_6926c4491864819181ee50f4b42ec07d
There was a problem hiding this comment.
This is how they look.
There was a problem hiding this comment.
Very nice. If it's easy then as a test could you try to setup the full micrometer dashboard, just for this service? Not building it by hand, there should be some pre-made things in Grafana https://grafana.com/grafana/dashboards/4701-jvm-micrometer/
Pull Request Review - PR #46: Integrate Prometheus for MetricsSummaryThis PR integrates Prometheus metrics into the Poll App to track command usage. The implementation is generally solid with good test coverage, but there are several areas that could be improved. ✅ Strengths
🔍 Code Quality & Best Practices1. Unused Metric Counter
|
This reverts commit a1b9a54.
Pull Request Review: Prometheus Metrics IntegrationThank you for adding Prometheus metrics to the Poll App! This is a valuable addition for monitoring usage. Here's my detailed review: ✅ Positive Aspects
🔍 Issues and Recommendations1. Critical: Missing Metrics for Vote Actions
|
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764The PR Description
What's new in this PR?
Issues
We need usage stats for Poll App. So that we can know which command is called how many times.
Solutions
Integrate Prometheus metrics and add some basic usage stats metrics for some commands.
How to Test
Locally -> Run the application and send command on staging. Then verify the metrics with their counts from http://localhost:8080/metrics
Stating -> After the deployment on staging, we should see the metrics on Grafana if all the K8s related additions are correct.
Attachments (Optional)
Here is the sample output can be seen from http://localhost:8080/metrics
