Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emit a profiler settings event with perf_events_paranoid setting #4069

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void publish() {
new ProfilerSettingEvent("Checkpoints", String.valueOf(checkpointsEnabled)).commit();
new ProfilerSettingEvent("Endpoints", String.valueOf(endpointsEnabled)).commit();
new ProfilerSettingEvent("Auxiliary Profiler", auxiliaryProfiler).commit();
new ProfilerSettingEvent("perf_events_paranoid", perfEventsParanoid).commit();
jbachorik marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.datadog.profiling.controller;

import datadog.trace.api.Platform;
import datadog.trace.api.config.ProfilingConfig;
import datadog.trace.bootstrap.config.provider.ConfigProvider;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

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

protected ProfilerSettingsSupport() {
ConfigProvider configProvider = ConfigProvider.getInstance();
Expand Down Expand Up @@ -71,8 +77,23 @@ protected ProfilerSettingsSupport() {
configProvider.getString(
ProfilingConfig.PROFILING_AUXILIARY_TYPE,
ProfilingConfig.PROFILING_AUXILIARY_TYPE_DEFAULT);
perfEventsParanoid = readPerfEventsParanoidSetting();
}

/** To be defined in controller specific way. Eg. one could emit JFR events. */
public abstract void publish();

private static String readPerfEventsParanoidSetting() {
String value = "unknown";
jbachorik marked this conversation as resolved.
Show resolved Hide resolved
if (Platform.isLinux()) {
Path perfEventsParanoid = Paths.get("/proc/sys/kernel/perf_event_paranoid");
try {
if (Files.exists(perfEventsParanoid)) {
value = new String(Files.readAllBytes(perfEventsParanoid), StandardCharsets.UTF_8).trim();
}
} catch (Exception ignore) {
}
}
return value;
}
}