Skip to content

Commit ed29bd0

Browse files
committed
Update metrics
1 parent 9c81493 commit ed29bd0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

engine/src/server/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use crate::models::domain::Domain;
1717
use crate::models::site::Site;
1818
use crate::routes::error::HttpError;
1919
use crate::state::State;
20+
use opentelemetry::metrics::Meter;
21+
use opentelemetry::KeyValue;
2022

2123
const HTML_CACHE_SIZE_LIMIT: u64 = 1024 * 1024 * 5; // 5MB threshold
2224
const HTML_CACHE_FILE_EXTENSIONS: [&str; 6] = ["html", "htm", "json", "xml", "css", "svg"];
@@ -76,6 +78,17 @@ async fn resolve_http(request: &Request, state: Data<&State>) -> impl IntoRespon
7678
let path = raw_path.trim_start_matches('/').to_string();
7779
let state_ref = *state;
7880

81+
// Record metrics for domain and path
82+
let meter = global::meter("edgeserver");
83+
let request_counter = meter
84+
.u64_counter("http_requests_total")
85+
.with_description("Count of HTTP requests by domain and path")
86+
.build();
87+
request_counter.add(1, &[
88+
KeyValue::new("domain", host.to_string()),
89+
KeyValue::new("path", path.clone()),
90+
]);
91+
7992
info!("Router request at: {} {}", host, path);
8093

8194
// 1) domain -> Deployment

0 commit comments

Comments
 (0)