metrics-rs / metrics

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

Example in metrics docs does not work with latest released metrics-macros #315

Closed danielnelson closed 2 years ago

danielnelson commented 2 years ago

This issue is a bit of a nag, sorry if you are already aware of it.

The docs for the new metrics-0.20.0 show an example for describe_counter:

describe_counter!("some_metric_name", "my favorite counter");

But after updating I tried to compile:

error[E0308]: mismatched types
 --> examples/describe.rs:4:45
  |
4 |     describe_counter!("requests_processed", "number of requests processed");
  |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `metrics::cow::Cow`, found `&str`
  |
  = note: expected struct `metrics::cow::Cow<'static, str>`
          found reference `&'static str`

In order for this to work, I believe there needs to be a new release of metrics-macros with the changes from #312.

In the meantime, this works okay:

describe_counter!("some_metric_name", "my favorite counter".into());
tobz commented 2 years ago

Dangit! Nope, not a nag at all. I missed the fact I needed to cut a release of metrics-macros.

Good eye and thank you for reporting. 👍🏻

tobz commented 2 years ago

Alright, released metrics-macros@v0.6.0 which includes the changes related to SharedString, and released metrics@v0.20.1 which correctly uses that new version. Likewise, I yanked metrics@v0.20.0 to avoid users picking up that broken version going forward.

Thank you again for spotting and reporting this so quickly. ❤️