datadog_agent_remote_config/
identity.rs

1//! How the client presents itself to the Agent.
2
3/// The kind of client the Agent sees, and the details that kind reports.
4///
5/// The Agent requires every client to be exactly one kind, and checks that the details for that kind are present.
6#[derive(Clone, Debug)]
7#[non_exhaustive]
8pub enum ClientKind {
9    // TODO: consider Tracer and Updater variants if a use case needs them; this is an enum so they can be added
10    // without changing the settings. A tracer's details decide which configurations it receives, through the Agent's
11    // tracer predicates, and a tracer advertises capabilities. An updater reports the state of the packages it
12    // manages, which changes while it runs, so it would need a way to update that state on a running client.
13    /// A Datadog Agent process, or a process that runs alongside one.
14    Agent(AgentIdentity),
15}
16
17/// What an [`Agent`](ClientKind::Agent) client reports.
18///
19/// The Agent does not act on any of these fields. It forwards them to the Datadog backend and lists them among its
20/// active clients in `datadog-agent remote-config`.
21#[derive(Clone, Debug)]
22pub struct AgentIdentity {
23    /// The name of the running application, such as `agent-data-plane`.
24    ///
25    /// Sent as `client_agent.name` in every poll. Must not be empty.
26    ///
27    /// Has no default.
28    pub name: String,
29
30    /// The version of the running application, such as `1.7.0`.
31    ///
32    /// Sent as `client_agent.version` in every poll. Must not be empty.
33    ///
34    /// Has no default.
35    pub version: String,
36
37    /// The name of the Kubernetes cluster the application manages. Optional, and only for a cluster-level agent.
38    ///
39    /// Sent as `client_agent.cluster_name` in every poll. The Cluster Agent reports it; an agent that runs on a single
40    /// host leaves it unset, which sends it empty.
41    ///
42    /// Defaults to `None`.
43    pub cluster_name: Option<String>,
44
45    /// The ID of the Kubernetes cluster the application manages. Optional, and only for a cluster-level agent.
46    ///
47    /// Sent as `client_agent.cluster_id` in every poll. The Cluster Agent reports it; an agent that runs on a single
48    /// host leaves it unset, which sends it empty.
49    ///
50    /// Defaults to `None`.
51    pub cluster_id: Option<String>,
52}
53
54impl AgentIdentity {
55    /// Creates the identity of an agent named `name` at `version`, with no cluster.
56    pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self {
57        Self {
58            name: name.into(),
59            version: version.into(),
60            cluster_name: None,
61            cluster_id: None,
62        }
63    }
64}