UUID v4 generation and correlation ID utilities.
Provides a dependency-free UUID v4 generator using :crypto.strong_rand_bytes/1
and a short correlation ID format suitable for log tracing.
Summary
Functions
Generates a short correlation ID (16 hex chars) for use in log tracing.
Generates a RFC 4122 UUID v4 string.
Returns true if the given string is a valid UUID v4.
Functions
@spec correlation_id() :: String.t()
Generates a short correlation ID (16 hex chars) for use in log tracing.
Shorter than a full UUID — suitable for HTTP headers and log fields.
Example
iex> PhoenixMicro.Utils.ID.correlation_id()
"a3f2e1b4c8d9e0f1"
@spec uuid4() :: String.t()
Generates a RFC 4122 UUID v4 string.
Uses :crypto.strong_rand_bytes/1 — no external dependencies.
Example
iex> PhoenixMicro.Utils.ID.uuid4()
"550e8400-e29b-41d4-a716-446655440000"
Returns true if the given string is a valid UUID v4.
Example
iex> PhoenixMicro.Utils.ID.valid_uuid?("550e8400-e29b-41d4-a716-446655440000")
true