Documentation
¶
Overview ¶
Package runtime detects the container/process runtime (Kubernetes, Docker, Podman, systemd-managed, or plain binary) and exposes a unified Info so the rest of the framework can attach identity metadata to logs/metrics/traces without caring where the process runs.
This package is the runtime-agnostic successor to k8s/podinfo:
- On Kubernetes it reads the downward-API env vars (POD_NAME, POD_NAMESPACE, POD_IP, NODE_NAME, SERVICE_ACCOUNT) plus the container ID from cgroups.
- On Docker / Podman it reads the container ID from cgroups + HOSTNAME.
- On systemd it reads INVOCATION_ID + NOTIFY_SOCKET presence to identify the unit.
- On bare Linux it falls back to os.Hostname().
`k8s/podinfo` remains as a k8s-only view for packages that want just the k8s fields; new code should prefer `container/runtime`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Module provides Info via fx.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
// Runtime is the detected platform.
Runtime Runtime
// Hostname is os.Hostname(). Always populated.
Hostname string
// ContainerID is the 12+ char container ID from /proc/self/cgroup,
// or empty if the runtime doesn't expose it.
ContainerID string
// PodName, Namespace, PodIP, NodeName, ServiceAccount, ContainerName,
// ContainerImage: populated on Kubernetes via the downward API.
PodName string
Namespace string
PodIP string
NodeName string
ServiceAccount string
ContainerName string
ContainerImage string
// SystemdUnit is populated when Runtime == RuntimeSystemd, from the
// SYSTEMD_UNIT env var (if set by the unit file) or falls back to the
// INVOCATION_ID.
SystemdUnit string
}
Info is the unified identity of the running process.
Click to show internal directories.
Click to hide internal directories.