MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / metrics

Function metrics

guest-agent/src/http_routes.rs:86–101  ·  view source on GitHub ↗
(state: &State<AppState>)

Source from the content-addressed store, hash-verified

84// Returns metrics about the guest in prometheus format if public_sysinfo is enabled
85#[get("/metrics")]
86async fn metrics(state: &State<AppState>) -> Result<String, String> {
87 let public_sysinfo = state.config().app_compose.public_sysinfo;
88 if !public_sysinfo {
89 return Err("Sysinfo API is disabled".to_string());
90 }
91 let context = CallContext::builder().state(&**state).build();
92 let handler = GuestApiHandler::construct(context.clone())
93 .map_err(|e| format!("Failed to construct RPC handler: {}", e))?;
94
95 let system_info = handler.sys_info().await.unwrap_or_default();
96 let model = crate::models::Metrics { system_info };
97 match model.render() {
98 Ok(body) => Ok(body),
99 Err(err) => Err(format!("Failed to render template: {err}")),
100 }
101}
102
103#[get("/logs/<container_name>?<since>&<until>&<follow>&<text>&<timestamps>&<bare>&<tail>&<ansi>")]
104#[allow(clippy::too_many_arguments)]

Callers

nothing calls this directly

Calls 5

cloneMethod · 0.80
renderMethod · 0.80
configMethod · 0.45
buildMethod · 0.45
sys_infoMethod · 0.45

Tested by

no test coverage detected