|
2 | 2 |
|
3 | 3 | import com.datadog.profiling.controller.ProfilerSettingsSupport;
|
4 | 4 | import com.datadog.profiling.controller.openjdk.events.ProfilerSettingEvent;
|
| 5 | +import datadog.trace.api.Platform; |
| 6 | +import datadog.trace.bootstrap.config.provider.ConfigProvider; |
5 | 7 |
|
6 | 8 | /** Capture the profiler config first and allow emitting the setting events per each recording. */
|
7 | 9 | final class JfrProfilerSettings extends ProfilerSettingsSupport {
|
| 10 | + private static final String JFP_TEMPLATE_OVERRIDE_PROFILING_KEY = |
| 11 | + "JFP Template Override Profiling"; |
| 12 | + private static final String EXCEPTION_SAMPLE_RATE_LIMIT_KEY = "Exception Sample Rate Limit"; |
| 13 | + private static final String EXCEPTION_HISTO_REPORT_LIMIT_KEY = "Exception Histo Report Limit"; |
| 14 | + private static final String EXCEPTION_HISTO_SIZE_LIMIT_KEY = "Exception Histo Size Limit"; |
| 15 | + private final String jfrImplementation; |
| 16 | + |
| 17 | + public JfrProfilerSettings() { |
| 18 | + super(ConfigProvider.getInstance()); |
| 19 | + this.jfrImplementation = |
| 20 | + Platform.isNativeImage() |
| 21 | + ? "native-image" |
| 22 | + : (Platform.isOracleJDK8() ? "oracle" : "openjdk"); |
| 23 | + } |
| 24 | + |
8 | 25 | public void publish() {
|
9 | 26 | if (new ProfilerSettingEvent(null, null, null).isEnabled()) {
|
10 | | - new ProfilerSettingEvent("Upload Period", String.valueOf(uploadPeriod), "seconds").commit(); |
11 | | - new ProfilerSettingEvent("Upload Timeout", String.valueOf(uploadTimeout), "seconds").commit(); |
12 | | - new ProfilerSettingEvent("Upload Compression", uploadCompression).commit(); |
13 | | - new ProfilerSettingEvent("Allocation Profiling", String.valueOf(allocationProfilingEnabled)) |
| 27 | + new ProfilerSettingEvent(UPLOAD_PERIOD_KEY, String.valueOf(uploadPeriod), "seconds").commit(); |
| 28 | + new ProfilerSettingEvent(UPLOAD_TIMEOUT_KEY, String.valueOf(uploadTimeout), "seconds") |
14 | 29 | .commit();
|
15 | | - new ProfilerSettingEvent("Heap Profiling", String.valueOf(heapProfilingEnabled)).commit(); |
16 | | - new ProfilerSettingEvent("Force Start-First", String.valueOf(startForceFirst)).commit(); |
17 | | - new ProfilerSettingEvent("JFP Template Override Profiling", String.valueOf(templateOverride)) |
| 30 | + new ProfilerSettingEvent(UPLOAD_COMPRESSION_KEY, uploadCompression).commit(); |
| 31 | + new ProfilerSettingEvent(ALLOCATION_PROFILING_KEY, String.valueOf(allocationProfilingEnabled)) |
| 32 | + .commit(); |
| 33 | + new ProfilerSettingEvent(HEAP_PROFILING_KEY, String.valueOf(heapProfilingEnabled)).commit(); |
| 34 | + new ProfilerSettingEvent(FORCE_START_FIRST_KEY, String.valueOf(startForceFirst)).commit(); |
| 35 | + new ProfilerSettingEvent( |
| 36 | + JFP_TEMPLATE_OVERRIDE_PROFILING_KEY, String.valueOf(templateOverride)) |
18 | 37 | .commit();
|
19 | 38 | new ProfilerSettingEvent(
|
20 | | - "Exception Sample Rate Limit", |
| 39 | + EXCEPTION_SAMPLE_RATE_LIMIT_KEY, |
21 | 40 | String.valueOf(exceptionSampleLimit),
|
22 | 41 | "exceptions/second")
|
23 | 42 | .commit();
|
24 | 43 | new ProfilerSettingEvent(
|
25 | | - "Exception Histo Report Limit", String.valueOf(exceptionHistogramTopItems)) |
| 44 | + EXCEPTION_HISTO_REPORT_LIMIT_KEY, String.valueOf(exceptionHistogramTopItems)) |
26 | 45 | .commit();
|
27 | 46 | new ProfilerSettingEvent(
|
28 | | - "Exception Histo Size Limit", String.valueOf(exceptionHistogramMaxSize)) |
| 47 | + EXCEPTION_HISTO_SIZE_LIMIT_KEY, String.valueOf(exceptionHistogramMaxSize)) |
29 | 48 | .commit();
|
30 | | - new ProfilerSettingEvent("Hotspots", String.valueOf(hotspotsEnabled)).commit(); |
31 | | - new ProfilerSettingEvent("Endpoints", String.valueOf(endpointsEnabled)).commit(); |
32 | | - new ProfilerSettingEvent("Auxiliary Profiler", auxiliaryProfiler).commit(); |
33 | | - new ProfilerSettingEvent("perf_events_paranoid", perfEventsParanoid).commit(); |
34 | | - new ProfilerSettingEvent("Native Stacks", String.valueOf(hasNativeStacks)).commit(); |
| 49 | + new ProfilerSettingEvent(HOTSPOTS_KEY, String.valueOf(hotspotsEnabled)).commit(); |
| 50 | + new ProfilerSettingEvent(ENDPOINTS_KEY, String.valueOf(endpointsEnabled)).commit(); |
| 51 | + new ProfilerSettingEvent(AUXILIARY_PROFILER_KEY, auxiliaryProfiler).commit(); |
| 52 | + new ProfilerSettingEvent(PERF_EVENTS_PARANOID_KEY, perfEventsParanoid).commit(); |
| 53 | + new ProfilerSettingEvent(NATIVE_STACKS_KEY, String.valueOf(hasNativeStacks)).commit(); |
| 54 | + new ProfilerSettingEvent(JFR_IMPLEMENTATION_KEY, jfrImplementation).commit(); |
35 | 55 | }
|
36 | 56 | }
|
37 | 57 | }
|
0 commit comments