Documentation
¶
Overview ¶
Package uid is the single source of truth for entity identifiers.
Every entity uses a UUID primary key so that ids can be minted independently by the server or by a remote agent without coordination. There are two ways to obtain an id:
- New() mints a fresh time-ordered UUIDv7, for server-created entities and for telemetry events that have no stable natural key.
- Derive() computes a deterministic UUIDv5 from a natural key, so the agent and the server independently arrive at the same id for the same entity.
Index ¶
- Constants
- func Agent(agentID string) string
- func CertMonitor(agentID, hostname string, port int, serverName string) string
- func Container(agentID, externalID string) string
- func Derive(ns uuid.UUID, parts ...string) string
- func EndpointLabel(agentID, containerName, labelKey string) string
- func K8sNode(agentID, name string) string
- func K8sWorkload(agentID, workloadID string) string
- func Namespace(agentID, name string) string
- func New() string
- func Pod(agentID, namespace, name string) string
- func SwarmNode(agentID, nodeID string) string
- func SwarmService(agentID, serviceID string) string
- func SwarmTask(agentID, taskID string) string
Constants ¶
const LocalAgent = "00000000-0000-0000-0000-000000000000"
LocalAgent is the sentinel agent id for the server's own in-process runtime (as opposed to a remote enrolled agent). Locally discovered entities are attributed to it so that agent_id is never NULL and the (agent_id, natural key) identity is uniform across local and remote sources.
Variables ¶
This section is empty.
Functions ¶
func Agent ¶
Agent returns agentID, or LocalAgent when it is empty. Eases the transition from the old nullable agent_id where NULL/"" meant the local runtime.
func CertMonitor ¶
CertMonitor derives a cert monitor id from the agent, the monitored hostname:port and the optional SNI server name. An empty serverName keeps the historical three-part derivation so pre-SNI monitor ids are unchanged.
func Container ¶
Container derives a container id from the reporting agent and the runtime's external container id (Docker SHA / pod uid). Pass LocalAgent for the server's own runtime.
func Derive ¶
Derive returns a deterministic UUIDv5 string from a namespace and the parts of a natural key. The same inputs always yield the same id. Parts are trimmed and joined with a unit separator; callers normalize case per field (e.g. lowercase hostnames) before calling.
func EndpointLabel ¶
EndpointLabel derives a label-sourced endpoint id from the agent, the owning container name and the maintenant label key.
func K8sWorkload ¶
K8sWorkload derives a Kubernetes workload id from the agent and the workload's natural id ("{namespace}/{kind}/{name}").
func SwarmService ¶
SwarmService derives a swarm service id from the agent and the runtime service id.
Types ¶
This section is empty.