Skip to content

Commit

Permalink
Merge pull request #202 from dynatrace-oss-contrib/feat/add_display_name
Browse files Browse the repository at this point in the history
Add display_name field
  • Loading branch information
lquerel authored Jun 13, 2024
2 parents 7f675c7 + f9ee8b7 commit 1f5075c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion crates/weaver_forge/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ pub struct ResolvedGroup {
/// The name of the event. If not specified, the prefix is used.
/// If prefix is empty (or unspecified), name is required.
pub name: Option<String>,

/// The lineage of the group.
#[serde(skip_serializing_if = "Option::is_none")]
pub lineage: Option<GroupLineage>,
/// The readable name for attribute groups used when generating registry tables.
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
}

impl ResolvedGroup {
Expand Down Expand Up @@ -153,6 +155,7 @@ impl ResolvedGroup {
unit: group.unit.clone(),
name: group.name.clone(),
lineage,
display_name: group.display_name.clone(),
})
}
}
Expand Down Expand Up @@ -211,6 +214,7 @@ impl ResolvedRegistry {
unit: group.unit.clone(),
name: group.name.clone(),
lineage,
display_name: group.display_name.clone(),
}
})
.collect();
Expand Down
4 changes: 3 additions & 1 deletion crates/weaver_resolved_schema/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ pub struct Group {
/// If prefix is empty (or unspecified), name is required.
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,

/// The lineage of the group.
#[serde(skip_serializing_if = "Option::is_none")]
pub lineage: Option<GroupLineage>,
/// The readable name for attribute groups used when generating registry tables.
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
}

/// Common statistics for a group.
Expand Down
1 change: 1 addition & 0 deletions crates/weaver_resolver/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ fn group_from_spec(group: GroupSpecWithProvenance) -> UnresolvedGroup {
unit: group.spec.unit,
name: group.spec.name,
lineage: Some(GroupLineage::new(&group.provenance)),
display_name: group.spec.display_name,
},
attributes: attrs,
provenance: group.provenance,
Expand Down
1 change: 1 addition & 0 deletions crates/weaver_semconv/data/faas-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ groups:
- id: attributes.faas.common
type: attribute_group
brief: "Describes FaaS attributes."
display_name: "FaaS Attributes"
prefix: faas
attributes:
- id: trigger
Expand Down
4 changes: 4 additions & 0 deletions crates/weaver_semconv/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ pub struct GroupSpec {
/// The name of the event. If not specified, the prefix is used.
/// If prefix is empty (or unspecified), name is required.
pub name: Option<String>,
/// The readable name for attribute groups used when generating registry tables.
pub display_name: Option<String>,
}

impl GroupSpec {
Expand Down Expand Up @@ -331,6 +333,7 @@ mod tests {
instrument: None,
unit: None,
name: None,
display_name: None,
};
assert!(group.validate("<test>").is_ok());

Expand Down Expand Up @@ -430,6 +433,7 @@ mod tests {
instrument: None,
unit: None,
name: None,
display_name: None,
};
assert!(group.validate("<test>").is_ok());

Expand Down
2 changes: 2 additions & 0 deletions crates/weaver_semconv/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ mod tests {
deprecated: None,
events: vec![],
name: None,
display_name: Some("Group 1".to_owned()),
}],
},
),
Expand All @@ -283,6 +284,7 @@ mod tests {
deprecated: None,
events: vec![],
name: None,
display_name: Some("Group 2".to_owned()),
}],
},
),
Expand Down

0 comments on commit 1f5075c

Please sign in to comment.