feat: add prometheus and grafana #4

Merged
salmaelsoly merged 6 commits from developemnt_prometheus into development 2026-03-17 16:54:30 +00:00
Member

#2
image

#2 ![image](/attachments/72783b73-940d-485b-8c1a-aeea1e4d1368)
feat: integrate grafana
Some checks are pending
CI / test (push) Waiting to run
ec25fe2b61
feat: add health check endpoint
All checks were successful
CI / test (push) Successful in 1m26s
2ee16189c2
salmaelsoly force-pushed developemnt_prometheus from 2ee16189c2
All checks were successful
CI / test (push) Successful in 1m26s
to 1158f898af
All checks were successful
CI / test (push) Successful in 1m2s
2026-03-17 09:35:03 +00:00
Compare
salmaelsoly changed title from WIP: feat: add prometheus and grafana to feat: add prometheus and grafana 2026-03-17 09:55:24 +00:00
rawan requested changes 2026-03-17 12:46:39 +00:00
Dismissed
src/main.rs Outdated
@ -90,0 +117,4 @@
} else {
"connect_info"
};
state.metrics.record_source(source);
Member

record_source is called after IP resolution, so failed requests don't record a source. Source counts won't sum to total requests

is this the expected behaviour?

`record_source` is called after IP resolution, so failed requests don't record a source. Source counts won't sum to total requests is this the expected behaviour?
Author
Member

yes, record_source only makes sense when we actually have a valid IP to look up it increments total lookups but by source

 let lookup_source = Family::default();
        registry.register(
            "geoip_lookup_source",
            "Total lookups by IP source",
            lookup_source.clone(),
        );
yes, record_source only makes sense when we actually have a valid IP to look up it increments total lookups but by source ``` let lookup_source = Family::default(); registry.register( "geoip_lookup_source", "Total lookups by IP source", lookup_source.clone(), ); ```
src/metrics.rs Outdated
@ -0,0 +36,4 @@
pub requests: Family<RequestLabels, Counter>,
pub request_duration_seconds: Histogram,
pub lookup_errors: Family<ErrorLabels, Counter>,
pub lookup_source: Family<SourceLabels, Counter>,
Member

Access of these four variables goes through record_ methods
so these fields should be private to avoid direct access to them

Access of these four variables goes through record_ methods so these fields should be private to avoid direct access to them
salmaelsoly marked this conversation as resolved
src/metrics.rs Outdated
@ -0,0 +113,4 @@
/// Handler that renders all registered metrics in OpenMetrics text format.
pub async fn metrics_handler(State(state): State<super::AppState>) -> impl IntoResponse {
let mut buffer = String::new();
encode(&mut buffer, &state.metrics_registry).unwrap();
Member

can we avoid the use of unwrap to avoid panics? we can return internal server error instead if the encode fails

can we avoid the use of `unwrap` to avoid panics? we can return internal server error instead if the encode fails
salmaelsoly marked this conversation as resolved
fix: improve response header handling in rate limit middleware
All checks were successful
CI / test (push) Successful in 1m31s
a39c99237f
rawan approved these changes 2026-03-17 14:09:15 +00:00
salmaelsoly merged commit 92c8bf8e03 into development 2026-03-17 16:54:30 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_code/geoip!4
No description provided.