Class ContainerCollector

java.lang.Object
io.fluxzero.sdk.tracking.metrics.host.collectors.ContainerCollector
All Implemented Interfaces:
MetricCollector<ContainerMetrics>

public class ContainerCollector extends Object implements MetricCollector<ContainerMetrics>
Collector for container metrics from cgroups (v1 and v2).

Automatically detects cgroup version and collects CPU and memory metrics when running in a containerized environment.

  • Constructor Details

    • ContainerCollector

      public ContainerCollector()
  • Method Details

    • collect

      public Optional<ContainerMetrics> collect()
      Description copied from interface: MetricCollector
      Collects metrics.
      Specified by:
      collect in interface MetricCollector<ContainerMetrics>
      Returns:
      an Optional containing the collected metrics, or empty if collection failed or the metrics are not available on this platform
    • isAvailable

      public boolean isAvailable()
      Description copied from interface: MetricCollector
      Checks if this collector is available on the current platform.

      This method should return quickly and may cache its result.

      Specified by:
      isAvailable in interface MetricCollector<ContainerMetrics>
      Returns:
      true if this collector can collect metrics on the current platform