Skip to content

Commit bab5474

Browse files
author
Matt
committed
Check for containerized Posix when locating hsperfdata dir
1 parent 6e7e380 commit bab5474

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

internal-api/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ dependencies {
246246
api project(':components:yaml')
247247
api project(':components:cli')
248248
api project(":utils:time-utils")
249+
api project(":utils:container-utils")
249250

250251
// has to be loaded by system classloader:
251252
// it contains annotations that are also present in the instrumented application classes

internal-api/src/main/java/datadog/trace/util/PidHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package datadog.trace.util;
22

3+
import datadog.common.container.ContainerInfo;
34
import datadog.trace.api.Platform;
45
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
56
import datadog.trace.context.TraceScope;
@@ -76,6 +77,11 @@ private static String getOSTempDir() {
7677
// the JDK OS-specific implementations of os::get_temp_directory(), i.e.
7778
// https://github.com/openjdk/jdk/blob/f50bd0d9ec65a6b9596805d0131aaefc1bb913f3/src/hotspot/os/bsd/os_bsd.cpp#L886-L904
7879
if (Platform.isLinux()) {
80+
if (ContainerInfo.isRunningInContainer()) {
81+
// See
82+
// https://github.com/openjdk/jdk/blob/39a28ffe4e23274dba34317d8960bfb7e6d203ed/src/hotspot/os/posix/perfMemory_posix.cpp#L136-L146
83+
return "/proc/" + getPid() + "/root/tmp/hsperfdata_" + System.getProperty("user.name");
84+
}
7985
return "/tmp/";
8086
} else if (Platform.isWindows()) {
8187
return Stream.of(System.getenv("TMP"), System.getenv("TEMP"), System.getenv("USERPROFILE"))

0 commit comments

Comments
 (0)