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

Chore/update opentelemetry #1441

Merged
merged 4 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions tracing-opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tracing-opentelemetry"
version = "0.13.0"
version = "0.14.0"
authors = [
"Julian Tescher <julian@tescher.me>",
"Tokio Contributors <team@tokio.rs>"
Expand All @@ -22,7 +22,7 @@ edition = "2018"
default = ["tracing-log"]

[dependencies]
opentelemetry = { version = "0.14", default-features = false, features = ["trace"] }
opentelemetry = { version = "0.15", 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"] }
Expand All @@ -31,7 +31,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.13"
opentelemetry-jaeger = "0.14"

[lib]
bench = false
Expand Down
4 changes: 2 additions & 2 deletions tracing-opentelemetry/src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ impl Timings {
#[cfg(test)]
mod tests {
use super::*;
use opentelemetry::trace::SpanKind;
use opentelemetry::trace::{SpanKind, TraceFlags};
use std::borrow::Cow;
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
Expand Down Expand Up @@ -750,7 +750,7 @@ mod tests {
let existing_cx = OtelContext::current_with_span(TestSpan(otel::SpanContext::new(
trace_id,
otel::SpanId::from_u64(1),
0,
TraceFlags::default(),
false,
Default::default(),
)));
Expand Down
26 changes: 13 additions & 13 deletions tracing-opentelemetry/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use opentelemetry::{
trace as otel,
trace::{
SpanBuilder, SpanContext, SpanId, SpanKind, TraceContextExt, TraceId, TraceState,
TRACE_FLAG_SAMPLED,
TraceFlags
},
Context as OtelContext,
};
Expand Down Expand Up @@ -123,7 +123,7 @@ fn current_trace_state(
builder: &SpanBuilder,
parent_cx: &OtelContext,
provider: &TracerProvider,
) -> (bool, TraceId, bool, u8) {
) -> (bool, TraceId, bool, TraceFlags) {
if parent_cx.has_active_span() {
let span = parent_cx.span();
let sc = span.span_context();
Expand All @@ -135,15 +135,15 @@ fn current_trace_state(
.trace_id
.unwrap_or_else(|| provider.config().id_generator.new_trace_id()),
false,
0,
Default::default(),
)
}
}

fn process_sampling_result(
sampling_result: &SamplingResult,
trace_flags: u8,
) -> Option<(u8, TraceState)> {
trace_flags: TraceFlags,
) -> Option<(TraceFlags, TraceState)> {
match sampling_result {
SamplingResult {
decision: SamplingDecision::Drop,
Expand All @@ -153,20 +153,20 @@ fn process_sampling_result(
decision: SamplingDecision::RecordOnly,
trace_state,
..
} => Some((trace_flags & !TRACE_FLAG_SAMPLED, trace_state.clone())),
} => Some((trace_flags & !TraceFlags::SAMPLED, trace_state.clone())),
SamplingResult {
decision: SamplingDecision::RecordAndSample,
trace_state,
..
} => Some((trace_flags | TRACE_FLAG_SAMPLED, trace_state.clone())),
} => Some((trace_flags | TraceFlags::SAMPLED, trace_state.clone())),
}
}

#[cfg(test)]
mod tests {
use super::*;
use opentelemetry::sdk::trace::{config, Sampler, TracerProvider};
use opentelemetry::trace::{SpanBuilder, SpanId, TracerProvider as _, TRACE_FLAG_NOT_SAMPLED};
use opentelemetry::trace::{SpanBuilder, SpanId, TracerProvider as _};

#[test]
fn assigns_default_trace_id_if_missing() {
Expand All @@ -190,10 +190,10 @@ mod tests {
("empty_parent_cx_always_off", Sampler::AlwaysOff, OtelContext::new(), None, false),

// Remote parent samples
("remote_parent_cx_always_on", Sampler::AlwaysOn, OtelContext::new().with_remote_span_context(span_context(TRACE_FLAG_SAMPLED, true)), None, true),
("remote_parent_cx_always_off", Sampler::AlwaysOff, OtelContext::new().with_remote_span_context(span_context(TRACE_FLAG_SAMPLED, true)), None, false),
("sampled_remote_parent_cx_parent_based", Sampler::ParentBased(Box::new(Sampler::AlwaysOff)), OtelContext::new().with_remote_span_context(span_context(TRACE_FLAG_SAMPLED, true)), None, true),
("unsampled_remote_parent_cx_parent_based", Sampler::ParentBased(Box::new(Sampler::AlwaysOn)), OtelContext::new().with_remote_span_context(span_context(TRACE_FLAG_NOT_SAMPLED, true)), None, false),
("remote_parent_cx_always_on", Sampler::AlwaysOn, OtelContext::new().with_remote_span_context(span_context(TraceFlags::SAMPLED, true)), None, true),
("remote_parent_cx_always_off", Sampler::AlwaysOff, OtelContext::new().with_remote_span_context(span_context(TraceFlags::SAMPLED, true)), None, false),
("sampled_remote_parent_cx_parent_based", Sampler::ParentBased(Box::new(Sampler::AlwaysOff)), OtelContext::new().with_remote_span_context(span_context(TraceFlags::SAMPLED, true)), None, true),
("unsampled_remote_parent_cx_parent_based", Sampler::ParentBased(Box::new(Sampler::AlwaysOn)), OtelContext::new().with_remote_span_context(span_context(TraceFlags::default(), true)), None, false),

// Existing sampling result defers
("previous_drop_result_always_on", Sampler::AlwaysOn, OtelContext::new(), Some(SamplingResult { decision: SamplingDecision::Drop, attributes: vec![], trace_state: Default::default() }), false),
Expand Down Expand Up @@ -226,7 +226,7 @@ mod tests {
}
}

fn span_context(trace_flags: u8, is_remote: bool) -> SpanContext {
fn span_context(trace_flags: TraceFlags, is_remote: bool) -> SpanContext {
SpanContext::new(
TraceId::from_u128(1),
SpanId::from_u64(1),
Expand Down