Skip to content

Commit

Permalink
Support for OpenTelemetry 0.22 (#35)
Browse files Browse the repository at this point in the history
* Support for OpenTelemetry 0.22

* Fixed clippy warning

* Tracing open telemetry update
  • Loading branch information
abdolence authored Mar 5, 2024
1 parent 87b9e84 commit 35a89b9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"] }
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
20 changes: 8 additions & 12 deletions src/google_trace_exporter_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl GcpCloudTraceExporterClient {
}
}

fn convert_span_attrs(attrs: &Vec<KeyValue>) -> gspan::Attributes {
fn convert_span_attrs(attrs: &[KeyValue]) -> gspan::Attributes {
const MAX_ATTRS: usize = 32;
gspan::Attributes {
attribute_map: attrs
Expand Down Expand Up @@ -140,9 +140,7 @@ impl GcpCloudTraceExporterClient {
}
}

fn convert_time_events(
events: &opentelemetry_sdk::trace::EvictedQueue<opentelemetry::trace::Event>,
) -> gspan::TimeEvents {
fn convert_time_events(events: &opentelemetry_sdk::trace::SpanEvents) -> gspan::TimeEvents {
const MAX_EVENTS: usize = 128;

gspan::TimeEvents {
Expand All @@ -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()
}
Expand Down Expand Up @@ -191,9 +189,7 @@ impl GcpCloudTraceExporterClient {
})
}

fn convert_links(
links: &opentelemetry_sdk::trace::EvictedQueue<opentelemetry::trace::Link>,
) -> gspan::Links {
fn convert_links(links: &opentelemetry_sdk::trace::SpanLinks) -> gspan::Links {
const MAX_LINKS: usize = 128;

gspan::Links {
Expand All @@ -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()
}
Expand Down

0 comments on commit 35a89b9

Please sign in to comment.