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

Update dependencies #187

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ once_cell = "1.13.0"
async-trait = { version = "0.1.56", optional = true }
futures-util = { version = "0.3.17", optional = true }
lazy_static = { version = "1.0.2", optional = true }
thiserror = { version = "1.0.31", optional = true }
# Work around incorrect minimal version in opentelemetry, https://github.com/open-telemetry/opentelemetry-rust/pull/2406
thiserror-1 = { package = "thiserror", version = "1.0.31", optional = true }
thiserror = { version = "2", optional = true }
smallvec = { version = "1.0", optional = true }

[dev-dependencies]
Expand All @@ -54,7 +56,7 @@ tracing-error = "0.2.0"
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["registry", "std", "fmt"] }

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
pprof = { version = "0.13.0", features = ["flamegraph", "criterion"] }
pprof = { version = "0.14.0", features = ["flamegraph", "criterion"] }

[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
js-sys = "0.3.64"
Expand Down
9 changes: 4 additions & 5 deletions benches/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use opentelemetry::{
trace::{Span, SpanBuilder, Tracer as _, TracerProvider as _},
Context,
};
use opentelemetry_sdk::trace::{Config, Tracer, TracerProvider};
use opentelemetry_sdk::trace::{Tracer, TracerProvider};
#[cfg(not(target_os = "windows"))]
use pprof::criterion::{Output, PProfProfiler};
use std::time::SystemTime;
Expand Down Expand Up @@ -160,10 +160,9 @@ fn many_events(c: &mut Criterion) {
}

{
let mut config = Config::default();
config.span_limits.max_events_per_span = 1000;

let provider = TracerProvider::builder().with_config(config).build();
let provider = TracerProvider::builder()
.with_max_events_per_span(1000)
.build();
let tracer = provider.tracer("bench");
let otel_layer = tracing_opentelemetry::layer()
.with_tracer(tracer)
Expand Down
17 changes: 7 additions & 10 deletions examples/opentelemetry-otlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,13 @@ fn init_tracer_provider() -> TracerProvider {
.unwrap();

TracerProvider::builder()
.with_config(
opentelemetry_sdk::trace::Config::default()
// Customize sampling strategy
.with_sampler(Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased(
1.0,
))))
// If export trace to AWS X-Ray, you can use XrayIdGenerator
.with_id_generator(RandomIdGenerator::default())
.with_resource(resource()),
)
// Customize sampling strategy
.with_sampler(Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased(
1.0,
))))
// If export trace to AWS X-Ray, you can use XrayIdGenerator
.with_id_generator(RandomIdGenerator::default())
.with_resource(resource())
.with_batch_exporter(exporter, runtime::Tokio)
.build()
}
Expand Down
6 changes: 3 additions & 3 deletions src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct SpanEventVisitor<'a, 'b> {
sem_conv_config: SemConvConfig,
}

impl<'a, 'b> field::Visit for SpanEventVisitor<'a, 'b> {
impl field::Visit for SpanEventVisitor<'_, '_> {
/// Record events on the underlying OpenTelemetry [`Span`] from `bool` values.
///
/// [`Span`]: opentelemetry::trace::Span
Expand Down Expand Up @@ -403,7 +403,7 @@ struct SpanAttributeVisitor<'a> {
sem_conv_config: SemConvConfig,
}

impl<'a> SpanAttributeVisitor<'a> {
impl SpanAttributeVisitor<'_> {
fn record(&mut self, attribute: KeyValue) {
self.span_builder_updates
.attributes
Expand All @@ -412,7 +412,7 @@ impl<'a> SpanAttributeVisitor<'a> {
}
}

impl<'a> field::Visit for SpanAttributeVisitor<'a> {
impl field::Visit for SpanAttributeVisitor<'_> {
/// Set attributes on the underlying OpenTelemetry [`Span`] from `bool` values.
///
/// [`Span`]: opentelemetry::trace::Span
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@
//! long as doing so complies with this policy.
//!
//! [subscriber]: tracing_subscriber::subscribe
#![deny(unreachable_pub)]
#![cfg_attr(test, deny(warnings))]
#![warn(unreachable_pub)]
#![doc(html_root_url = "https://docs.rs/tracing-opentelemetry/0.22.0")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
Expand Down
2 changes: 1 addition & 1 deletion src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub(crate) struct MetricVisitor<'a> {
visited_metrics: &'a mut SmallVec<[(&'static str, InstrumentType); 2]>,
}

