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

Method export_metrics_as_http_response

libs/orbit-essentials/src/metrics.rs:194–219  ·  view source on GitHub ↗

Exports the metrics in the registry to an HTTP response.

(&self)

Source from the content-addressed store, hash-verified

192
193 /// Exports the metrics in the registry to an HTTP response.
194 pub fn export_metrics_as_http_response(&self) -> HttpResponse {
195 let metrics_result = self.export_metrics();
196
197 match metrics_result {
198 Ok(metrics) => HttpResponse {
199 status_code: 200,
200 headers: vec![HeaderField(
201 "Content-Type".to_string(),
202 "text/plain".to_string(),
203 )],
204 body: metrics,
205 },
206 Err(err) => {
207 print(format!("Error exporting metrics: {err:?}"));
208
209 HttpResponse {
210 status_code: 500,
211 headers: vec![HeaderField(
212 "Content-Type".to_string(),
213 "text/plain".to_string(),
214 )],
215 body: "500 Internal Server Error".as_bytes().to_owned(),
216 }
217 }
218 }
219 }
220}
221
222/// A trait for application metrics that can be recalculated and updated based on the current state of the application.

Callers 2

metricsMethod · 0.80
metricsMethod · 0.80

Calls 2

printFunction · 0.85
export_metricsMethod · 0.80

Tested by

no test coverage detected