Skip to content

Commit

Permalink
Rename message events to events (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtescher committed Apr 22, 2021
1 parent 4e7613b commit 3ff1802
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 48 deletions.
4 changes: 2 additions & 2 deletions opentelemetry-datadog/src/exporter/model/mod.rs
Expand Up @@ -102,7 +102,7 @@ pub(crate) mod tests {
let mut attributes = sdk::trace::EvictedHashMap::new(capacity, capacity as usize);
attributes.insert(Key::new("span.type").string("web"));

let message_events = sdk::trace::EvictedQueue::new(capacity);
let events = sdk::trace::EvictedQueue::new(capacity);
let links = sdk::trace::EvictedQueue::new(capacity);

trace::SpanData {
Expand All @@ -113,7 +113,7 @@ pub(crate) mod tests {
start_time,
end_time,
attributes,
message_events,
events,
links,
status_code: StatusCode::Ok,
status_message: "".into(),
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger/src/exporter/mod.rs
Expand Up @@ -521,7 +521,7 @@ fn convert_otel_span_into_jaeger_span(
span.status_message.into_owned(),
span.span_kind,
)),
logs: events_to_logs(span.message_events),
logs: events_to_logs(span.events),
}
}

Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-otlp/src/transform/traces.rs
Expand Up @@ -95,9 +95,9 @@ mod tonic {
end_time_unix_nano: to_nanos(source_span.end_time),
dropped_attributes_count: source_span.attributes.dropped_count(),
attributes: Attributes::from(source_span.attributes).0,
dropped_events_count: source_span.message_events.dropped_count(),
dropped_events_count: source_span.events.dropped_count(),
events: source_span
.message_events
.events
.into_iter()
.map(|event| span::Event {
time_unix_nano: to_nanos(event.timestamp),
Expand Down Expand Up @@ -224,9 +224,9 @@ mod prost {
end_time_unix_nano: to_nanos(source_span.end_time),
dropped_attributes_count: source_span.attributes.dropped_count(),
attributes: Attributes::from(source_span.attributes).0,
dropped_events_count: source_span.message_events.dropped_count(),
dropped_events_count: source_span.events.dropped_count(),
events: source_span
.message_events
.events
.into_iter()
.map(|event| span::Event {
time_unix_nano: to_nanos(event.timestamp),
Expand Down Expand Up @@ -358,10 +358,10 @@ mod grpcio {
end_time_unix_nano: to_nanos(source_span.end_time),
dropped_attributes_count: source_span.attributes.dropped_count(),
attributes: Attributes::from(source_span.attributes).0,
dropped_events_count: source_span.message_events.dropped_count(),
dropped_events_count: source_span.events.dropped_count(),
events: RepeatedField::from_vec(
source_span
.message_events
.events
.into_iter()
.map(|event| Span_Event {
time_unix_nano: to_nanos(event.timestamp),
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-stackdriver/src/lib.rs
Expand Up @@ -153,7 +153,7 @@ impl StackDriverExporter {
.collect();

let time_event = span
.message_events
.events
.into_iter()
.map(|event| TimeEvent {
time: Some(event.timestamp.into()),
Expand Down
8 changes: 1 addition & 7 deletions opentelemetry-zipkin/src/exporter/model/mod.rs
Expand Up @@ -104,13 +104,7 @@ pub(crate) fn into_zipkin_span(local_endpoint: Endpoint, span_data: trace::SpanD
.as_micros() as u64,
)
.local_endpoint(local_endpoint)
.annotations(
span_data
.message_events
.into_iter()
.map(Into::into)
.collect(),
)
.annotations(span_data.events.into_iter().map(Into::into).collect())
.tags(tags)
.build()
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/src/exporter/model/span.rs
Expand Up @@ -173,7 +173,7 @@ mod tests {
start_time: SystemTime::now(),
end_time: SystemTime::now(),
attributes: EvictedHashMap::new(20, 20),
message_events: EvictedQueue::new(20),
events: EvictedQueue::new(20),
links: EvictedQueue::new(20),
status_code,
status_message: status_msg.into(),
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry/src/sdk/export/trace/mod.rs
Expand Up @@ -72,8 +72,8 @@ pub struct SpanData {
pub end_time: SystemTime,
/// Span attributes
pub attributes: sdk::trace::EvictedHashMap,
/// Span Message events
pub message_events: sdk::trace::EvictedQueue<Event>,
/// Span events
pub events: sdk::trace::EvictedQueue<Event>,
/// Span Links
pub links: sdk::trace::EvictedQueue<Link>,
/// Span status code
Expand Down Expand Up @@ -116,7 +116,7 @@ mod tests {

let capacity = 3;
let attributes = sdk::trace::EvictedHashMap::new(capacity, 0);
let message_events = sdk::trace::EvictedQueue::new(capacity);
let events = sdk::trace::EvictedQueue::new(capacity);
let links = sdk::trace::EvictedQueue::new(capacity);

let status_code = StatusCode::Ok;
Expand All @@ -131,7 +131,7 @@ mod tests {
start_time,
end_time,
attributes,
message_events,
events,
links,
status_code,
status_message,
Expand Down
26 changes: 12 additions & 14 deletions opentelemetry/src/sdk/trace/span.rs
Expand Up @@ -38,8 +38,8 @@ pub(crate) struct SpanData {
pub(crate) end_time: SystemTime,
/// Span attributes
pub(crate) attributes: sdk::trace::EvictedHashMap,
/// Span Message events
pub(crate) message_events: sdk::trace::EvictedQueue<trace::Event>,
/// Span events
pub(crate) events: sdk::trace::EvictedQueue<trace::Event>,
/// Span Links
pub(crate) links: sdk::trace::EvictedQueue<trace::Link>,
/// Span status code
Expand Down Expand Up @@ -89,7 +89,7 @@ impl crate::trace::Span for Span {
let dropped_attributes_count = attributes.len().saturating_sub(event_attributes_limit);
attributes.truncate(event_attributes_limit);

data.message_events.push_back(Event::new(
data.events.push_back(Event::new(
name,
timestamp,
attributes,
Expand Down Expand Up @@ -204,7 +204,7 @@ fn build_export_data(
start_time: data.start_time,
end_time: data.end_time,
attributes: data.attributes,
message_events: data.message_events,
events: data.events,
links: data.links,
status_code: data.status_code,
status_message: data.status_message,
Expand Down Expand Up @@ -237,7 +237,7 @@ mod tests {
config.span_limits.max_attributes_per_span,
0,
),
message_events: sdk::trace::EvictedQueue::new(config.span_limits.max_events_per_span),
events: sdk::trace::EvictedQueue::new(config.span_limits.max_events_per_span),
links: sdk::trace::EvictedQueue::new(config.span_limits.max_links_per_span),
status_code: StatusCode::Unset,
status_message: "".into(),
Expand Down Expand Up @@ -286,7 +286,7 @@ mod tests {
let attributes = vec![KeyValue::new("k", "v")];
span.add_event(name.clone(), attributes.clone());
span.with_data(|data| {
if let Some(event) = data.message_events.iter().next() {
if let Some(event) = data.events.iter().next() {
assert_eq!(event.name, name);
assert_eq!(event.attributes, attributes);
} else {
Expand All @@ -303,7 +303,7 @@ mod tests {
let timestamp = crate::time::now();
span.add_event_with_timestamp(name.clone(), timestamp, attributes.clone());
span.with_data(|data| {
if let Some(event) = data.message_events.iter().next() {
if let Some(event) = data.events.iter().next() {
assert_eq!(event.timestamp, timestamp);
assert_eq!(event.name, name);
assert_eq!(event.attributes, attributes);
Expand All @@ -319,7 +319,7 @@ mod tests {
let err = std::io::Error::from(std::io::ErrorKind::Other);
span.record_exception(&err);
span.with_data(|data| {
if let Some(event) = data.message_events.iter().next() {
if let Some(event) = data.events.iter().next() {
assert_eq!(event.name, "exception");
assert_eq!(
event.attributes,
Expand All @@ -338,7 +338,7 @@ mod tests {
let stacktrace = "stacktrace...".to_string();
span.record_exception_with_stacktrace(&err, stacktrace.clone());
span.with_data(|data| {
if let Some(event) = data.message_events.iter().next() {
if let Some(event) = data.events.iter().next() {
assert_eq!(event.name, "exception");
assert_eq!(
event.attributes,
Expand Down Expand Up @@ -459,7 +459,7 @@ mod tests {
span.set_status(StatusCode::Error, "ERROR".to_string());
span.update_name("new_name".to_string());
span.with_data(|data| {
assert_eq!(data.message_events, initial.message_events);
assert_eq!(data.events, initial.events);
assert_eq!(data.attributes, initial.attributes);
assert_eq!(data.status_code, initial.status_code);
assert_eq!(data.status_message, initial.status_message);
Expand Down Expand Up @@ -496,9 +496,7 @@ mod tests {
let event2 = event1.clone();

// add event when build
let span_builder = tracer
.span_builder("test")
.with_message_events(vec![event1]);
let span_builder = tracer.span_builder("test").with_events(vec![event1]);
let mut span = tracer.build(span_builder);

// add event after build
Expand All @@ -508,7 +506,7 @@ mod tests {
.data
.clone()
.expect("span data should not be empty as we already set it before")
.message_events;
.events;
let event_vec: Vec<_> = event_queue.iter().take(2).collect();
let processed_event_1 = event_vec.get(0).expect("should have at least two events");
let processed_event_2 = event_vec.get(1).expect("should have at least two events");
Expand Down
10 changes: 5 additions & 5 deletions opentelemetry/src/sdk/trace/tracer.rs
Expand Up @@ -255,7 +255,7 @@ impl crate::trace::Tracer for Tracer {
name,
start_time,
end_time,
message_events,
events,
status_code,
status_message,
..
Expand All @@ -282,8 +282,8 @@ impl crate::trace::Tracer for Tracer {
}
let start_time = start_time.unwrap_or_else(crate::time::now);
let end_time = end_time.unwrap_or(start_time);
let mut message_events_queue = EvictedQueue::new(span_limits.max_events_per_span);
if let Some(mut events) = message_events {
let mut events_queue = EvictedQueue::new(span_limits.max_events_per_span);
if let Some(mut events) = events {
let event_attributes_limit = span_limits.max_attributes_per_event as usize;
for event in events.iter_mut() {
let dropped_attributes_count = event
Expand All @@ -293,7 +293,7 @@ impl crate::trace::Tracer for Tracer {
event.attributes.truncate(event_attributes_limit);
event.dropped_attributes_count = dropped_attributes_count as u32;
}
message_events_queue.append_vec(&mut events);
events_queue.append_vec(&mut events);
}
let status_code = status_code.unwrap_or(StatusCode::Unset);
let status_message = status_message.unwrap_or(Cow::Borrowed(""));
Expand All @@ -305,7 +305,7 @@ impl crate::trace::Tracer for Tracer {
start_time,
end_time,
attributes,
message_events: message_events_queue,
events: events_queue,
links,
status_code,
status_message,
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/testing/trace.rs
Expand Up @@ -47,7 +47,7 @@ pub fn new_test_export_span_data() -> SpanData {
start_time: crate::time::now(),
end_time: crate::time::now(),
attributes: EvictedHashMap::new(config.span_limits.max_attributes_per_span, 0),
message_events: EvictedQueue::new(config.span_limits.max_events_per_span),
events: EvictedQueue::new(config.span_limits.max_events_per_span),
links: EvictedQueue::new(config.span_limits.max_links_per_span),
status_code: StatusCode::Unset,
status_message: "".into(),
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry/src/trace/tracer.rs
Expand Up @@ -352,8 +352,8 @@ pub struct SpanBuilder {
pub end_time: Option<SystemTime>,
/// Span attributes
pub attributes: Option<Vec<KeyValue>>,
/// Span Message events
pub message_events: Option<Vec<Event>>,
/// Span events
pub events: Option<Vec<Event>>,
/// Span Links
pub links: Option<Vec<Link>>,
/// Span status code
Expand Down Expand Up @@ -385,7 +385,7 @@ impl SpanBuilder {
start_time: None,
end_time: None,
attributes: None,
message_events: None,
events: None,
links: None,
status_code: None,
status_message: None,
Expand Down Expand Up @@ -449,10 +449,10 @@ impl SpanBuilder {
}
}

/// Assign message events
pub fn with_message_events(self, message_events: Vec<Event>) -> Self {
/// Assign events
pub fn with_events(self, events: Vec<Event>) -> Self {
SpanBuilder {
message_events: Some(message_events),
events: Some(events),
..self
}
}
Expand Down

0 comments on commit 3ff1802

Please sign in to comment.