Skip to content

feat(otlp): Re-export tonic crate #2898

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
run: |
cargo install [email protected]
cd ${{ matrix.example }}
cargo check-external-types --config allowed-external-types.toml
cargo check-external-types --all-features --config allowed-external-types.toml
msrv:
strategy:
matrix:
Expand Down
16 changes: 6 additions & 10 deletions opentelemetry-otlp/allowed-external-types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
# This is used with cargo-check-external-types to reduce the surface area of downstream crates from
# the public API. Ideally this can have a few exceptions as possible.
allowed_external_types = [
"opentelemetry::*",
"opentelemetry_http::*",
"opentelemetry_sdk::*",
# http is a pre 1.0 crate
"http::uri::InvalidUri",
"http::header::name::InvalidHeaderName",
"http::header::value::InvalidHeaderValue",
# prost is a pre 1.0 crate
"prost::error::EncodeError",
# serde
"serde::de::Deserialize",
"serde::ser::Serialize",
# tonic is a pre 1.0 crate
"tonic::status::Code",
"tonic::status::Status",
"tonic::metadata::map::MetadataMap",
"tonic::transport::channel::tls::ClientTlsConfig",
"tonic::transport::tls::Certificate",
"tonic::transport::tls::Identity",
"tonic::transport::channel::Channel",
"tonic::transport::error::Error",
"tonic::service::interceptor::Interceptor",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that all of these should be reexported and removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bantonsson, thanks for the review!
The added types are the ones now re-exported.
I also updated the CI script to check allowed external types with all features enabled, because the previous configuration was correct but wasn't actually enforced (some re-exported types are feature-gated).
I've also cleaned up the old types that are no longer re-exported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @MathieuTricoire. Didn't know how that plugin works.

]
17 changes: 17 additions & 0 deletions opentelemetry-otlp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,20 @@ pub enum Protocol {
#[doc(hidden)]
/// Placeholder type when no exporter pipeline has been configured in telemetry pipeline.
pub struct NoExporterConfig(());

/// Re-exported types from the `tonic` crate.
#[cfg(feature = "grpc-tonic")]
pub mod tonic_types {
/// Re-exported types from `tonic::metadata`.
pub mod metadata {
#[doc(no_inline)]
pub use tonic::metadata::MetadataMap;
}

/// Re-exported types from `tonic::transport`.
#[cfg(feature = "tls")]
pub mod transport {
#[doc(no_inline)]
pub use tonic::transport::{Certificate, ClientTlsConfig, Identity};
}
}