@@ -3,11 +3,15 @@ use newrelic_super_agent::opamp::instance_id::getter::ULIDInstanceIDGetter;
33use newrelic_super_agent:: opamp:: instance_id:: { self , Identifiers , Storer } ;
44use newrelic_super_agent:: opamp:: remote_config_hash:: HashRepositoryFile ;
55use newrelic_super_agent:: sub_agent:: values:: values_repository:: ValuesRepositoryFile ;
6- use newrelic_super_agent:: super_agent:: defaults:: SUPER_AGENT_TYPE ;
76use newrelic_super_agent:: super_agent:: error:: AgentError ;
87use newrelic_super_agent:: super_agent:: opamp:: client_builder:: SuperAgentOpAMPHttpBuilder ;
9- use newrelic_super_agent:: super_agent:: super_agent:: { SuperAgent , SuperAgentEvent } ;
8+ use newrelic_super_agent:: super_agent:: super_agent:: {
9+ super_agent_fqn, SuperAgent , SuperAgentEvent ,
10+ } ;
1011use newrelic_super_agent:: { cli:: Cli , context:: Context , logging:: Logging } ;
12+ use nix:: unistd:: gethostname;
13+ use opamp_client:: operation:: settings:: DescriptionValueType ;
14+ use std:: collections:: HashMap ;
1115use std:: error:: Error ;
1216use tracing:: { error, info} ;
1317
@@ -83,11 +87,8 @@ fn run_super_agent(
8387 opamp_client_builder : Option < SuperAgentOpAMPHttpBuilder > ,
8488 instance_id_getter : ULIDInstanceIDGetter < Storer > ,
8589) -> Result < ( ) , AgentError > {
86- use std:: collections:: HashMap ;
87-
8890 use newrelic_super_agent:: {
89- config:: super_agent_configs:: { AgentID , AgentTypeFQN } ,
90- opamp:: operations:: build_opamp_and_start_client,
91+ config:: super_agent_configs:: AgentID , opamp:: operations:: build_opamp_and_start_client,
9192 sub_agent:: opamp:: client_builder:: SubAgentOpAMPHttpBuilder ,
9293 super_agent:: effective_agents_assembler:: LocalEffectiveAgentsAssembler ,
9394 } ;
@@ -119,8 +120,8 @@ fn run_super_agent(
119120 opamp_client_builder. as_ref ( ) ,
120121 & instance_id_getter,
121122 AgentID :: new_super_agent_id ( ) ,
122- & AgentTypeFQN :: from ( SUPER_AGENT_TYPE ) ,
123- HashMap :: new ( ) ,
123+ & super_agent_fqn ( ) ,
124+ super_agent_opamp_non_identifying_attributes ( ) ,
124125 ) ?;
125126
126127 SuperAgent :: new (
@@ -141,11 +142,8 @@ fn run_super_agent(
141142 opamp_client_builder : Option < SuperAgentOpAMPHttpBuilder > ,
142143 instance_id_getter : ULIDInstanceIDGetter < Storer > ,
143144) -> Result < ( ) , AgentError > {
144- use std:: collections:: HashMap ;
145-
146145 use newrelic_super_agent:: {
147- config:: super_agent_configs:: { AgentID , AgentTypeFQN } ,
148- opamp:: operations:: build_opamp_and_start_client,
146+ config:: super_agent_configs:: AgentID , opamp:: operations:: build_opamp_and_start_client,
149147 } ;
150148
151149 let hash_repository = HashRepositoryFile :: default ( ) ;
@@ -163,8 +161,8 @@ fn run_super_agent(
163161 opamp_client_builder. as_ref ( ) ,
164162 & instance_id_getter,
165163 AgentID :: new_super_agent_id ( ) ,
166- & AgentTypeFQN :: from ( SUPER_AGENT_TYPE ) ,
167- HashMap :: new ( ) ,
164+ & super_agent_fqn ( ) ,
165+ super_agent_opamp_non_identifying_attributes ( ) ,
168166 ) ?;
169167
170168 SuperAgent :: new (
@@ -190,3 +188,14 @@ fn create_shutdown_signal_handler(
190188
191189 Ok ( ( ) )
192190}
191+
192+ fn super_agent_opamp_non_identifying_attributes ( ) -> HashMap < String , DescriptionValueType > {
193+ HashMap :: from ( [ (
194+ "host.name" . to_string ( ) ,
195+ gethostname ( )
196+ . unwrap_or_default ( )
197+ . into_string ( )
198+ . unwrap ( )
199+ . into ( ) ,
200+ ) ] )
201+ }
0 commit comments