Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion crates/health/src/otlp/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ fn resource_attributes(context: &EventContext) -> Vec<KeyValue> {
if let Some(component_type) = context.component_type() {
attrs.push(KeyValue::new("component.type", component_type.to_string()));
}
if let Some(power_shelf_id) = context.power_shelf_id() {
attrs.push(KeyValue::new("power_shelf.id", power_shelf_id.to_string()));
Comment thread
joseph-shifflett marked this conversation as resolved.
}
if context.component_type() == Some("power_shelf")
&& let Some(serial) = context.serial_number()
Comment thread
joseph-shifflett marked this conversation as resolved.
{
attrs.push(KeyValue::new(
"power_shelf.serial_number",
serial.to_string(),
));
}
if let Some(switch_id) = context.switch_id() {
attrs.push(KeyValue::new("switch.id", switch_id.to_string()));
}
Expand Down Expand Up @@ -904,10 +915,11 @@ mod tests {
}

#[test]
fn resource_attributes_include_power_shelf_component_type() {
fn resource_attributes_include_power_shelf_identity() {
let power_shelf_id =
PowerShelfId::from_str("ps100ht038bg3qsho433vkg684heguv282qaggmrsh2ugn1qk096n2c6hcg")
.expect("valid power shelf id");
let power_shelf_id_string = power_shelf_id.to_string();
let context = EventContext {
endpoint_key: "33:44:55:66:77:88".to_string(),
addr: BmcAddr {
Expand All @@ -927,6 +939,14 @@ mod tests {
let attrs = otlp_resource_attributes(&context);

assert_eq!(attr_value(&attrs, "component.type"), Some("power_shelf"));
assert_eq!(
attr_value(&attrs, "power_shelf.id"),
Some(power_shelf_id_string.as_str())
);
assert_eq!(
attr_value(&attrs, "power_shelf.serial_number"),
Some("SN-PS-001")
);
assert_eq!(attr_value(&attrs, "rack.id"), Some("RACK_4"));
}

Expand Down
Loading