Skip to content

Commit

Permalink
update stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb committed Jul 12, 2024
1 parent 853e16f commit 820911c
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions opentelemetry-stdout/src/logs/transform.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -131,16 +131,26 @@ impl From<opentelemetry_sdk::export::logs::LogData> 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::<Vec<_>>();

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()),
Expand Down

0 comments on commit 820911c

Please sign in to comment.