diff --git a/opentelemetry-proto/src/transform/trace.rs b/opentelemetry-proto/src/transform/trace.rs
index 231834a30d..db8221650e 100644
--- a/opentelemetry-proto/src/transform/trace.rs
+++ b/opentelemetry-proto/src/transform/trace.rs
@@ -7,7 +7,7 @@ pub mod tonic {
tonic::{Attributes, ResourceAttributesWithSchema},
};
use opentelemetry::trace;
- use opentelemetry::trace::{Link, SpanId, SpanKind};
+ use opentelemetry::trace::{SpanId, SpanKind};
use opentelemetry_sdk::trace::SpanData;
use std::collections::HashMap;
@@ -33,18 +33,6 @@ pub mod tonic {
}
}
- impl From for span::Link {
- fn from(link: Link) -> Self {
- span::Link {
- trace_id: link.span_context.trace_id().to_bytes().to_vec(),
- span_id: link.span_context.span_id().to_bytes().to_vec(),
- trace_state: link.span_context.trace_state().header(),
- attributes: Attributes::from(link.attributes).0,
- dropped_attributes_count: link.dropped_attributes_count,
- flags: link.span_context.trace_flags().to_u8() as u32,
- }
- }
- }
impl From for Span {
fn from(source_span: opentelemetry_sdk::trace::SpanData) -> Self {
let span_kind: span::SpanKind = source_span.span_kind.into();
@@ -74,11 +62,22 @@ pub mod tonic {
time_unix_nano: to_nanos(event.timestamp),
name: event.name.into(),
attributes: Attributes::from(event.attributes).0,
- dropped_attributes_count: event.dropped_attributes_count,
+ dropped_attributes_count: source_span.dropped_attributes_count,
})
.collect(),
dropped_links_count: source_span.links.dropped_count,
- links: source_span.links.into_iter().map(Into::into).collect(),
+ links: source_span
+ .links
+ .into_iter()
+ .map(|link| span::Link {
+ trace_id: link.span_context.trace_id().to_bytes().to_vec(),
+ span_id: link.span_context.span_id().to_bytes().to_vec(),
+ trace_state: link.span_context.trace_state().header(),
+ attributes: Attributes::from(link.attributes).0,
+ dropped_attributes_count: source_span.dropped_attributes_count,
+ flags: link.span_context.trace_flags().to_u8() as u32,
+ })
+ .collect(),
status: Some(Status {
code: status::StatusCode::from(&source_span.status).into(),
message: match source_span.status {
@@ -133,11 +132,22 @@ pub mod tonic {
time_unix_nano: to_nanos(event.timestamp),
name: event.name.into(),
attributes: Attributes::from(event.attributes).0,
- dropped_attributes_count: event.dropped_attributes_count,
+ dropped_attributes_count: source_span.dropped_attributes_count,
})
.collect(),
dropped_links_count: source_span.links.dropped_count,
- links: source_span.links.into_iter().map(Into::into).collect(),
+ links: source_span
+ .links
+ .into_iter()
+ .map(|link| span::Link {
+ trace_id: link.span_context.trace_id().to_bytes().to_vec(),
+ span_id: link.span_context.span_id().to_bytes().to_vec(),
+ trace_state: link.span_context.trace_state().header(),
+ attributes: Attributes::from(link.attributes).0,
+ dropped_attributes_count: source_span.dropped_attributes_count,
+ flags: link.span_context.trace_flags().to_u8() as u32,
+ })
+ .collect(),
status: Some(Status {
code: status::StatusCode::from(&source_span.status).into(),
message: match source_span.status {
diff --git a/opentelemetry-proto/src/transform/tracez.rs b/opentelemetry-proto/src/transform/tracez.rs
index 3147a82cbb..08006f246b 100644
--- a/opentelemetry-proto/src/transform/tracez.rs
+++ b/opentelemetry-proto/src/transform/tracez.rs
@@ -1,10 +1,10 @@
#[cfg(all(feature = "gen-tonic-messages", feature = "zpages"))]
mod tonic {
- use opentelemetry::trace::{Event, Status};
+ use opentelemetry::trace::Status;
use opentelemetry_sdk::trace::SpanData;
use crate::proto::tonic::{
- trace::v1::{span::Event as SpanEvent, Status as SpanStatus},
+ trace::v1::{span, span::Event as SpanEvent, Status as SpanStatus},
tracez::v1::{ErrorData, LatencyData, RunningData},
};
use crate::transform::common::{to_nanos, tonic::Attributes};
@@ -18,8 +18,30 @@ mod tonic {
starttime: to_nanos(span_data.start_time),
endtime: to_nanos(span_data.end_time),
attributes: Attributes::from(span_data.attributes).0,
- events: span_data.events.iter().cloned().map(Into::into).collect(),
- links: span_data.links.iter().cloned().map(Into::into).collect(),
+ events: span_data
+ .events
+ .events
+ .into_iter()
+ .map(|e| SpanEvent {
+ time_unix_nano: to_nanos(e.timestamp),
+ name: e.name.to_string(),
+ attributes: Attributes::from(e.attributes).0,
+ dropped_attributes_count: span_data.dropped_attributes_count,
+ })
+ .collect(),
+ links: span_data
+ .links
+ .iter()
+ .cloned()
+ .map(|link| span::Link {
+ trace_id: link.span_context.trace_id().to_bytes().to_vec(),
+ span_id: link.span_context.span_id().to_bytes().to_vec(),
+ trace_state: link.span_context.trace_state().header(),
+ attributes: Attributes::from(link.attributes).0,
+ dropped_attributes_count: span_data.dropped_attributes_count,
+ flags: link.span_context.trace_flags().to_u8() as u32,
+ })
+ .collect(),
}
}
}
@@ -32,8 +54,30 @@ mod tonic {
parentid: span_data.parent_span_id.to_bytes().to_vec(),
starttime: to_nanos(span_data.start_time),
attributes: Attributes::from(span_data.attributes).0,
- events: span_data.events.iter().cloned().map(Into::into).collect(),
- links: span_data.links.iter().cloned().map(Into::into).collect(),
+ events: span_data
+ .events
+ .events
+ .into_iter()
+ .map(|e| SpanEvent {
+ time_unix_nano: to_nanos(e.timestamp),
+ name: e.name.to_string(),
+ attributes: Attributes::from(e.attributes).0,
+ dropped_attributes_count: span_data.dropped_attributes_count,
+ })
+ .collect(),
+ links: span_data
+ .links
+ .iter()
+ .cloned()
+ .map(|link| span::Link {
+ trace_id: link.span_context.trace_id().to_bytes().to_vec(),
+ span_id: link.span_context.span_id().to_bytes().to_vec(),
+ trace_state: link.span_context.trace_state().header(),
+ attributes: Attributes::from(link.attributes).0,
+ dropped_attributes_count: span_data.dropped_attributes_count,
+ flags: link.span_context.trace_flags().to_u8() as u32,
+ })
+ .collect(),
status: match span_data.status {
Status::Error { description } => Some(SpanStatus {
message: description.to_string(),
@@ -53,19 +97,30 @@ mod tonic {
parentid: span_data.parent_span_id.to_bytes().to_vec(),
starttime: to_nanos(span_data.start_time),
attributes: Attributes::from(span_data.attributes).0,
- events: span_data.events.iter().cloned().map(Into::into).collect(),
- links: span_data.links.iter().cloned().map(Into::into).collect(),
- }
- }
- }
-
- impl From for SpanEvent {
- fn from(event: Event) -> Self {
- SpanEvent {
- time_unix_nano: to_nanos(event.timestamp),
- name: event.name.to_string(),
- attributes: Attributes::from(event.attributes).0,
- dropped_attributes_count: event.dropped_attributes_count,
+ events: span_data
+ .events
+ .events
+ .into_iter()
+ .map(|e| SpanEvent {
+ time_unix_nano: to_nanos(e.timestamp),
+ name: e.name.to_string(),
+ attributes: Attributes::from(e.attributes).0,
+ dropped_attributes_count: span_data.dropped_attributes_count,
+ })
+ .collect(),
+ links: span_data
+ .links
+ .iter()
+ .cloned()
+ .map(|link| span::Link {
+ trace_id: link.span_context.trace_id().to_bytes().to_vec(),
+ span_id: link.span_context.span_id().to_bytes().to_vec(),
+ trace_state: link.span_context.trace_state().header(),
+ attributes: Attributes::from(link.attributes).0,
+ dropped_attributes_count: span_data.links.dropped_count,
+ flags: link.span_context.trace_flags().to_u8() as u32,
+ })
+ .collect(),
}
}
}
diff --git a/opentelemetry-sdk/src/trace/span.rs b/opentelemetry-sdk/src/trace/span.rs
index 9cb8b88045..b70b19d64c 100644
--- a/opentelemetry-sdk/src/trace/span.rs
+++ b/opentelemetry-sdk/src/trace/span.rs
@@ -101,16 +101,10 @@ impl opentelemetry::trace::Span for Span {
let event_attributes_limit = self.span_limits.max_attributes_per_event as usize;
self.with_data(|data| {
if data.events.len() < span_events_limit {
- let dropped_attributes_count =
- attributes.len().saturating_sub(event_attributes_limit);
attributes.truncate(event_attributes_limit);
- data.events.add_event(Event::new(
- name,
- timestamp,
- attributes,
- dropped_attributes_count as u32,
- ));
+ data.events
+ .add_event(Event::new(name, timestamp, attributes));
} else {
data.events.dropped_count += 1;
}
@@ -175,15 +169,9 @@ impl opentelemetry::trace::Span for Span {
let link_attributes_limit = self.span_limits.max_attributes_per_link as usize;
self.with_data(|data| {
if data.links.links.len() < span_links_limit {
- let dropped_attributes_count =
- attributes.len().saturating_sub(link_attributes_limit);
let mut attributes = attributes;
attributes.truncate(link_attributes_limit);
- data.links.add_link(Link::new(
- span_context,
- attributes,
- dropped_attributes_count as u32,
- ));
+ data.links.add_link(Link::new(span_context, attributes));
} else {
data.links.dropped_count += 1;
}
diff --git a/opentelemetry-sdk/src/trace/tracer.rs b/opentelemetry-sdk/src/trace/tracer.rs
index 40e55fdc52..8df72226d4 100644
--- a/opentelemetry-sdk/src/trace/tracer.rs
+++ b/opentelemetry-sdk/src/trace/tracer.rs
@@ -86,10 +86,7 @@ impl SdkTracer {
links.truncate(spans_links_limit);
let link_attributes_limit = span_limits.max_attributes_per_link as usize;
for link in links.iter_mut() {
- let dropped_attributes_count =
- link.attributes.len().saturating_sub(link_attributes_limit);
link.attributes.truncate(link_attributes_limit);
- link.dropped_attributes_count = dropped_attributes_count as u32;
}
SpanLinks {
links,
@@ -116,12 +113,7 @@ impl SdkTracer {
events.truncate(spans_events_limit);
let event_attributes_limit = span_limits.max_attributes_per_event as usize;
for event in events.iter_mut() {
- let dropped_attributes_count = event
- .attributes
- .len()
- .saturating_sub(event_attributes_limit);
event.attributes.truncate(event_attributes_limit);
- event.dropped_attributes_count = dropped_attributes_count as u32;
}
SpanEvents {
events,
diff --git a/opentelemetry/src/trace/mod.rs b/opentelemetry/src/trace/mod.rs
index 173d36aeff..47d5ab56fd 100644
--- a/opentelemetry/src/trace/mod.rs
+++ b/opentelemetry/src/trace/mod.rs
@@ -199,10 +199,6 @@ pub struct Event {
/// Attributes that describe this event.
pub attributes: Vec,
-
- /// The number of attributes that were above the configured limit, and thus
- /// dropped.
- pub dropped_attributes_count: u32,
}
impl Event {
@@ -211,13 +207,11 @@ impl Event {
name: T,
timestamp: time::SystemTime,
attributes: Vec,
- dropped_attributes_count: u32,
) -> Self {
Event {
name: name.into(),
timestamp,
attributes,
- dropped_attributes_count,
}
}
@@ -227,7 +221,6 @@ impl Event {
name: name.into(),
timestamp: crate::time::now(),
attributes: Vec::new(),
- dropped_attributes_count: 0,
}
}
}
@@ -243,23 +236,14 @@ pub struct Link {
/// Attributes that describe this link.
pub attributes: Vec,
-
- /// The number of attributes that were above the configured limit, and thus
- /// dropped.
- pub dropped_attributes_count: u32,
}
impl Link {
/// Create new `Link`
- pub fn new(
- span_context: SpanContext,
- attributes: Vec,
- dropped_attributes_count: u32,
- ) -> Self {
+ pub fn new(span_context: SpanContext, attributes: Vec) -> Self {
Link {
span_context,
attributes,
- dropped_attributes_count,
}
}
@@ -268,7 +252,6 @@ impl Link {
Link {
span_context,
attributes: Vec::new(),
- dropped_attributes_count: 0,
}
}
}