File tree Expand file tree Collapse file tree 6 files changed +12
-16
lines changed
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap
dd-smoke-tests/profiling-integration-tests/src/test/java/datadog/smoketest
main/java/datadog/trace/util
test/groovy/datadog/trace/util
src/main/java/datadog/trace/util Expand file tree Collapse file tree 6 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -430,7 +430,7 @@ public static void patchJPSAccess(Instrumentation inst) {
430
430
// Unclear if supported for J9, may need to revisit
431
431
try {
432
432
Class .forName ("datadog.trace.util.JPMSJPSAccess" )
433
- .getMethod ("patchModuleAccess" )
433
+ .getMethod ("patchModuleAccess" , Instrumentation . class )
434
434
.invoke (inst );
435
435
} catch (Exception e ) {
436
436
log .debug (
Original file line number Diff line number Diff line change @@ -507,8 +507,6 @@ void testShutdown(final TestInfo testInfo) throws Exception {
507
507
assertTrue (
508
508
targetProcess .waitFor (
509
509
duration + PROFILING_UPLOAD_TIMEOUT_SECONDS + 1 , TimeUnit .SECONDS ));
510
- assertTrue (
511
- checkLogLines (logFilePath , it -> it .contains ("Successfully invoked jvmstat" )));
512
510
} finally {
513
511
if (targetProcess != null ) {
514
512
targetProcess .destroyForcibly ();
Original file line number Diff line number Diff line change @@ -41,10 +41,6 @@ forbiddenApisMain {
41
41
failOnMissingClasses = false
42
42
}
43
43
44
- forbiddenApisMain_java11 {
45
- failOnMissingClasses = false
46
- }
47
-
48
44
idea {
49
45
module {
50
46
jdkName = ' 11'
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
package datadog.trace.util
2
2
3
3
import datadog.trace.test.util.DDSpecification
4
+ import net.bytebuddy.agent.ByteBuddyAgent
4
5
5
6
class PidHelperTest extends DDSpecification {
6
7
7
8
def " PID is available everywhere we test" () {
8
9
expect :
9
10
! PidHelper . getPid(). isEmpty()
10
11
}
12
+
13
+ def " JPS via jvmstat is used when possible" () {
14
+ when :
15
+ def inst = ByteBuddyAgent . install()
16
+ JPMSJPSAccess . patchModuleAccess(inst)
17
+
18
+ then :
19
+ JPSUtils.VMPids != null
20
+ }
11
21
}
Original file line number Diff line number Diff line change 2
2
3
3
import de .thetaphi .forbiddenapis .SuppressForbidden ;
4
4
import java .lang .reflect .Method ;
5
- import java .util .HashSet ;
6
- import java .util .List ;
7
5
import java .util .Set ;
8
6
import org .slf4j .Logger ;
9
7
import org .slf4j .LoggerFactory ;
@@ -13,21 +11,15 @@ public final class JPSUtils {
13
11
14
12
@ SuppressForbidden
15
13
public static Set <String > getVMPids () {
16
- Set <String > vmPids = new HashSet <>();
17
14
try {
18
15
Class <?> monitoredHostClass = Class .forName ("sun.jvmstat.monitor.MonitoredHost" );
19
16
Method getMonitoredHostMethod =
20
17
monitoredHostClass .getDeclaredMethod ("getMonitoredHost" , String .class );
21
18
Object vmHost = getMonitoredHostMethod .invoke (null , "localhost" );
22
- for (Integer vmPid :
23
- (List <Integer >) monitoredHostClass .getDeclaredMethod ("activeVms" ).invoke (vmHost )) {
24
- vmPids .add (vmPid .toString ());
25
- }
26
- log .debug ("Successfully invoked jvmstat" );
19
+ return (Set <String >) monitoredHostClass .getDeclaredMethod ("activeVms" ).invoke (vmHost );
27
20
} catch (Exception e ) {
28
21
log .debug ("Failed to invoke jvmstat with exception " , e );
29
22
return null ;
30
23
}
31
- return vmPids ;
32
24
}
33
25
}
You can’t perform that action at this time.
0 commit comments