### Question:
CGroupMetrics extends AbstractLifecycleListener { void bindTo(MetricRegistry metricRegistry) { if (cgroupFiles != null) { metricRegistry.addUnlessNan("system.process.cgroup.memory.mem.usage.bytes", Labels.EMPTY, new DoubleSupplier() { @Override public double get() { try (BufferedReader fileReaderMemoryUsed = new BufferedReader(new FileReader(cgroupFiles.getUsedMemoryFile()))) { return Long.parseLong(fileReaderMemoryUsed.readLine()); } catch (Exception e) { logger.debug("Failed to read " + cgroupFiles.getUsedMemoryFile().getAbsolutePath() + " file", e); return Double.NaN; } } }); final File maxMemoryFile = cgroupFiles.getMaxMemoryFile(); if (maxMemoryFile != null) { metricRegistry.addUnlessNan("system.process.cgroup.memory.mem.limit.bytes", Labels.EMPTY, new DoubleSupplier() { @Override public double get() { try (BufferedReader fileReaderMemoryMax = new BufferedReader(new FileReader(maxMemoryFile))) { return Long.parseLong(fileReaderMemoryMax.readLine()); } catch (Exception e) { logger.debug("Failed to read " + maxMemoryFile + " file", e); return Double.NaN; } } }); } } } CGroupMetrics();   CGroupMetrics(File procSelfCgroup, File mountInfo); @Override void start(ElasticApmTracer tracer);  }### Answer:
@Test void testUnlimitedCgroup1() throws Exception { CGroupMetrics cgroupMetrics = createUnlimitedSystemMetrics(); cgroupMetrics.bindTo(metricRegistry); assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.limit.bytes", Labels.EMPTY)).isEqualTo(Double.NaN); assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.usage.bytes", Labels.EMPTY)).isEqualTo(964778496); }
@Test void testUnlimitedCgroup2() throws Exception { CGroupMetrics cgroupMetrics = createUnlimitedSystemMetrics(); cgroupMetrics.bindTo(metricRegistry); assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.limit.bytes", Labels.EMPTY)).isEqualTo(Double.NaN); assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.usage.bytes", Labels.EMPTY)).isEqualTo(964778496); }