File tree Expand file tree Collapse file tree
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/servicediscovery
dd-trace-core/src/main/java/datadog/trace/core/servicediscovery Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import com .sun .jna .Native ;
66import com .sun .jna .NativeLong ;
77import com .sun .jna .Pointer ;
8+ import datadog .trace .api .GlobalTracer ;
9+ import datadog .trace .api .Tracer ;
10+ import datadog .trace .context .TraceScope ;
811
912public final class MemFDUnixWriterJNA extends MemFDUnixWriter {
10- private final LibC libc = Native . load ( "c" , LibC . class ) ;
13+ private final LibC libc ;
1114
1215 private interface LibC extends Library {
1316 long syscall (long number , Object ... args );
@@ -17,6 +20,14 @@ private interface LibC extends Library {
1720 int fcntl (int fd , int cmd , int arg );
1821 }
1922
23+ public MemFDUnixWriterJNA () {
24+ final Tracer tracer = GlobalTracer .get ();
25+ // JNA initialisation can do ldconfig and other commands. Those are hidden since internal.
26+ try (TraceScope closeme = tracer != null ? tracer .muteTracing () : null ) {
27+ libc = Native .load ("c" , LibC .class );
28+ }
29+ }
30+
2031 @ Override
2132 protected long syscall (long number , String name , int flags ) {
2233 return libc .syscall (number , name , flags );
Original file line number Diff line number Diff line change 55import datadog .environment .JavaVirtualMachine ;
66import datadog .environment .OperatingSystem ;
77import datadog .environment .SystemProperties ;
8- import datadog .trace .api .GlobalTracer ;
9- import datadog .trace .api .Tracer ;
10- import datadog .trace .context .TraceScope ;
118import de .thetaphi .forbiddenapis .SuppressForbidden ;
129import java .util .function .Supplier ;
1310import org .slf4j .Logger ;
@@ -28,9 +25,7 @@ public ForeignMemoryWriter get() {
2825
2926 @ SuppressForbidden // intentional Class.forName to force loading
3027 private ForeignMemoryWriter createForLinux () {
31- final Tracer tracer = GlobalTracer .get ();
32- // JNA initialisation can do ldconfig and other commands. Those are hidden since internal.
33- try (TraceScope closeme = tracer != null ? tracer .muteTracing () : null ) {
28+ try {
3429 // first check if the arch is supported
3530 if (OperatingSystem .architecture () == OperatingSystem .Architecture .UNKNOWN ) {
3631 log .debug (
You can’t perform that action at this time.
0 commit comments