diff --git a/opentelemetry-stdout/src/logs/transform.rs b/opentelemetry-stdout/src/logs/transform.rs index b2f5a43a57..323fd9a011 100644 --- a/opentelemetry-stdout/src/logs/transform.rs +++ b/opentelemetry-stdout/src/logs/transform.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, collections::HashMap, time::SystemTime}; use crate::common::{ - as_human_readable, as_opt_human_readable, as_opt_unix_nano, as_unix_nano, AttributeSet, + as_human_readable, as_opt_human_readable, as_opt_unix_nano, as_unix_nano, AttributeSet, Key, KeyValue, Resource, Scope, Value, }; use serde::Serialize; @@ -131,16 +131,26 @@ impl From for LogRecord { .severity_number .map(|u| u as u32) .unwrap_or_default(), - attributes: value - .record - .attributes - .map(|attrs| { - attrs - .into_iter() - .map(|(key, value)| (key, value).into()) - .collect() - }) - .unwrap_or_default(), + attributes: { + let mut attributes = value + .record + .attributes + .unwrap_or_default() + .into_iter() + .map(|(key, value)| (key, value).into()) + .collect::>(); + + if let Some(event_name) = &value.record.event_name { + attributes.push( + ( + opentelemetry::Key::from("name"), + opentelemetry::Value::String(event_name.to_owned().into()), + ) + .into(), + ) + } + attributes + }, dropped_attributes_count: 0, severity_text: value.record.severity_text, body: value.record.body.map(|a| a.into()),