MCPcopy Create free account
hub / github.com/dfinity/orbit / metrics

Method metrics

core/control-panel/impl/src/controllers/http.rs:82–107  ·  view source on GitHub ↗
(&self, request: HttpRequest)

Source from the content-addressed store, hash-verified

80 }
81
82 async fn metrics(&self, request: HttpRequest) -> HttpResponse {
83 if request.method.to_lowercase() != "get" {
84 return HttpResponse {
85 status_code: 405,
86 headers: vec![HeaderField("Allow".into(), "GET".into())],
87 body: "405 Method Not Allowed".as_bytes().to_owned(),
88 };
89 }
90
91 // Trigger active users metric update.
92 METRIC_ACTIVE_USERS.with(|metric| metric.borrow_mut().refresh(time()));
93
94 // Add dynamic metrics, dropped after the request since query calls don't save state changes.
95 with_metrics_registry(SERVICE_NAME, |registry| {
96 registry
97 .gauge_mut(
98 "canister_cycles_balance",
99 "cycles balance available to the canister",
100 )
101 .set(canister_balance() as f64);
102 });
103
104 with_metrics_registry(SERVICE_NAME, |registry| {
105 registry.export_metrics_as_http_response()
106 })
107 }
108}
109
110#[cfg(test)]

Callers 1

routerMethod · 0.45

Calls 7

timeFunction · 0.85
with_metrics_registryFunction · 0.85
canister_balanceFunction · 0.85
refreshMethod · 0.80
gauge_mutMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected