-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Counter<u32, AtomicU32>
implementation
#206
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank you for the work!
Mind adding bumping the patch version in the root Cargo.toml
and writing a CHANGELOG.md
entry? I can then cut a new release right after merge.
I have more to come regarding 32-bit wide datatypes (this one was the uncontroversial low hanging fruit), so let’s not cut a release right now to cut on overhead. I’ll add a changelog though. |
Counter<u32, AtomicU32>
implementation
Interestingly there is a test compile fail on this one, that I had not seen before: error[E0277]: the trait bound `i32: EncodeCounterValue` is not satisfied
--> src/encoding/text.rs:890:29
|
890 | counter.metric_type(),
| ^^^^^^^^^^^ the trait `EncodeCounterValue` is not implemented for `i32`, which is required by `ConstCounte<{integer}>: EncodeMetric`
|
= help: the following other types implement trait `EncodeCounterValue`:
u32
u64
f64
note: required for `ConstCounter<i32>` to implement `EncodeMetric`
--> src/metrics/counter.rs:209:9
|
209 | impl<N> EncodeMetric for ConstCounter<N>
| ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
210 | where
211 | N: crate::encoding::EncodeCounterValue,
| ----------------------------------- unsatisfied trait bound introduced here
For more information about this error, try `rustc --explain E0277`.
error: could not compile `prometheus-client` (lib test) due to 1 previous error I suspect that it’s because integer literal will select the only available type when type inference is unambiguous (when there was only u64) but will default to i32 otherwise (see Rust Reference), and introducing u32 beside u64 makes it ambiguous. Will fix that. |
Signed-off-by: Léo Gillot-Lamure <leo.gillot@navaati.net>
Soooo… I’ve fixed it in the simplest way, but it raises several questions, as this innocent looking commit could actually be a breaking change x). Putting the PR as draft for now and let me share my analysis. First, let’s scope it: only So if we merge as is, it’s a hard breaking change (compilation fail) for anyone using Another solution is adding to this PR, before the current commit, a commit to support @mxinden what do you think ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the investigation.
I would prefer playing it safe and releasing it as a breaking change, i.e. a minor version bump (v0.23.0
). Given the widespread use of @dependabot, I don't think this creates too much work for downstream users.
I suggest calling out in the changelog entry, that this is a minor breaking change only.
Again, thank you for the work!
Hi. Aaaah, I hadn’t realized you were still in the 0.x.y phase, so it’s less disruptive that what I imagined indeed. And that’s a good thing, because I realized that my idea of adding a Ok so if we can go ahead and break a bit, I’ll prepare a series of commits in order to add all missing 32-bit support once and for all and break only once, after which we can cut a release. Thanks for your answer, now it’s clearer ! |
@navaati merge window for |
Hi, I see you merged #173, which I guess supersedes my PR (ugh, I would I saved time if I’d seen it…) ? At least it already introduces the breaking change of needing the |
Ok, got it ! Where I implemented Cool ! Let’s close this PR, superseded by #173. There might be some work left for actual |
This is useful for platforms that don’t support 64bit, such as a number of std-enabled networked MCUs.
I have unfortunately not been able to test the protobuf part, as I’m unable to build it (something about
protoc failed: google/protobuf/timestamp.proto: File not found.
). Hope CI will test it !