From b46d09608f116fbb299da17e054d59cf5888771d Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Wed, 22 Feb 2023 13:14:39 +0000 Subject: [PATCH 1/2] Avoid relocating com.kenai.jffi in dd-trace-ot because it contains native methods that have to match to the embedded native libraries --- dd-trace-ot/build.gradle | 6 +++++- .../src/test/java/CreateTracerTest.java | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dd-trace-ot/build.gradle b/dd-trace-ot/build.gradle index acb757ccb99..e3af08a245f 100644 --- a/dd-trace-ot/build.gradle +++ b/dd-trace-ot/build.gradle @@ -90,7 +90,11 @@ shadowJar { exclude(dependency('org.slf4j:')) } - relocate('com.', 'ddtrot.com.') + relocate('com.', 'ddtrot.com.') { + // don't relocate native methods + exclude('com.kenai.jffi.*') + exclude('com.kenai.jffi.internal.*') + } relocate('dogstatsd/', 'ddtrot/dogstatsd/') relocate('jni/', 'ddtrot/jni/') relocate('jnr/', 'ddtrot/jnr/') diff --git a/test-published-dependencies/ot-pulls-in-api/src/test/java/CreateTracerTest.java b/test-published-dependencies/ot-pulls-in-api/src/test/java/CreateTracerTest.java index badd1834041..6a16f229493 100644 --- a/test-published-dependencies/ot-pulls-in-api/src/test/java/CreateTracerTest.java +++ b/test-published-dependencies/ot-pulls-in-api/src/test/java/CreateTracerTest.java @@ -1,6 +1,8 @@ import datadog.opentracing.DDTracer; import io.opentracing.util.GlobalTracer; import org.junit.jupiter.api.Test; +import java.nio.file.Files; +import java.nio.file.Path; public class CreateTracerTest { @@ -13,4 +15,18 @@ void createTracer() throws InterruptedException { // Sleep a bit so the trace sending machinery has a chance to start Thread.sleep(1000); } + + @Test + void buildTracerWithUDS() throws Exception { + // trigger use of JNR and JFFI to validate native method linking + Path fakeSocketPath = Files.createTempFile("dd-java", "test-uds"); + System.setProperty("dd.trace.agent.url", "unix://" + fakeSocketPath.toUri().getPath()); + try { + // we don't need to actually use the tracer, just build it + DDTracer.builder().serviceName("TestServiceWithUDS").build(); + } finally { + System.clearProperty("dd.trace.agent.url"); + Files.delete(fakeSocketPath); + } + } } From 9c6e64b1443a748d6f13afeda397d9b023ccb92d Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Wed, 22 Feb 2023 13:50:19 +0000 Subject: [PATCH 2/2] Update shaded contents check --- test-published-dependencies/ot-is-shaded/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test-published-dependencies/ot-is-shaded/build.gradle b/test-published-dependencies/ot-is-shaded/build.gradle index 7a5e772bd81..f46b8994634 100644 --- a/test-published-dependencies/ot-is-shaded/build.gradle +++ b/test-published-dependencies/ot-is-shaded/build.gradle @@ -91,6 +91,9 @@ tasks.register('checkJarContents', CheckJarContentsTask) { '^[^/]*\\.version$', '^DDSketch.proto$', '^META-INF/.*$', + '^com/$', + '^com/kenai/$', + '^com/kenai/jffi/.*$', '^datadog/.*$', '^ddtrot/.*$' ]