Skip to content

Commit 7efa75b

Browse files
authored
Enable publishing process context by default (#11288)
Enable publishing process context by default **What does this PR do?** This PR changes the default of `PROFILING_PROCESS_CONTEXT_ENABLED` to `true`, thus enabling publishing of the [OpenTelemetry process context](open-telemetry/opentelemetry-specification#4719) by default. **Motivation:** When we added this feature, the specification linked above was still a work-in-progress and that's why we chose to not enable it by default. As of version 1.62.0 of dd-trace-java we already ship with the latest version of the spec (that got accepted by opentelemetry). Publishing this information will enable the Datadog Full Host Profiler (which itself is based on the OTel eBPF Profiler) to provide a better experience when profiling apps using dd-trace-java. (And there's plans for more features built atop it -- e.g. in the Datadog agent). This feature is already turned on by default in libdatadog (thus dd-trace-rb, dd-trace-py, dd-trace-dotnet) + dd-trace-rs + dd-trace-go and we're working to make sure every lib has it enabled. **Additional Notes:** Note that the process context is only supported on Linux, so you won't see anything on macOS/Linux (outside of docker). The code already turns those into a no-op, so there's no problem there, just calling it out for folks interested in testing. **How to test the change?** Other than the unit tests, the `otel_process_ctx_dump.sh` script from [this repo](https://github.com/open-telemetry/sig-profiling/tree/main/process-context/c-and-cpp) can be used to see the feature working. Co-authored-by: ivo.anjo <ivo.anjo@datadoghq.com>
1 parent ed1f6f9 commit 7efa75b

2 files changed

Lines changed: 4 additions & 19 deletions

File tree

dd-java-agent/agent-profiling/src/test/java/com/datadog/profiling/agent/ProcessContextTest.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.datadog.profiling.agent;
22

3+
import static org.junit.jupiter.api.Assertions.assertTrue;
34
import static org.mockito.ArgumentMatchers.eq;
45
import static org.mockito.Mockito.mock;
56
import static org.mockito.Mockito.mockStatic;
@@ -79,24 +80,8 @@ void testRegisterSkipsWhenDisabled() {
7980
}
8081

8182
@Test
82-
void testRegisterSkipsByDefault() {
83-
ConfigProvider configProvider = mock(ConfigProvider.class);
84-
when(configProvider.getBoolean(
85-
eq(ProfilingConfig.PROFILING_PROCESS_CONTEXT_ENABLED),
86-
eq(ProfilingConfig.PROFILING_PROCESS_CONTEXT_ENABLED_DEFAULT)))
87-
.thenReturn(ProfilingConfig.PROFILING_PROCESS_CONTEXT_ENABLED_DEFAULT);
88-
89-
DdprofLibraryLoader.OTelContextHolder holder =
90-
mock(DdprofLibraryLoader.OTelContextHolder.class);
91-
92-
try (MockedStatic<DdprofLibraryLoader> ddprofMock = mockStatic(DdprofLibraryLoader.class)) {
93-
ddprofMock.when(DdprofLibraryLoader::otelContext).thenReturn(holder);
94-
95-
ProcessContext.register(configProvider);
96-
97-
verify(holder, org.mockito.Mockito.never()).getReasonNotLoaded();
98-
verify(holder, org.mockito.Mockito.never()).getComponent();
99-
}
83+
void testEnabledByDefault() {
84+
assertTrue(ProfilingConfig.PROFILING_PROCESS_CONTEXT_ENABLED_DEFAULT);
10085
}
10186

10287
@Test

dd-trace-api/src/main/java/datadog/trace/api/config/ProfilingConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public final class ProfilingConfig {
127127

128128
public static final String PROFILING_PROCESS_CONTEXT_ENABLED =
129129
"profiling.experimental.process_context.enabled";
130-
public static final boolean PROFILING_PROCESS_CONTEXT_ENABLED_DEFAULT = false;
130+
public static final boolean PROFILING_PROCESS_CONTEXT_ENABLED_DEFAULT = true;
131131

132132
public static final String PROFILING_DATADOG_PROFILER_LOG_LEVEL = "profiling.ddprof.loglevel";
133133

0 commit comments

Comments
 (0)