impl<'a> Visit for MetricVisitor<'a> {
impl Visit for MetricVisitor<'_> {
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
self.attributes
.push(KeyValue::new(field.name(), format!("{value:?}")));
Expand Down
6 changes: 2 additions & 4 deletions src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ mod tests {
use super::*;
use crate::OtelData;
use opentelemetry::trace::TracerProvider as _;
use opentelemetry_sdk::trace::{Config, Sampler, TracerProvider};
use opentelemetry_sdk::trace::{Sampler, TracerProvider};

#[test]
fn assigns_default_trace_id_if_missing() {
Expand Down Expand Up @@ -195,9 +195,7 @@ mod tests {
#[test]
fn sampled_context() {
for (name, sampler, parent_cx, previous_sampling_result, is_sampled) in sampler_data() {
let provider = TracerProvider::builder()
.with_config(Config::default().with_sampler(sampler))
.build();
let provider = TracerProvider::builder().with_sampler(sampler).build();
let tracer = provider.tracer("test");
let mut builder = SpanBuilder::from_name("parent".to_string());
builder.sampling_result = previous_sampling_result;
Expand Down
15 changes: 7 additions & 8 deletions tests/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use futures_util::future::BoxFuture;
use opentelemetry::trace::TracerProvider as _;
use opentelemetry_sdk::{
export::trace::{ExportResult, SpanData, SpanExporter},
trace::{Config, SpanLimits, Tracer, TracerProvider},
trace::{SpanLimits, Tracer, TracerProvider},
};
use std::sync::{Arc, Mutex};
use tracing::level_filters::LevelFilter;
Expand Down Expand Up @@ -32,15 +32,14 @@ fn test_tracer() -> (
impl Subscriber + Clone,
) {
let exporter = TestExporter::default();
let mut config = Config::default();
config.span_limits = SpanLimits {
max_events_per_span: u32::MAX,
..SpanLimits::default()
};

let provider = TracerProvider::builder()
.with_simple_exporter(exporter.clone())
.with_config(config)
// `with_max_events_per_span()` is buggy https://github.com/open-telemetry/opentelemetry-rust/pull/2405
.with_span_limits(SpanLimits {
max_events_per_span: u32::MAX,
..SpanLimits::default()
})
.with_max_events_per_span(u32::MAX)
.build();

let tracer = provider.tracer("test");
Expand Down
6 changes: 2 additions & 4 deletions tests/trace_state_propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use opentelemetry::{
use opentelemetry_sdk::{
export::trace::{ExportResult, SpanData, SpanExporter},
propagation::{BaggagePropagator, TraceContextPropagator},
trace::{Config, Sampler, Tracer, TracerProvider},
trace::{Sampler, Tracer, TracerProvider},
};
use std::collections::{HashMap, HashSet};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -107,9 +107,7 @@ fn sampling_decision_respects_new_parent() {
let exporter = TestExporter::default();
let provider = TracerProvider::builder()
.with_simple_exporter(exporter.clone())
.with_config(
Config::default().with_sampler(Sampler::ParentBased(Box::new(Sampler::AlwaysOff))),
)
.with_sampler(Sampler::ParentBased(Box::new(Sampler::AlwaysOff)))
.build();
let tracer = provider.tracer("test");
let subscriber = tracing_subscriber::registry().with(layer().with_tracer(tracer.clone()));
Expand Down
Loading