Skip to content

Commit

Permalink
update minitrate-opentelemetry to use opentelemetry 0.22, _sdk: 0.22.…
Browse files Browse the repository at this point in the history
…1 and otlp: 0.15 and tweak the corresponding API usage to match
  • Loading branch information
rrichardson committed Apr 25, 2024
1 parent bf68171 commit 1f00735
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions minitrace-opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
13 changes: 7 additions & 6 deletions minitrace-opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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(),
Expand All @@ -90,9 +91,9 @@ impl OpenTelemetryReporter {
map
}

fn convert_events(events: &[EventRecord]) -> EvictedQueue<Event> {
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),
Expand All @@ -106,7 +107,7 @@ impl OpenTelemetryReporter {
0,
)
}));
queue
queue
}

fn try_report(&mut self, spans: &[SpanRecord]) -> Result<(), Box<dyn std::error::Error>> {
Expand Down

0 comments on commit 1f00735

Please sign in to comment.