From 35a89b9b75cf26ea673e9f26db006054fa934ee6 Mon Sep 17 00:00:00 2001 From: Abdulla Abdurakhmanov Date: Tue, 5 Mar 2024 21:03:37 +0100 Subject: [PATCH] Support for OpenTelemetry 0.22 (#35) * Support for OpenTelemetry 0.22 * Fixed clippy warning * Tracing open telemetry update --- Cargo.toml | 10 +++++----- README.md | 1 + src/google_trace_exporter_client.rs | 20 ++++++++------------ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index afd65aa..ef98ceb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,9 +22,9 @@ path = "src/lib.rs" [dependencies] tracing = "0.1" -opentelemetry = { version = "0.21" } -opentelemetry_sdk = { version = "0.21", features = ["rt-tokio"] } -opentelemetry-semantic-conventions = { version = "0.13" } +opentelemetry = { version = "0.22" } +opentelemetry_sdk = { version = "0.22", features = ["rt-tokio"] } +opentelemetry-semantic-conventions = { version = "0.14" } gcloud-sdk = { version = "0.24", features = ["google-devtools-cloudtrace-v2"] } rvstruct = "0.3" rsb_derive = "0.5" @@ -36,8 +36,8 @@ async-trait = "0.1" [dev-dependencies] tokio = { version = "1", features = ["full"] } -opentelemetry = { version = "0.21" } +opentelemetry = { version = "0.22" } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter","registry"] } -tracing-opentelemetry = { version = "0.22" } +tracing-opentelemetry = { version = "0.23" } cargo-husky = { version = "1.5", default-features = false, features = ["run-for-all", "prepush-hook", "run-cargo-fmt"] } diff --git a/README.md b/README.md index b378a13..92ed374 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ opentelemetry-gcloud-trace = "0.8" | opentelemetry-gcloud-trace version | opentelemetry version | tracing-opentelemetry | gcloud-sdk | |------------------------------------|-----------------------|-----------------------|------------| +| 0.9 | 0.22 | 0.23 | 0.24 | | 0.8 | 0.21 | 0.22 | 0.23 | | 0.7 | 0.20 | 0.21 | 0.21 | | 0.6 | 0.20 | 0.20 | 0.20 | diff --git a/src/google_trace_exporter_client.rs b/src/google_trace_exporter_client.rs index 686a909..823d929 100644 --- a/src/google_trace_exporter_client.rs +++ b/src/google_trace_exporter_client.rs @@ -96,7 +96,7 @@ impl GcpCloudTraceExporterClient { } } - fn convert_span_attrs(attrs: &Vec) -> gspan::Attributes { + fn convert_span_attrs(attrs: &[KeyValue]) -> gspan::Attributes { const MAX_ATTRS: usize = 32; gspan::Attributes { attribute_map: attrs @@ -140,9 +140,7 @@ impl GcpCloudTraceExporterClient { } } - fn convert_time_events( - events: &opentelemetry_sdk::trace::EvictedQueue, - ) -> gspan::TimeEvents { + fn convert_time_events(events: &opentelemetry_sdk::trace::SpanEvents) -> gspan::TimeEvents { const MAX_EVENTS: usize = 128; gspan::TimeEvents { @@ -151,10 +149,10 @@ impl GcpCloudTraceExporterClient { .take(MAX_EVENTS) .map(Self::convert_time_event) .collect(), - dropped_annotations_count: if events.len() > MAX_EVENTS { - (events.dropped_count() as usize + events.len() - MAX_EVENTS) as i32 + dropped_message_events_count: if events.len() > MAX_EVENTS { + (events.dropped_count as usize + events.len() - MAX_EVENTS) as i32 } else { - events.dropped_count() as i32 + events.dropped_count as i32 }, ..gspan::TimeEvents::default() } @@ -191,9 +189,7 @@ impl GcpCloudTraceExporterClient { }) } - fn convert_links( - links: &opentelemetry_sdk::trace::EvictedQueue, - ) -> gspan::Links { + fn convert_links(links: &opentelemetry_sdk::trace::SpanLinks) -> gspan::Links { const MAX_LINKS: usize = 128; gspan::Links { @@ -203,9 +199,9 @@ impl GcpCloudTraceExporterClient { .map(Self::convert_link) .collect(), dropped_links_count: if links.len() > MAX_LINKS { - (links.dropped_count() as usize + links.len() - MAX_LINKS) as i32 + (links.dropped_count as usize + links.len() - MAX_LINKS) as i32 } else { - links.dropped_count() as i32 + links.dropped_count as i32 }, ..gspan::Links::default() }