uid

package
v1.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

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

View Source
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

func Agent(agentID string) string

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

func CertMonitor(agentID, hostname string, port int, serverName string) string

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

func Container(agentID, externalID string) string

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

func Derive(ns uuid.UUID, parts ...string) string

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

func EndpointLabel(agentID, containerName, labelKey string) string

EndpointLabel derives a label-sourced endpoint id from the agent, the owning container name and the maintenant label key.

func K8sNode

func K8sNode(agentID, name string) string

K8sNode derives a Kubernetes node id from the agent and the node name.

func K8sWorkload

func K8sWorkload(agentID, workloadID string) string

K8sWorkload derives a Kubernetes workload id from the agent and the workload's natural id ("{namespace}/{kind}/{name}").

func Namespace

func Namespace(agentID, name string) string

Namespace derives a Kubernetes namespace id from the agent and the namespace name.

func New

func New() string

New returns a fresh time-ordered UUIDv7 string.

func Pod

func Pod(agentID, namespace, name string) string

Pod derives a Kubernetes pod id from the agent, namespace and pod name.

func SwarmNode

func SwarmNode(agentID, nodeID string) string

SwarmNode derives a swarm node id from the agent and the runtime node id.

func SwarmService

func SwarmService(agentID, serviceID string) string

SwarmService derives a swarm service id from the agent and the runtime service id.

func SwarmTask

func SwarmTask(agentID, taskID string) string

SwarmTask derives a swarm task id from the agent and the runtime task id.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL