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 1 commit
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
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
4 changes: 2 additions & 2 deletions tracing-opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rust-version = "1.42.0"
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
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
7 changes: 7 additions & 0 deletions tracing-opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,10 @@ mod tracer;
pub use span_ext::OpenTelemetrySpanExt;
pub use subscriber::{subscriber, OpenTelemetrySubscriber};
pub use tracer::PreSampledTracer;

/// Per-span OpenTelemetry data tracked by this crate.
#[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.

parent_cx: opentelemetry::Context,
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