-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add support for OpenTelemetry 0.21 #118
Conversation
src/lib.rs
Outdated
|
||
#[cfg(all(feature = "opentelemetry_0_19", feature = "opentelemetry_0_20"))] | ||
compile_error!("feature \"opentelemetry_0_19\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time"); | ||
const _OTEL_GUARD: () = assert!({ |
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.
It breaks it.
I don't see the error while build
ing
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.
I think it's because compiler fails earlier than running/replacing consts.
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.
No, it's not runtime, const _: ()
forces compile-time evaluation of a const block here.
It might be a later compiler pass than checking import name clashes, so errors look different, but this will prevent compilation from working.
See https://internals.rust-lang.org/t/nicer-static-assertions/15986
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.
Anyway, compilation will fail, even if you remove this bit.
Having assert
is as useful as not having it. But compile_error
will be triggered earlier.
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.
Okay, I can revert this if that's your preference, however I don't think maintaining an ever-expanding and quite a bit error prone Cartesian cross-product of possible flag combinations is a good approach.
Ideally, there could be some macro that would take a feature list and then construct the cross product for us, but I'm unaware of such a macro and then whether it's at all possible as cfg!
and #[cfg(..)]
expression are a bit magical and might be evaluated earlier than any possible macro could kick in.
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.
If @LukeMathWalker agrees, we can use https://crates.io/crates/mutually_exclusive_features
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.
Happy to add the dependency!
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.
If @LukeMathWalker agrees, we can use https://crates.io/crates/mutually_exclusive_features
Cool, done. Is the @recurs [params: ...]
a common convention for recursive declarative macros BTW? Haven't seen it yet.
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.
I'm not sure how common it is. I learned that from diesel
macros, eg.
It's not just for recursion, they can there to make it rarely possible to being called from outside, and make internal calls in macros.
Like here, I used it, to name and extract a functionality of making comma separated list of items, with the comma_sep
name. (And yes, in this case we also have a recursion and an extra rule for the last element.)
And about the new changes, I think we need exactly one of the opentelemetry_*
features, no? I'm not sure. If so, then better to use exactly_one_of
macro.
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.
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.
Thanks!
Issue #, if available:
Description of changes:
Adds support for OpenTelemetry 0.21. Nothing particularly interesting. While here, getting rid of the Fibonacci-exploding number of compile guards and use a single const-evaluated expression.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.