Skip to content

Commit cea4237

Browse files
Remove cgroup inactive_file.bytes metric (#1422)
Remove cgroup inactive_file.bytes metric Co-authored-by: Sylvain Juge <[email protected]>
1 parent c609815 commit cea4237

File tree

4 files changed

+5
-38
lines changed

4 files changed

+5
-38
lines changed

CHANGELOG.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ endif::[]
2929
[float]
3030
===== Features
3131
* Migrate some plugins to indy dispatcher {pull}1362[1362] {pull}1366[1366] {pull}1363[1363] {pull}1383[1383] {pull}1368[1368] {pull}1364[1364] {pull}1365[1365] {pull}1367[1367] {pull}1371[1371]
32+
* Remove cgroup inactive_file.bytes metric {pull}1422[1422]
3233
3334
[float]
3435
===== Bug fixes

apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/CGroupMetrics.java

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -224,31 +224,6 @@ public void start(ElasticApmTracer tracer) {
224224

225225
void bindTo(MetricRegistry metricRegistry) {
226226
if (cgroupFiles != null) {
227-
metricRegistry.addUnlessNan("system.process.cgroup.memory.stats.inactive_file.bytes", Labels.EMPTY, new DoubleSupplier() {
228-
@Override
229-
public double get() {
230-
try (BufferedReader fileReaderStatFile = new BufferedReader(new FileReader(cgroupFiles.getStatMemoryFile()))) {
231-
String statLine = fileReaderStatFile.readLine();
232-
String inactiveBytes = null;
233-
while (statLine != null) {
234-
final String[] statLineSplit = StringUtils.split(statLine, ' ');
235-
if (statLineSplit.length > 1) {
236-
if ("total_inactive_file".equals(statLineSplit[0])) {
237-
inactiveBytes = statLineSplit[1];
238-
break;
239-
} else if ("inactive_file".equals(statLineSplit[0])) {
240-
inactiveBytes = statLineSplit[1];
241-
}
242-
}
243-
statLine = fileReaderStatFile.readLine();
244-
}
245-
return inactiveBytes != null ? Long.parseLong(inactiveBytes) : Double.NaN;
246-
} catch (Exception e) {
247-
logger.debug("Failed to read " + cgroupFiles.getStatMemoryFile().getAbsolutePath() + " file", e);
248-
return Double.NaN;
249-
}
250-
}
251-
});
252227

253228
metricRegistry.addUnlessNan("system.process.cgroup.memory.mem.usage.bytes", Labels.EMPTY, new DoubleSupplier() {
254229
@Override
@@ -301,6 +276,10 @@ public File getUsedMemoryFile() {
301276
return usedMemoryFile;
302277
}
303278

279+
/**
280+
* Not used at the moment, but contains useful info, so no harm of leaving without opening and reading from
281+
* @return the memory.stat file
282+
*/
304283
public File getStatMemoryFile() {
305284
return statMemoryFile;
306285
}

apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/CGroupMetricsTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ void testFreeCgroupMemory(long value, String selfCGroup, String sysFsGroup, Stri
8484

8585
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.usage.bytes", Labels.EMPTY)).isEqualTo(value);
8686
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.limit.bytes", Labels.EMPTY)).isEqualTo(Double.valueOf(memLimit));
87-
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.stats.inactive_file.bytes", Labels.EMPTY)).isEqualTo(10407936L);
8887
}
8988
@ParameterizedTest
9089
@ValueSource(strings ={
@@ -116,7 +115,6 @@ void testUnlimitedCgroup1() throws Exception {
116115

117116
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.limit.bytes", Labels.EMPTY)).isEqualTo(Double.NaN);
118117
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.usage.bytes", Labels.EMPTY)).isEqualTo(964778496);
119-
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.stats.inactive_file.bytes", Labels.EMPTY)).isEqualTo(10407936L);
120118
}
121119

122120
@Test
@@ -126,7 +124,6 @@ void testUnlimitedCgroup2() throws Exception {
126124

127125
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.limit.bytes", Labels.EMPTY)).isEqualTo(Double.NaN);
128126
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.mem.usage.bytes", Labels.EMPTY)).isEqualTo(964778496);
129-
assertThat(metricRegistry.getGaugeValue("system.process.cgroup.memory.stats.inactive_file.bytes", Labels.EMPTY)).isEqualTo(10407936L);
130127
}
131128

132129
}

docs/metrics.asciidoc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,6 @@ Memory usage in current cgroup slice.
120120
--
121121

122122

123-
*`system.process.cgroup.memory.stats.inactive_file.bytes`*::
124-
+
125-
--
126-
type: long
127-
128-
format: bytes
129-
130-
Inactive memory in current cgroup slice.
131-
--
132-
133123
[float]
134124
[[metrics-jvm]]
135125
=== JVM Metrics

0 commit comments

Comments
 (0)