-
Notifications
You must be signed in to change notification settings - Fork 510
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
feat: clean up lint.sh, use API to set grpc layer #467
feat: clean up lint.sh, use API to set grpc layer #467
Conversation
3bb9b97
to
cef5eea
Compare
IMO making features non-additive is frowned upon in the ecosystem. Perhaps we could do it as part of the tests to flush out issues in our test suite, but I don't think we should intentionally start doing this for our published libraries. |
I'm not super happy with this, either. If I understand correctly, the features are already mutually exclusive, though. At the moment we just silently ignore one of the features if the other one is enabled. I would prefer a helpful error message instead. That said, I'm still undecided if it would be better to configure these things at runtime. The scripts look fine to me. I think a trailing newline might be nice. I think that's common for shell scripts, too. |
I think the real problems I would like to solve is how do we tell user that featureA and featureB is exclusive and should only enable one of them. Some of our crates have complex features. For example, in
This basically comes down to four choices.
But I don't think it's trivial to understand how to choose between those features without some knowledge of the implementation. |
I made a change in hyper-rustls which removed the compiler error on feature conflict in favor of having the API be explicit about which feature to prefer. rustls/hyper-rustls@fc60b8c I think this is probably the best way to do it if possible, though I don't quite understand why the grpc vs tonic features (for example) necessarily/naturally conflict. |
Sorry those two are not mutually exclusive. 🤦♂️ Thanks for the example! I think it could be a good approach.
I think it's mostly because we have different ways to build the client based on different grpc layers. But I will try to poke around to see if we can use the API to separate those two features. |
Still need to add docs, change tests and fix small nits. But my general idea for this crate is to use an enum to represent different grpc layers. The reason for not using trait is that the trace exporter here has two tasks,
In our current implementation, If users want to bring their own grpc layer, they can just implement a new tracer exporter with SpanExporter trait and install it. |
9a350b6
to
b2a5540
Compare
… same time. As per open-telemetry#444 (comment). We should try to throw compile error when users set two exclusive features instead of default to use one of them.
The TracerExporter basically have two tasks. The first one is convert OTEL trace to binary, the second one is send it. `tonic` and `grpcio` take different approaches in both of those two tasks. Thus, we use enum here to represent two different grpc layers. If user want to bring their own grpc layer. They can just implement a new TracerExporter with SpanExporter trait and install it.
b2a5540
to
685c26b
Compare
I'm still on the fence between cargo features and setting things up at runtime. Since cargo doesn't have a way of describing that features are mutually exclusive, I'm leaning slightly towards the setup in Rust code at runtime. This looks quite nice to me. Didn't see anything worth commenting on. 👍 Do you want to update docs/tests/etc in this PR? |
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 the API-based approach works out pretty well, I especially like the builder setup.
#[cfg( | ||
not(feature = "integration-testing") | ||
)] |
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.
This looks a little odd?
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 the idea is to hide the proto mod unless we are running integrationt testing.
not(feature = "integration-testing") | ||
))] | ||
#[allow(clippy::all, unreachable_pub, dead_code)] | ||
#[allow(warnings)] |
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.
Why are we allowing all the warnings here? Maybe add a comment about this?
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.
Mostly because the proto mod only contains generated code. We should change it.
scripts/lint.sh
Outdated
cargo_feature opentelemetry-jaeger "reqwest_collector_client" | ||
cargo_feature opentelemetry-jaeger "collector_client" | ||
|
||
fi |
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.
Nit: add a newline?
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.
LGTM @djc is this good to merge or do you have additional feedback?
LGTM. @TommyCpp, good work! |
…nc feature is not set. This was introduced in open-telemetry#467. I believe the async feature was there to spin up a tokio runtime if the exporter was not already in one. It's mostly because the tonic cannot work without a tokio runtime. Renamed the feature to be less confusing. Also clean up all the clippy problems in metrics module and add some links into doc.
…nc feature is not set. This was introduced in open-telemetry#467. I believe the async feature was there to spin up a tokio runtime if the exporter was not already in one. It's mostly because the tonic cannot work without a tokio runtime. Renamed the feature to be less confusing. Also clean up all the clippy problems in metrics module and add some links into doc.
We should try to throw compile errors when users set two exclusive features instead of default to use one of them.
precommit.sh
to runfmt
,clippy
andtest
lint.sh
a little bit. Haven't worked with Bash for a while so please let me know if something doesn't look right.