Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opentelemetry: Update otel to 0.17.0 #1853

Merged
merged 7 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/check_msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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,3 +61,20 @@ jobs:
with:
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
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.2", default-features = false, features = ["std"] }
tracing-core = { path = "../tracing-core", version = "0.2" }
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.2", 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this be

Suggested change
Tracing Opentelemetry is built against the latest stable release. The minimum
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::subscriber()
.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
12 changes: 12 additions & 0 deletions tracing-opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ mod tracer;
pub use span_ext::OpenTelemetrySpanExt;
pub use subscriber::{subscriber, OpenTelemetrySubscriber};
pub use tracer::PreSampledTracer;

/// Per-span OpenTelemetry data tracked by this crate.
///
/// Useful for implementing [PreSampledTracer] in alternate otel SDKs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
/// Useful for implementing [PreSampledTracer] in alternate otel SDKs.
/// Useful for implementing [`PreSampledTracer`] in alternate otel SDKs.

#[derive(Debug, Clone)]
pub struct OtelData {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct that this needs to be public because it's used in the PreSampledTracer trait, but it's totally opaque to user code? Is there any reason user code might need to access or mutate this type's fields?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fields need to be pub for althernate sdk implementations. Will fix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added quick comment as well to clarify purpose a bit. Should be opaque to everyone who is not trying to implement PreSampledTracer directly.

/// The parent otel `Context` for the current tracing span.
pub parent_cx: opentelemetry::Context,

/// The otel span data recorded during the current tracing span.
pub builder: opentelemetry::trace::SpanBuilder,
}
8 changes: 4 additions & 4 deletions tracing-opentelemetry/src/span_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ impl OpenTelemetrySpanExt for tracing::Span {
let mut cx = Some(cx);
self.with_collector(move |(id, collector)| {
if let Some(get_context) = collector.downcast_ref::<WithContext>() {
get_context.with_context(collector, id, move |builder, _tracer| {
get_context.with_context(collector, id, move |data, _tracer| {
if let Some(cx) = cx.take() {
builder.parent_context = cx;
data.parent_cx = cx;
}
});
}
Expand All @@ -140,11 +140,11 @@ impl OpenTelemetrySpanExt for tracing::Span {
let mut att = Some(attributes);
self.with_collector(move |(id, collector)| {
if let Some(get_context) = collector.downcast_ref::<WithContext>() {
get_context.with_context(collector, id, move |builder, _tracer| {
get_context.with_context(collector, id, move |data, _tracer| {
if let Some(cx) = cx.take() {
let attr = att.take().unwrap_or_default();
let follows_link = opentelemetry::trace::Link::new(cx, attr);
builder
data.builder
.links
.get_or_insert_with(|| Vec::with_capacity(1))
.push(follows_link);
Expand Down
Loading