Skip to content

Commit

Permalink
opentelemetry: Update otel to 0.17.0 (#1853)
Browse files Browse the repository at this point in the history
## Motivation

Support the latest OpenTelemetry specification.

## Solution

Update `opentelemetry` to the latest `0.17.x` release. Breaking changes
upstream in the tracking of parent contexts in otel's `SpanBuilder` have
necessitated a new `OtelData` struct to continue pairing tracing spans
with their associated otel `Context`.
# Conflicts:
#	.github/workflows/check_msrv.yml
#	tracing-opentelemetry/Cargo.toml
#	tracing-opentelemetry/benches/trace.rs
#	tracing-opentelemetry/src/layer.rs
#	tracing-opentelemetry/src/span_ext.rs
#	tracing-opentelemetry/tests/trace_state_propagation.rs
  • Loading branch information
jtescher authored and hawkw committed Feb 3, 2022
1 parent 3d96c0f commit 3bf5fc2
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 85 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: --all --exclude=tracing-appender
args: --all --exclude=tracing-appender --exclude=tracing-opentelemetry

# TODO: remove this once tracing's MSRV is bumped.
check-msrv-appender:
Expand All @@ -61,6 +61,23 @@ jobs:
command: check
args: --lib=tracing-appender

# TODO: remove this once tracing's MSRV is bumped.
check-msrv-opentelemetry:
# Run `cargo check` on our minimum supported Rust version (1.46.0).
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.46.0
profile: minimal
override: true
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --package=tracing-opentelemetry

check:
# Run `cargo check` first to ensure that the pushed code at least compiles.
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ inferno = "0.10.0"
tempfile = "3"

# opentelemetry example
opentelemetry = { version = "0.16", default-features = false, features = ["trace"] }
opentelemetry-jaeger = "0.15"
opentelemetry = { version = "0.17", default-features = false, features = ["trace"] }
opentelemetry-jaeger = "0.16"

# fmt examples
snafu = "0.6.10"
Expand Down
6 changes: 3 additions & 3 deletions tracing-opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ categories = [
keywords = ["tracing", "opentelemetry", "jaeger", "zipkin", "async"]
license = "MIT"
edition = "2018"
rust-version = "1.42.0"
rust-version = "1.46.0"

[features]
default = ["tracing-log"]

[dependencies]
opentelemetry = { version = "0.16", default-features = false, features = ["trace"] }
opentelemetry = { version = "0.17", default-features = false, features = ["trace"] }
tracing = { path = "../tracing", version = "0.1", default-features = false, features = ["std"] }
tracing-core = { path = "../tracing-core", version = "0.1" }
tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", default-features = false, features = ["registry", "std"] }
Expand All @@ -32,7 +32,7 @@ tracing-log = { path = "../tracing-log", version = "0.1", default-features = fal
[dev-dependencies]
async-trait = "0.1"
criterion = { version = "0.3", default_features = false }
opentelemetry-jaeger = "0.15"
opentelemetry-jaeger = "0.16"

[lib]
bench = false
Expand Down
6 changes: 3 additions & 3 deletions tracing-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ $ firefox http://localhost:16686/

## Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.42. The current Tracing version is not guaranteed to build on Rust
versions earlier than the minimum supported version.
Tracing Opentelemetry is built against the latest stable release. The minimum
supported version is 1.46. The current Tracing version is not guaranteed to
build on Rust versions earlier than the minimum supported version.

Tracing follows the same compiler support policies as the rest of the Tokio
project. The current stable Rust compiler and the three most recent minor
Expand Down
9 changes: 4 additions & 5 deletions tracing-opentelemetry/benches/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ fn many_children(c: &mut Criterion) {

group.bench_function("spec_baseline", |b| {
let provider = TracerProvider::default();
let tracer = provider.tracer("bench", None);
let tracer = provider.tracer("bench");
b.iter(|| {
fn dummy(tracer: &Tracer, cx: &Context) {
for _ in 0..99 {
tracer.start_with_context("child", cx.clone());
tracer.start_with_context("child", cx);
}
}

Expand All @@ -41,7 +41,7 @@ fn many_children(c: &mut Criterion) {

{
let provider = TracerProvider::default();
let tracer = provider.tracer("bench", None);
let tracer = provider.tracer("bench");
let otel_layer = tracing_opentelemetry::layer()
.with_tracer(tracer)
.with_tracked_inactivity(false);
Expand Down Expand Up @@ -96,8 +96,7 @@ where
let span = ctx.span(id).expect("Span not found, this is a bug");
let mut extensions = span.extensions_mut();
extensions.insert(
SpanBuilder::from_name(attrs.metadata().name().to_string())
.with_start_time(SystemTime::now()),
SpanBuilder::from_name(attrs.metadata().name()).with_start_time(SystemTime::now()),
);
}

Expand Down
Loading

0 comments on commit 3bf5fc2

Please sign in to comment.