diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 532693b3cf..353ecf6c45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,7 +102,7 @@ jobs: run: | cargo install cargo-check-external-types@0.1.13 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: diff --git a/opentelemetry-otlp/CHANGELOG.md b/opentelemetry-otlp/CHANGELOG.md index 4ad96907a7..28038d3b60 100644 --- a/opentelemetry-otlp/CHANGELOG.md +++ b/opentelemetry-otlp/CHANGELOG.md @@ -3,6 +3,8 @@ ## vNext - Update `tonic` dependency version to 0.13 +- Re-export `tonic` types under `tonic_types` + [2898](https://github.com/open-telemetry/opentelemetry-rust/pull/2898) ## 0.29.0 diff --git a/opentelemetry-otlp/allowed-external-types.toml b/opentelemetry-otlp/allowed-external-types.toml index 2412d22715..7995873ee8 100644 --- a/opentelemetry-otlp/allowed-external-types.toml +++ b/opentelemetry-otlp/allowed-external-types.toml @@ -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", ] diff --git a/opentelemetry-otlp/src/lib.rs b/opentelemetry-otlp/src/lib.rs index 7cb37a1780..86180e3e6f 100644 --- a/opentelemetry-otlp/src/lib.rs +++ b/opentelemetry-otlp/src/lib.rs @@ -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}; + } +}