Documentation
¶
Overview ¶
Package userid exposes the persistent UUID identifying this cagent installation. The value is stored in `$configDir/user-uuid`, generated lazily on first use, and shared across cagent runs on the same machine.
It is consumed both by telemetry (as the `user_uuid` event property) and by the HTTP transport (as the `X-Cagent-Id` header on gateway-bound requests) so that the gateway can correlate calls made by the same cagent install without having to invent a new identifier.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get() string
Get returns the persistent UUID using the default resolver, which reads from paths.GetConfigDir.
Types ¶
type Resolver ¶ added in v1.92.0
type Resolver struct {
// contains filtered or unexported fields
}
Resolver owns the directory it reads from and the in-memory cache of the resolved UUID. Each instance is fully independent, so tests can create one per testing.T.TempDir and run in parallel without sharing any global state.
func (*Resolver) Get ¶ added in v1.92.0
Get returns the persistent UUID identifying this cagent installation.
On the first call it tries to read the value from `<dir>/user-uuid`; if the file does not exist, is empty, contains an invalid UUID, or cannot be read, a fresh UUID is generated and persisted (best effort). The result is cached in memory for the lifetime of the resolver so subsequent calls do not touch the filesystem.