1- use crate :: agent_control:: defaults:: { HOST_NAME_ATTRIBUTE_KEY , OPAMP_SERVICE_VERSION } ;
1+ use crate :: agent_control:: defaults:: {
2+ HOST_NAME_ATTRIBUTE_KEY , OPAMP_SERVICE_VERSION , OS_ATTRIBUTE_KEY , OS_VERSION_ATTRIBUTE_VALUE ,
3+ } ;
24use crate :: agent_control:: run:: Environment ;
35use crate :: agent_type:: runtime_config:: on_host:: filesystem:: rendered:: FileSystemEntries ;
46use crate :: event:: SubAgentEvent ;
@@ -18,6 +20,7 @@ use crate::{
1820 opamp:: client_builder:: OpAMPClientBuilder ,
1921 sub_agent:: { SubAgentBuilder , error:: SubAgentBuilderError } ,
2022} ;
23+ use opamp_client:: operation:: settings:: DescriptionValueType ;
2124use resource_detection:: system:: hostname:: get_hostname;
2225use std:: collections:: HashMap ;
2326use std:: path:: PathBuf ;
@@ -105,7 +108,13 @@ where
105108 OPAMP_SERVICE_VERSION . to_string ( ) ,
106109 agent_identity. agent_type_id . version ( ) . to_string ( ) . into ( ) ,
107110 ) ] ) ,
108- HashMap :: from ( [ ( HOST_NAME_ATTRIBUTE_KEY . to_string ( ) , hostname) ] ) ,
111+ HashMap :: from ( [
112+ ( HOST_NAME_ATTRIBUTE_KEY . to_string ( ) , hostname) ,
113+ (
114+ OS_ATTRIBUTE_KEY . to_string ( ) ,
115+ DescriptionValueType :: String ( OS_VERSION_ATTRIBUTE_VALUE . to_string ( ) ) ,
116+ ) ,
117+ ] ) ,
109118 )
110119 . map_err ( |e| SubAgentBuilderError :: OpampClientBuilderError ( e. to_string ( ) ) )
111120 } )
@@ -183,9 +192,8 @@ impl SupervisorBuilder for SupervisortBuilderOnHost {
183192mod tests {
184193 use super :: * ;
185194 use crate :: agent_control:: agent_id:: AgentID ;
186-
187195 use crate :: agent_control:: defaults:: {
188- OPAMP_SERVICE_NAME , OPAMP_SERVICE_NAMESPACE , OPAMP_SERVICE_VERSION ,
196+ OPAMP_SERVICE_INSTANCE_ID , OPAMP_SERVICE_NAME , OPAMP_SERVICE_NAMESPACE ,
189197 PARENT_AGENT_ID_ATTRIBUTE_KEY , default_capabilities, default_sub_agent_custom_capabilities,
190198 } ;
191199 use crate :: agent_type:: agent_type_id:: AgentTypeID ;
@@ -237,7 +245,7 @@ mod tests {
237245 & hostname,
238246 agent_control_instance_id. clone ( ) ,
239247 sub_agent_instance_id. clone ( ) ,
240- & agent_identity. agent_type_id ,
248+ & agent_identity,
241249 ) ;
242250
243251 let agent_control_id = AgentID :: AgentControl ;
@@ -354,7 +362,7 @@ mod tests {
354362 & hostname,
355363 agent_control_instance_id. clone ( ) ,
356364 sub_agent_instance_id. clone ( ) ,
357- & agent_identity. agent_type_id ,
365+ & agent_identity,
358366 ) ;
359367
360368 let remote_config_values = RemoteConfig {
@@ -461,17 +469,24 @@ mod tests {
461469 hostname : & str ,
462470 agent_control_instance_id : InstanceID ,
463471 sub_agent_instance_id : InstanceID ,
464- agent_fqn : & AgentTypeID ,
472+ agent_identity : & AgentIdentity ,
465473 ) -> StartSettings {
466474 let identifying_attributes = HashMap :: < String , DescriptionValueType > :: from ( [
467- ( OPAMP_SERVICE_NAME . to_string ( ) , agent_fqn. name ( ) . into ( ) ) ,
475+ (
476+ OPAMP_SERVICE_NAME . to_string ( ) ,
477+ agent_identity. agent_type_id . name ( ) . into ( ) ,
478+ ) ,
468479 (
469480 OPAMP_SERVICE_NAMESPACE . to_string ( ) ,
470- agent_fqn. namespace ( ) . into ( ) ,
481+ agent_identity. agent_type_id . namespace ( ) . into ( ) ,
482+ ) ,
483+ (
484+ OPAMP_SERVICE_INSTANCE_ID . to_string ( ) ,
485+ agent_identity. id . to_string ( ) . into ( ) ,
471486 ) ,
472487 (
473488 OPAMP_SERVICE_VERSION . to_string ( ) ,
474- agent_fqn . version ( ) . to_string ( ) . into ( ) ,
489+ agent_identity . agent_type_id . version ( ) . to_string ( ) . into ( ) ,
475490 ) ,
476491 ] ) ;
477492 StartSettings {
@@ -489,6 +504,10 @@ mod tests {
489504 PARENT_AGENT_ID_ATTRIBUTE_KEY . to_string ( ) ,
490505 DescriptionValueType :: Bytes ( agent_control_instance_id. into ( ) ) ,
491506 ) ,
507+ (
508+ OS_ATTRIBUTE_KEY . to_string ( ) ,
509+ OS_VERSION_ATTRIBUTE_VALUE . into ( ) ,
510+ ) ,
492511 ] ) ,
493512 } ,
494513 }
0 commit comments