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

Method metrics

core/station/impl/src/controllers/http.rs:39–61  ·  view source on GitHub ↗
(&self, request: HttpRequest)

Source from the content-addressed store, hash-verified

37 }
38
39 async fn metrics(&self, request: HttpRequest) -> HttpResponse {
40 if request.method.to_lowercase() != "get" {
41 return HttpResponse {
42 status_code: 405,
43 headers: vec![HeaderField("Allow".into(), "GET".into())],
44 body: "405 Method Not Allowed".as_bytes().to_owned(),
45 };
46 }
47
48 // Add dynamic metrics, dropped after the request since query calls don't save state changes.
49 with_metrics_registry(SERVICE_NAME, |registry| {
50 registry
51 .gauge_mut(
52 "canister_cycles_balance",
53 "cycles balance available to the canister",
54 )
55 .set(canister_balance() as f64);
56 });
57
58 with_metrics_registry(SERVICE_NAME, |registry| {
59 registry.export_metrics_as_http_response()
60 })
61 }
62}

Callers 1

routerMethod · 0.45

Calls 5

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

Tested by

no test coverage detected