Exports the metrics in the registry to a buffer in text format.
(&self)
| 179 | |
| 180 | /// Exports the metrics in the registry to a buffer in text format. |
| 181 | pub fn export_metrics(&self) -> Result<Vec<u8>, prometheus::Error> { |
| 182 | let mut buffer = vec![]; |
| 183 | let encoder = TextEncoder::new(); |
| 184 | |
| 185 | let registry = self.get_registry(); |
| 186 | let metrics_family = registry.gather(); |
| 187 | |
| 188 | encoder.encode(&metrics_family, &mut buffer)?; |
| 189 | |
| 190 | Ok(buffer) |
| 191 | } |
| 192 | |
| 193 | /// Exports the metrics in the registry to an HTTP response. |
| 194 | pub fn export_metrics_as_http_response(&self) -> HttpResponse { |