Skip to content

Commit 820911c

Browse files
committed
update stdout
1 parent 853e16f commit 820911c

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

opentelemetry-stdout/src/logs/transform.rs

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{borrow::Cow, collections::HashMap, time::SystemTime};
22

33
use crate::common::{
4-
as_human_readable, as_opt_human_readable, as_opt_unix_nano, as_unix_nano, AttributeSet,
4+
as_human_readable, as_opt_human_readable, as_opt_unix_nano, as_unix_nano, AttributeSet, Key,
55
KeyValue, Resource, Scope, Value,
66
};
77
use serde::Serialize;
@@ -131,16 +131,26 @@ impl From<opentelemetry_sdk::export::logs::LogData> for LogRecord {
131131
.severity_number
132132
.map(|u| u as u32)
133133
.unwrap_or_default(),
134-
attributes: value
135-
.record
136-
.attributes
137-
.map(|attrs| {
138-
attrs
139-
.into_iter()
140-
.map(|(key, value)| (key, value).into())
141-
.collect()
142-
})
143-
.unwrap_or_default(),
134+
attributes: {
135+
let mut attributes = value
136+
.record
137+
.attributes
138+
.unwrap_or_default()
139+
.into_iter()
140+
.map(|(key, value)| (key, value).into())
141+
.collect::<Vec<_>>();
142+
143+
if let Some(event_name) = &value.record.event_name {
144+
attributes.push(
145+
(
146+
opentelemetry::Key::from("name"),
147+
opentelemetry::Value::String(event_name.to_owned().into()),
148+
)
149+
.into(),
150+
)
151+
}
152+
attributes
153+
},
144154
dropped_attributes_count: 0,
145155
severity_text: value.record.severity_text,
146156
body: value.record.body.map(|a| a.into()),

0 commit comments

Comments
 (0)