metrics-rs / metrics

A metrics ecosystem for Rust.
MIT License
1.1k stars 151 forks source link

From<std::borrow::Cow> for KeyName #377

Closed mooso closed 1 year ago

mooso commented 1 year ago

We have a use case to have semi-dynamic names for some metrics, and it'd be great if KeyName could impl From<std::borrow::Cow> so that we construct the key name once (at runtime) and then cheaply emit metrics using that without reallocating every time. Unless I'm missing something that should be easy enough since SharedString (the crate's Cow) already has impl From<std::borrow::Cow<'static, str>>. Will be happy to craft a PR for this unless I hear objections. Thanks!

tobz commented 1 year ago

Hmm, weird. Surprised I never added that impl. 🤔

Feel free to craft a PR. 👍🏻

tobz commented 1 year ago

Closed via #378, released via metrics@v0.21.1.