Skip to content

Commit 4a4cc80

Browse files
committed
Add /metrics endpoint
1 parent 0ff81d5 commit 4a4cc80

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/build-and-deploy-rust.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
run: |
4646
sleep 5
4747
48+
curl -f http://localhost:8080/metrics
49+
4850
# Put request with store='storeId' and key=k1
4951
hex=0A0773746F726549641A150A026B3110FFFFFFFFFFFFFFFFFF011A046B317631
5052
curl -f --data-binary "$(echo "$hex" | xxd -r -p)" http://localhost:8080/vss/putObjects

rust/server/src/vss_service.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ impl Service<Request<Incoming>> for VssService {
7979
let maximum_request_body_size = self.config.maximum_request_body_size;
8080

8181
Box::pin(async move {
82+
if path == "/metrics" {
83+
let response = b"# HELP vss_service_up Is the vss service up?\n# TYPE vss_service_up gauge\nvss_service_up 1\n";
84+
return Ok(Response::builder()
85+
.status(StatusCode::OK)
86+
.header("Content-Type", "text/plain; version=0.0.4")
87+
.header(PROTOCOL_VERSION_HEADER, PROTOCOL_VERSION.as_bytes())
88+
.body(Full::new(Bytes::from_static(response)))
89+
// unwrap safety: body only errors when previous chained calls failed.
90+
.unwrap());
91+
}
92+
8293
let prefix_stripped_path = path.strip_prefix(BASE_PATH_PREFIX).unwrap_or_default();
8394

8495
match prefix_stripped_path {

0 commit comments

Comments
 (0)