From 1f00735bfe5f6aa64286790c2aa1e57b2c3fc062 Mon Sep 17 00:00:00 2001 From: Rick Richardson Date: Thu, 25 Apr 2024 16:29:26 -0700 Subject: [PATCH] update minitrate-opentelemetry to use opentelemetry 0.22, _sdk: 0.22.1 and otlp: 0.15 and tweak the corresponding API usage to match --- minitrace-opentelemetry/Cargo.toml | 6 +++--- minitrace-opentelemetry/src/lib.rs | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/minitrace-opentelemetry/Cargo.toml b/minitrace-opentelemetry/Cargo.toml index ba79073b..fe82501a 100644 --- a/minitrace-opentelemetry/Cargo.toml +++ b/minitrace-opentelemetry/Cargo.toml @@ -16,10 +16,10 @@ keywords = ["tracing", "span", "datadog", "jaeger", "opentelemetry"] futures = { version = "0.3", features = ["executor"] } log = "0.4" minitrace = { version = "0.6.4", path = "../minitrace" } -opentelemetry = { version = "0.21", features = ["trace"] } -opentelemetry_sdk = { version = "0.21", features = ["trace"] } +opentelemetry = { version = "0.22", features = ["trace"] } +opentelemetry_sdk = { version = "0.22.1", features = ["trace"] } [dev-dependencies] -opentelemetry-otlp = { version = "0.14", features = ["trace"] } +opentelemetry-otlp = { version = "0.15", features = ["trace"] } rand = "0.8" tokio = { version = "1", features = ["rt-multi-thread"] } diff --git a/minitrace-opentelemetry/src/lib.rs b/minitrace-opentelemetry/src/lib.rs index e2645836..ffc640c3 100644 --- a/minitrace-opentelemetry/src/lib.rs +++ b/minitrace-opentelemetry/src/lib.rs @@ -20,9 +20,10 @@ use opentelemetry::Key; use opentelemetry::KeyValue; use opentelemetry::StringValue; use opentelemetry::Value; +use opentelemetry_sdk::trace::SpanLinks; +use opentelemetry_sdk::trace::SpanEvents; use opentelemetry_sdk::export::trace::SpanData; use opentelemetry_sdk::export::trace::SpanExporter; -use opentelemetry_sdk::trace::EvictedQueue; use opentelemetry_sdk::Resource; /// [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-rust) reporter for `minitrace`. @@ -70,7 +71,7 @@ impl OpenTelemetryReporter { + Duration::from_nanos(span.begin_time_unix_ns + span.duration_ns), attributes: Self::convert_properties(&span.properties), events: Self::convert_events(&span.events), - links: EvictedQueue::new(0), + links: SpanLinks::default(), status: Status::default(), span_kind: self.span_kind.clone(), resource: self.resource.clone(), @@ -90,9 +91,9 @@ impl OpenTelemetryReporter { map } - fn convert_events(events: &[EventRecord]) -> EvictedQueue { - let mut queue = EvictedQueue::new(u32::MAX); - queue.extend(events.iter().map(|event| { + fn convert_events(events: &[EventRecord]) -> SpanEvents { + let mut queue = SpanEvents::default(); + queue.events.extend(events.iter().map(|event| { Event::new( event.name.clone(), UNIX_EPOCH + Duration::from_nanos(event.timestamp_unix_ns), @@ -106,7 +107,7 @@ impl OpenTelemetryReporter { 0, ) })); - queue + queue } fn try_report(&mut self, spans: &[SpanRecord]) -> Result<(), Box> {