Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions agent-control/src/agent_control/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub const HOST_NAME_ATTRIBUTE_KEY: &str = opentelemetry_semantic_conventions::at
pub const CLUSTER_NAME_ATTRIBUTE_KEY: &str = "cluster.name";
pub const HOST_ID_ATTRIBUTE_KEY: &str = opentelemetry_semantic_conventions::attribute::HOST_ID;
pub const FLEET_ID_ATTRIBUTE_KEY: &str = "fleet.guid";
pub const CD_EXTERNAL_ENABLED_ATTRIBUTE_KEY: &str = "cd.external.enabled";
pub const CD_REMOTE_UPDATE_ENABLED_ATTRIBUTE_KEY: &str = "cd.remote_update.enabled";

pub const OS_ATTRIBUTE_KEY: &str = "os.type";
#[cfg(target_os = "macos")]
Expand Down
14 changes: 12 additions & 2 deletions agent-control/src/agent_control/run/k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use crate::agent_control::config_repository::store::AgentControlConfigStore;
use crate::agent_control::config_validator::RegistryDynamicConfigValidator;
use crate::agent_control::config_validator::k8s::K8sReleaseNamesConfigValidator;
use crate::agent_control::defaults::{
AGENT_CONTROL_VERSION, CLUSTER_NAME_ATTRIBUTE_KEY, FLEET_ID_ATTRIBUTE_KEY,
AGENT_CONTROL_VERSION, CD_EXTERNAL_ENABLED_ATTRIBUTE_KEY,
CD_REMOTE_UPDATE_ENABLED_ATTRIBUTE_KEY, CLUSTER_NAME_ATTRIBUTE_KEY, FLEET_ID_ATTRIBUTE_KEY,
HOST_NAME_ATTRIBUTE_KEY, OPAMP_AC_CHART_VERSION_ATTRIBUTE_KEY,
OPAMP_AGENT_VERSION_ATTRIBUTE_KEY, OPAMP_CD_CHART_VERSION_ATTRIBUTE_KEY,
};
Expand Down Expand Up @@ -90,7 +91,7 @@ impl AgentControlRunner {
info!("Instance Identifiers: {}", identifiers);

let non_identifying_attributes =
agent_control_opamp_non_identifying_attributes(&identifiers);
agent_control_opamp_non_identifying_attributes(&identifiers, &self.k8s_config);

let additional_identifying_attributes =
agent_control_additional_opamp_identifying_attributes(&self.k8s_config);
Expand Down Expand Up @@ -292,6 +293,7 @@ fn start_cd_version_checker(

pub fn agent_control_opamp_non_identifying_attributes(
identifiers: &Identifiers,
k8s_config: &K8sConfig,
) -> HashMap<String, DescriptionValueType> {
let hostname = get_hostname().unwrap_or_else(|e| {
error!("cannot retrieve hostname: {}", e.to_string());
Expand All @@ -308,6 +310,14 @@ pub fn agent_control_opamp_non_identifying_attributes(
CLUSTER_NAME_ATTRIBUTE_KEY.to_string(),
identifiers.cluster_name.clone().into(),
),
(
CD_EXTERNAL_ENABLED_ATTRIBUTE_KEY.to_string(),
(k8s_config.cd_release_name.is_empty()).into(),
),
(
CD_REMOTE_UPDATE_ENABLED_ATTRIBUTE_KEY.to_string(),
k8s_config.cd_remote_update.into(),
),
])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ k8s:
namespace_agents: <agents-ns>
cluster_name: <cluster-name>
current_chart_version: 1.2.3-beta
cd_release_name: agent-control-cd
agents: {}
8 changes: 7 additions & 1 deletion agent-control/tests/k8s/scenarios/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use crate::k8s::tools::{
};
use newrelic_agent_control::agent_control::agent_id::AgentID;
use newrelic_agent_control::agent_control::defaults::{
AGENT_CONTROL_VERSION, CLUSTER_NAME_ATTRIBUTE_KEY, FLEET_ID_ATTRIBUTE_KEY,
AGENT_CONTROL_VERSION, CD_EXTERNAL_ENABLED_ATTRIBUTE_KEY,
CD_REMOTE_UPDATE_ENABLED_ATTRIBUTE_KEY, CLUSTER_NAME_ATTRIBUTE_KEY, FLEET_ID_ATTRIBUTE_KEY,
HOST_NAME_ATTRIBUTE_KEY, OPAMP_AGENT_VERSION_ATTRIBUTE_KEY, OPAMP_SERVICE_NAME,
OPAMP_SERVICE_NAMESPACE, OPAMP_SERVICE_VERSION, OPAMP_SUBAGENT_CHART_VERSION_ATTRIBUTE_KEY,
OPAMP_SUPERVISOR_KEY, PARENT_AGENT_ID_ATTRIBUTE_KEY,
Expand Down Expand Up @@ -96,6 +97,11 @@ agents:
CLUSTER_NAME_ATTRIBUTE_KEY,
Value::StringValue("minikube".to_string()),
),
(CD_EXTERNAL_ENABLED_ATTRIBUTE_KEY, Value::BoolValue(false)),
(
CD_REMOTE_UPDATE_ENABLED_ATTRIBUTE_KEY,
Value::BoolValue(false),
),
]));

// Check attributes of Agent Control
Expand Down
Loading