Skip to content

Commit 76795e2

Browse files
Merge pull request DataDog#4069 from DataDog/rgs/perf_event_paranoid_setting
emit a profiler settings event with perf_events_paranoid setting
2 parents 34cd6ba + aa3cbea commit 76795e2

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎dd-java-agent/agent-profiling/profiling-controller-openjdk/src/main/java/com/datadog/profiling/controller/openjdk/JfrProfilerSettings.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public void publish() {
3131
new ProfilerSettingEvent("Checkpoints", String.valueOf(checkpointsEnabled)).commit();
3232
new ProfilerSettingEvent("Endpoints", String.valueOf(endpointsEnabled)).commit();
3333
new ProfilerSettingEvent("Auxiliary Profiler", auxiliaryProfiler).commit();
34+
new ProfilerSettingEvent("perf_events_paranoid", perfEventsParanoid).commit();
3435
}
3536
}
3637
}

‎dd-java-agent/agent-profiling/profiling-controller/src/main/java/com/datadog/profiling/controller/ProfilerSettingsSupport.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package com.datadog.profiling.controller;
22

3+
import datadog.trace.api.Platform;
34
import datadog.trace.api.config.ProfilingConfig;
45
import datadog.trace.bootstrap.config.provider.ConfigProvider;
6+
import java.nio.charset.StandardCharsets;
7+
import java.nio.file.Files;
8+
import java.nio.file.Path;
9+
import java.nio.file.Paths;
510

611
/** Capture the profiler config first and allow emitting the setting events per each recording. */
712
public abstract class ProfilerSettingsSupport {
@@ -19,6 +24,7 @@ public abstract class ProfilerSettingsSupport {
1924
protected final boolean checkpointsEnabled;
2025
protected final boolean endpointsEnabled;
2126
protected final String auxiliaryProfiler;
27+
protected final String perfEventsParanoid;
2228

2329
protected ProfilerSettingsSupport() {
2430
ConfigProvider configProvider = ConfigProvider.getInstance();
@@ -71,8 +77,23 @@ protected ProfilerSettingsSupport() {
7177
configProvider.getString(
7278
ProfilingConfig.PROFILING_AUXILIARY_TYPE,
7379
ProfilingConfig.PROFILING_AUXILIARY_TYPE_DEFAULT);
80+
perfEventsParanoid = readPerfEventsParanoidSetting();
7481
}
7582

7683
/** To be defined in controller specific way. Eg. one could emit JFR events. */
7784
public abstract void publish();
85+
86+
private static String readPerfEventsParanoidSetting() {
87+
String value = "unknown";
88+
if (Platform.isLinux()) {
89+
Path perfEventsParanoid = Paths.get("/proc/sys/kernel/perf_event_paranoid");
90+
try {
91+
if (Files.exists(perfEventsParanoid)) {
92+
value = new String(Files.readAllBytes(perfEventsParanoid), StandardCharsets.UTF_8).trim();
93+
}
94+
} catch (Exception ignore) {
95+
}
96+
}
97+
return value;
98+
}
7899
}

0 commit comments

Comments
 (0)