Skip to content

Commit

Permalink
reorder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
psandana committed Mar 12, 2024
1 parent bf06008 commit 85cf5ea
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions opentelemetry-etw-logs/src/logs/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,55 @@ impl ETWExporter {
}
}

Check warning on line 233 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L215-L233

Added lines #L215 - L233 were not covered by tests

fn populate_part_b(
&self,
event: &mut tld::EventBuilder,
log_data: &opentelemetry_sdk::export::logs::LogData,
level: tld::Level,
event_id: Option<i64>,
event_name: Option<&str>,
) {
// Count fields in PartB
const COUNT_TYPE_NAME: u8 = 1u8;
const COUNT_SEVERITY_NUMBER: u8 = 1u8;

let field_count = COUNT_TYPE_NAME
+ COUNT_SEVERITY_NUMBER
+ log_data.record.body.is_some() as u8
+ log_data.record.severity_text.is_some() as u8
+ event_id.is_some() as u8
+ event_name.is_some() as u8;

// Create PartB struct
event.add_struct("PartB", field_count, 0);

// Fill fields of PartB struct
event.add_str8("_typeName", "Logs", tld::OutType::Default, 0);

Check warning on line 258 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L235-L258

Added lines #L235 - L258 were not covered by tests

if let Some(body) = log_data.record.body.clone() {
add_attribute_to_event(event, &Key::new("body"), &body);
}

Check warning on line 262 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L260-L262

Added lines #L260 - L262 were not covered by tests

event.add_u8("severityNumber", level.as_int(), tld::OutType::Default, 0);

Check warning on line 264 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L264

Added line #L264 was not covered by tests

if let Some(severity_text) = &log_data.record.severity_text {
event.add_str8(
"severityText",
severity_text.as_ref(),
tld::OutType::Default,
0,
);
}

Check warning on line 273 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L266-L273

Added lines #L266 - L273 were not covered by tests

if let Some(event_id) = event_id {
event.add_i64("eventId", event_id, tld::OutType::Default, 0);
}

Check warning on line 277 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L275-L277

Added lines #L275 - L277 were not covered by tests

if let Some(event_name) = event_name {
event.add_str8("name", event_name, tld::OutType::Default, 0);
}
}

Check warning on line 282 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L279-L282

Added lines #L279 - L282 were not covered by tests

fn populate_part_c<'a>(
&'a self,
event: &mut tld::EventBuilder,
Expand Down Expand Up @@ -286,55 +335,6 @@ impl ETWExporter {

return (event_id, event_name);
}

Check warning on line 337 in opentelemetry-etw-logs/src/logs/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-etw-logs/src/logs/exporter.rs#L336-L337

Added lines #L336 - L337 were not covered by tests

fn populate_part_b(
&self,
event: &mut tld::EventBuilder,
log_data: &opentelemetry_sdk::export::logs::LogData,
level: tld::Level,
event_id: Option<i64>,
event_name: Option<&str>,
) {
// Count fields in PartB
const COUNT_TYPE_NAME: u8 = 1u8;
const COUNT_SEVERITY_NUMBER: u8 = 1u8;

let field_count = COUNT_TYPE_NAME
+ COUNT_SEVERITY_NUMBER
+ log_data.record.body.is_some() as u8
+ log_data.record.severity_text.is_some() as u8
+ event_id.is_some() as u8
+ event_name.is_some() as u8;

// Create PartB struct
event.add_struct("PartB", field_count, 0);

// Fill fields of PartB struct
event.add_str8("_typeName", "Logs", tld::OutType::Default, 0);

if let Some(body) = log_data.record.body.clone() {
add_attribute_to_event(event, &Key::new("body"), &body);
}

event.add_u8("severityNumber", level.as_int(), tld::OutType::Default, 0);

if let Some(severity_text) = &log_data.record.severity_text {
event.add_str8(
"severityText",
severity_text.as_ref(),
tld::OutType::Default,
0,
);
}

if let Some(event_id) = event_id {
event.add_i64("eventId", event_id, tld::OutType::Default, 0);
}

if let Some(event_name) = event_name {
event.add_str8("name", event_name, tld::OutType::Default, 0);
}
}
}

impl Debug for ETWExporter {
Expand Down

0 comments on commit 85cf5ea

Please sign in to comment.