refactor(metrics): Add status_code for api_requests_by_status metric#135
Open
Sarthak1799 wants to merge 1 commit intomainfrom
Open
refactor(metrics): Add status_code for api_requests_by_status metric#135Sarthak1799 wants to merge 1 commit intomainfrom
Sarthak1799 wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request adds a third label "status_code" to the API request counter metric to enable more granular monitoring by HTTP status codes. The change allows tracking of specific HTTP response codes (200, 400, 404, 409, 500) alongside the existing endpoint and status labels.
- Updates the metric definition to include a "status_code" label
- Adds HTTP status codes to all API_REQUEST_COUNTER metric calls throughout the codebase
- Modifies one function to dynamically extract status codes from error responses
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/metrics.rs | Adds "status_code" as third label to API_REQUEST_COUNTER metric definition |
| src/routes/update_score.rs | Adds static status codes (200, 400) to metric calls and fixes import order |
| src/routes/update_gateway_score.rs | Adds static status codes (200, 400) to metric calls |
| src/routes/rule_configuration.rs | Adds status codes (200, 400, 404, 409, 500) to metric calls |
| src/routes/merchant_account_config.rs | Adds status codes (200, 404, 409, 500) to metric calls |
| src/routes/decision_gateway.rs | Adds status codes (200, 400) and dynamic status code extraction |
| src/routes/decide_gateway.rs | Adds static status codes (200, 400) to metric calls |
| src/euclid/handlers/routing_rules.rs | Adds status codes (200, 400, 404, 500) to metric calls |
Comment on lines
+208
to
+210
| let status_code = e.status.clone(); | ||
| API_REQUEST_COUNTER | ||
| .with_label_values(&["decision_gateway", "failure"]) | ||
| .with_label_values(&["decision_gateway", "failure", &status_code]) |
There was a problem hiding this comment.
The clone() operation on e.status is unnecessary since it's being used immediately as a string reference. Consider using &e.status instead of cloning.
jagan-jaya
requested changes
Aug 12, 2025
| logger::debug!(tag = "DecideGateway", "Error: {:?}", e); | ||
| metrics::API_REQUEST_COUNTER | ||
| .with_label_values(&["decide_gateway", "failure"]) | ||
| .with_label_values(&["decide_gateway", "failure", "400"]) |
Collaborator
There was a problem hiding this comment.
Suggested change
| .with_label_values(&["decide_gateway", "failure", "400"]) | |
| .with_label_values(&["decide_gateway", "failure", "500"]) |
isn't it 500?
| .with_label_values(&["update_gateway_score", "failure", "400"]) | ||
| .inc(); | ||
| timer.observe_duration(); | ||
| println!("Error: {:?}", e); |
Collaborator
There was a problem hiding this comment.
Suggested change
| println!("Error: {:?}", e); |
remove if not needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add status_code for api_requests_by_status metric