From 753b2439fafa64e9fd94e5a4165ca027c0c9b497 Mon Sep 17 00:00:00 2001 From: Ilmari Vacklin Date: Mon, 30 Aug 2021 14:14:06 +0300 Subject: [PATCH] Add support for OpenTelemetry 0.16 and tracing-opentelemetry 0.15 (#2) * add opentelemetry 0.16 * ci: run against otel 0.16 * ci: run jobs against each otel version * docs: mention opentelemetry_0_16 in README --- .github/workflows/ci.yml | 27 ++++++++++++++++++++++++--- reqwest-tracing/Cargo.toml | 3 +++ reqwest-tracing/README.md | 4 ++-- reqwest-tracing/src/lib.rs | 3 ++- reqwest-tracing/src/middleware.rs | 3 ++- reqwest-tracing/src/otel.rs | 6 ++++++ 6 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80639f7..0ebbdee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,13 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest + strategy: + matrix: + otel_version: + - opentelemetry_0_13 + - opentelemetry_0_14 + - opentelemetry_0_15 + - opentelemetry_0_16 steps: - name: Checkout repository uses: actions/checkout@v2 @@ -21,7 +28,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: test - args: --workspace --all-targets --features opentelemetry_0_15 + args: --workspace --all-targets --features ${{ matrix.otel_version }} rustfmt: name: Rustfmt @@ -45,6 +52,13 @@ jobs: clippy: name: Clippy runs-on: ubuntu-latest + strategy: + matrix: + otel_version: + - opentelemetry_0_13 + - opentelemetry_0_14 + - opentelemetry_0_15 + - opentelemetry_0_16 steps: - name: Checkout repository uses: actions/checkout@v2 @@ -59,11 +73,18 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: --all-targets --features opentelemetry_0_15 --workspace -- -D warnings + args: --all-targets --features ${{ matrix.otel_version }} --workspace -- -D warnings docs: name: Docs runs-on: ubuntu-latest + strategy: + matrix: + otel_version: + - opentelemetry_0_13 + - opentelemetry_0_14 + - opentelemetry_0_15 + - opentelemetry_0_16 steps: - name: Checkout repository uses: actions/checkout@v2 @@ -79,7 +100,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: doc - args: --no-deps --document-private-items --features opentelemetry_0_15 --workspace + args: --no-deps --document-private-items --features ${{ matrix.otel_version }} --workspace publish-check: name: Publish dry run diff --git a/reqwest-tracing/Cargo.toml b/reqwest-tracing/Cargo.toml index eb1017c..6d1893a 100644 --- a/reqwest-tracing/Cargo.toml +++ b/reqwest-tracing/Cargo.toml @@ -13,6 +13,7 @@ categories = ["web-programming::http-client"] opentelemetry_0_13 = ["opentelemetry_0_13_pkg", "tracing-opentelemetry_0_12_pkg"] opentelemetry_0_14 = ["opentelemetry_0_14_pkg", "tracing-opentelemetry_0_13_pkg"] opentelemetry_0_15 = ["opentelemetry_0_15_pkg", "tracing-opentelemetry_0_14_pkg"] +opentelemetry_0_16 = ["opentelemetry_0_16_pkg", "tracing-opentelemetry_0_15_pkg"] [dependencies] reqwest-middleware = { version = "0.1", path = "../reqwest-middleware" } @@ -26,9 +27,11 @@ truelayer-extensions = "0.1" opentelemetry_0_13_pkg = { package = "opentelemetry", version = "0.13", optional = true } opentelemetry_0_14_pkg = { package = "opentelemetry", version = "0.14", optional = true } opentelemetry_0_15_pkg = { package = "opentelemetry", version = "0.15", optional = true } +opentelemetry_0_16_pkg = { package = "opentelemetry", version = "0.16", optional = true } tracing-opentelemetry_0_12_pkg = { package = "tracing-opentelemetry",version = "0.12", optional = true } tracing-opentelemetry_0_13_pkg = { package = "tracing-opentelemetry", version = "0.13", optional = true } tracing-opentelemetry_0_14_pkg = { package = "tracing-opentelemetry",version = "0.14", optional = true } +tracing-opentelemetry_0_15_pkg = { package = "tracing-opentelemetry",version = "0.15", optional = true } [dev-dependencies] wiremock = "0.5" diff --git a/reqwest-tracing/README.md b/reqwest-tracing/README.md index e9e5468..7a1b4f6 100644 --- a/reqwest-tracing/README.md +++ b/reqwest-tracing/README.md @@ -49,10 +49,10 @@ an opentelemetry version feature: ```toml [dependencies] # ... -reqwest-tracing = { version = "0.1.0", features = ["opentelemetry_0_15"] } +reqwest-tracing = { version = "0.1.0", features = ["opentelemetry_0_16"] } ``` -Available opentelemetry features are `opentelemetry_0_15`, `opentelemetry_0_14` and +Available opentelemetry features are `opentelemetry_0_16`, `opentelemetry_0_15`, `opentelemetry_0_14` and `opentelemetry_0_13`. #### License diff --git a/reqwest-tracing/src/lib.rs b/reqwest-tracing/src/lib.rs index fc7887e..c17d90f 100644 --- a/reqwest-tracing/src/lib.rs +++ b/reqwest-tracing/src/lib.rs @@ -2,7 +2,8 @@ mod middleware; #[cfg(any( feature = "opentelemetry_0_13", feature = "opentelemetry_0_14", - feature = "opentelemetry_0_15" + feature = "opentelemetry_0_15", + feature = "opentelemetry_0_16", ))] mod otel; diff --git a/reqwest-tracing/src/middleware.rs b/reqwest-tracing/src/middleware.rs index 9cb65a8..da41302 100644 --- a/reqwest-tracing/src/middleware.rs +++ b/reqwest-tracing/src/middleware.rs @@ -43,7 +43,8 @@ impl Middleware for TracingMiddleware { #[cfg(any( feature = "opentelemetry_0_13", feature = "opentelemetry_0_14", - feature = "opentelemetry_0_15" + feature = "opentelemetry_0_15", + feature = "opentelemetry_0_16", ))] let req = crate::otel::inject_opentracing_context_into_request(&request_span, req); diff --git a/reqwest-tracing/src/otel.rs b/reqwest-tracing/src/otel.rs index aa9c688..5a71a17 100644 --- a/reqwest-tracing/src/otel.rs +++ b/reqwest-tracing/src/otel.rs @@ -12,6 +12,9 @@ use opentelemetry_0_14_pkg as opentelemetry; #[cfg(feature = "opentelemetry_0_15")] use opentelemetry_0_15_pkg as opentelemetry; +#[cfg(feature = "opentelemetry_0_16")] +use opentelemetry_0_16_pkg as opentelemetry; + #[cfg(feature = "opentelemetry_0_13")] pub use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry; @@ -21,6 +24,9 @@ pub use tracing_opentelemetry_0_13_pkg as tracing_opentelemetry; #[cfg(feature = "opentelemetry_0_15")] pub use tracing_opentelemetry_0_14_pkg as tracing_opentelemetry; +#[cfg(feature = "opentelemetry_0_16")] +pub use tracing_opentelemetry_0_15_pkg as tracing_opentelemetry; + use opentelemetry::global; use opentelemetry::propagation::Injector; use tracing_opentelemetry::OpenTelemetrySpanExt;