From 6aaff99142ec7f9e120cd933085cdc8feb9ff3a2 Mon Sep 17 00:00:00 2001 From: Harold Dost Date: Wed, 6 Mar 2024 09:46:43 +0100 Subject: [PATCH] Add External Type Checking The purpose of this is to ensure we understand the API surface area. Anything exposed by a crate like a type can affect the possible compatibility. This means that if we bump an external type it could cause breaking changes. This tracks them to limit this possibility. Affected Crates: - opentelemetry-otlp - opentelemetry-zipkin --- .github/workflows/ci.yml | 2 +- .../allowed-external-types.toml | 22 +++++++++++++++++++ .../allowed-external-types.toml | 12 ++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 opentelemetry-otlp/allowed-external-types.toml create mode 100644 opentelemetry-zipkin/allowed-external-types.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96d9cc285b..3a7c891c42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: external-types: strategy: matrix: - example: [opentelemetry, opentelemetry-sdk] + example: [opentelemetry, opentelemetry-sdk, opentelemetry-otlp, opentelemetry-zipkin] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/opentelemetry-otlp/allowed-external-types.toml b/opentelemetry-otlp/allowed-external-types.toml new file mode 100644 index 0000000000..2412d22715 --- /dev/null +++ b/opentelemetry-otlp/allowed-external-types.toml @@ -0,0 +1,22 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 +# 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", + # tonic is a pre 1.0 crate + "tonic::status::Code", + "tonic::status::Status", + "tonic::metadata::map::MetadataMap", + "tonic::transport::channel::Channel", + "tonic::transport::error::Error", + "tonic::service::interceptor::Interceptor", +] diff --git a/opentelemetry-zipkin/allowed-external-types.toml b/opentelemetry-zipkin/allowed-external-types.toml new file mode 100644 index 0000000000..d27d242006 --- /dev/null +++ b/opentelemetry-zipkin/allowed-external-types.toml @@ -0,0 +1,12 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 +# 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::error::Error", + "http::uri::InvalidUri", +]