Class ResourceDetector
java.lang.Object
codes.grow.packages.otelcollector.ResourceDetector
Best-effort client-side resource detection:
host (host.name, host.arch,
os.type, os.version), process (process.pid,
process.executable.path, process.runtime.*, process.owner), container
(container.id from cgroups) and k8s (k8s.pod.name,
k8s.namespace.name, … from the downward-API variables K8S_* / POD_*,
HOSTNAME and the service-account namespace file). Detectors that find nothing add nothing.-
Method Summary
Modifier and TypeMethodDescriptionContainer id from/proc/self/cgroup(cgroup v1) or/proc/self/mountinfo(cgroup v2).detect(Collection<String> detectors) Runs the given detectors.static ResourceDetectorA detector over explicit sources (tests).static ResourceDetectorsystem()A detector over the process environment and file system.
-
Method Details
-
system
A detector over the process environment and file system.- Returns:
- the detector
-
of
public static ResourceDetector of(Map<String, String> env, Function<String, Optional<String>> readFile) A detector over explicit sources (tests).- Parameters:
env- environment variablesreadFile- reads a text file, empty when it cannot- Returns:
- the detector
-
detect
Runs the given detectors.- Parameters:
detectors- names:host,process,container,k8s- Returns:
- the detected attributes
-
containerId
Container id from/proc/self/cgroup(cgroup v1) or/proc/self/mountinfo(cgroup v2).- Returns:
- the 64-hex id, or empty
-