From 362076ee742c810ea8ccb28f415fd90e0b8171c3 Mon Sep 17 00:00:00 2001 From: Asmir Avdicevic Date: Mon, 4 Nov 2024 12:29:28 +0100 Subject: [PATCH] fix(metrics): allow external crates to encode their metrics (#2885) ## Description Allows external crates to easily encode metrics. ## Breaking Changes ## Notes & open questions ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented. --- iroh-metrics/src/core.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iroh-metrics/src/core.rs b/iroh-metrics/src/core.rs index c1218a7af1..ca7168548c 100644 --- a/iroh-metrics/src/core.rs +++ b/iroh-metrics/src/core.rs @@ -183,8 +183,10 @@ impl Core { self.metrics_map.get::() } + /// Encodes the current metrics registry to a string in + /// the prometheus text exposition format. #[cfg(feature = "metrics")] - pub(crate) fn encode(&self) -> Result { + pub fn encode(&self) -> Result { let mut buf = String::new(); encode(&mut buf, &self.registry)?; Ok(buf)