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
This commit is contained in:
Ilmari Vacklin 2021-08-30 14:14:06 +03:00 committed by GitHub
parent 7fe55152ec
commit 753b2439fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 7 deletions

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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;