diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java index b4696da4e69..283ed9b7366 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/NoOpTestEventsHandler.java @@ -10,8 +10,8 @@ import datadog.trace.civisibility.retry.NeverRetry; import java.lang.reflect.Method; import java.util.Collection; +import javax.annotation.Nullable; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class NoOpTestEventsHandler implements TestEventsHandler { @@ -25,7 +25,8 @@ public void onTestSuiteStart( @Nullable Class testClass, @Nullable Collection categories, boolean parallelized, - TestFrameworkInstrumentation instrumentation) { + TestFrameworkInstrumentation instrumentation, + @Nullable Long startTime) { // do nothing } @@ -40,7 +41,7 @@ public void onTestSuiteFailure(SuiteKey descriptor, @Nullable Throwable throwabl } @Override - public void onTestSuiteFinish(SuiteKey descriptor) { + public void onTestSuiteFinish(SuiteKey descriptor, @Nullable Long endTime) { // do nothing } @@ -57,7 +58,8 @@ public void onTestStart( @Nullable Class testClass, @Nullable String testMethodName, @Nullable Method testMethod, - boolean isRetry) { + boolean isRetry, + @Nullable Long startTime) { // do nothing } @@ -72,7 +74,7 @@ public void onTestFailure(TestKey descriptor, @Nullable Throwable throwable) { } @Override - public void onTestFinish(TestKey descriptor) { + public void onTestFinish(TestKey descriptor, @Nullable Long endTime) { // do nothing } diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java index 94958461f41..14ff1f2f1ce 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java @@ -50,6 +50,10 @@ public TestEventsHandlerImpl( this.inProgressTests = (ContextStore) testStore; } + private static boolean skipTrace(final Class testClass) { + return testClass != null && testClass.getAnnotation(DisableTestTrace.class) != null; + } + @Override public void onTestSuiteStart( final SuiteKey descriptor, @@ -59,13 +63,15 @@ public void onTestSuiteStart( final @Nullable Class testClass, final @Nullable Collection categories, boolean parallelized, - TestFrameworkInstrumentation instrumentation) { + TestFrameworkInstrumentation instrumentation, + @Nullable Long startTime) { if (skipTrace(testClass)) { return; } TestSuiteImpl testSuite = - testModule.testSuiteStart(testSuiteName, testClass, null, parallelized, instrumentation); + testModule.testSuiteStart( + testSuiteName, testClass, startTime, parallelized, instrumentation); if (testFramework != null) { testSuite.setTag(Tags.TEST_FRAMEWORK, testFramework); @@ -92,13 +98,13 @@ private String getTestTraits(Collection categories) { } @Override - public void onTestSuiteFinish(SuiteKey descriptor) { + public void onTestSuiteFinish(SuiteKey descriptor, @Nullable Long endTime) { if (skipTrace(descriptor.getClass())) { return; } TestSuiteImpl testSuite = inProgressTestSuites.remove(descriptor); - testSuite.end(null); + testSuite.end(endTime); } @Override @@ -134,7 +140,8 @@ public void onTestStart( final @Nullable Class testClass, final @Nullable String testMethodName, final @Nullable Method testMethod, - final boolean isRetry) { + final boolean isRetry, + @Nullable Long startTime) { if (skipTrace(testClass)) { return; } @@ -148,7 +155,7 @@ public void onTestStart( + descriptor); } - TestImpl test = testSuite.testStart(testName, testParameters, testMethod, null); + TestImpl test = testSuite.testStart(testName, testParameters, testMethod, startTime); TestIdentifier thisTest = new TestIdentifier(testSuiteName, testName, testParameters); if (testModule.isNew(thisTest)) { @@ -212,13 +219,13 @@ public void onTestFailure(TestKey descriptor, @Nullable Throwable throwable) { } @Override - public void onTestFinish(TestKey descriptor) { + public void onTestFinish(TestKey descriptor, @Nullable Long endTime) { TestImpl test = inProgressTests.remove(descriptor); if (test == null) { log.debug("Ignoring finish event, could not find test {}", descriptor); return; } - test.end(null); + test.end(endTime); } @Override @@ -247,13 +254,10 @@ public void onTestIgnore( testClass, testMethodName, testMethod, - false); + false, + null); onTestSkip(testDescriptor, reason); - onTestFinish(testDescriptor); - } - - private static boolean skipTrace(final Class testClass) { - return testClass != null && testClass.getAnnotation(DisableTestTrace.class) != null; + onTestFinish(testDescriptor, null); } @Override diff --git a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java index d824f05eceb..697321bded7 100644 --- a/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java +++ b/dd-java-agent/instrumentation/junit-4.10/cucumber-junit-4/src/main/java/datadog/trace/instrumentation/junit4/CucumberTracingListener.java @@ -51,7 +51,8 @@ public void testSuiteStarted(final Description description) { null, Collections.emptyList(), false, - TestFrameworkInstrumentation.CUCUMBER); + TestFrameworkInstrumentation.CUCUMBER, + null); } } @@ -59,7 +60,7 @@ public void testSuiteStarted(final Description description) { public void testSuiteFinished(final Description description) { if (isFeature(description)) { TestSuiteDescriptor suiteDescriptor = CucumberUtils.toSuiteDescriptor(description); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } } @@ -82,7 +83,8 @@ public void testStarted(final Description description) { null, null, null, - retryPolicy != null && retryPolicy.currentExecutionIsRetry()); + retryPolicy != null && retryPolicy.currentExecutionIsRetry(), + null); recordFeatureFileCodeCoverage(description); } @@ -100,7 +102,7 @@ private static void recordFeatureFileCodeCoverage(Description scenarioDescriptio @Override public void testFinished(final Description description) { TestDescriptor testDescriptor = CucumberUtils.toTestDescriptor(description); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); } // same callback is executed both for test cases and test suites (for setup/teardown errors) @@ -154,9 +156,10 @@ public void testIgnored(final Description description) { null, Collections.emptyList(), false, - TestFrameworkInstrumentation.CUCUMBER); + TestFrameworkInstrumentation.CUCUMBER, + null); TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteSkip(suiteDescriptor, reason); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } else { String testSuiteName = CucumberUtils.getTestSuiteNameForScenario(description); String testName = CucumberUtils.getTestNameForScenario(description); diff --git a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java index 8ea55709841..43524046393 100644 --- a/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java +++ b/dd-java-agent/instrumentation/junit-4.10/munit-junit-4/src/main/java/datadog/trace/instrumentation/junit4/MUnitTracingListener.java @@ -54,7 +54,8 @@ public void testSuiteStarted(final Description description) { testClass, categories, false, - TestFrameworkInstrumentation.MUNIT); + TestFrameworkInstrumentation.MUNIT, + null); } public void testSuiteFinished(final Description description) { @@ -66,7 +67,7 @@ public void testSuiteFinished(final Description description) { } TestSuiteDescriptor suiteDescriptor = MUnitUtils.toSuiteDescriptor(description); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } @Override @@ -90,13 +91,14 @@ public void testStarted(final Description description) { testClass, null, null, - retryPolicy != null && retryPolicy.currentExecutionIsRetry()); + retryPolicy != null && retryPolicy.currentExecutionIsRetry(), + null); } @Override public void testFinished(final Description description) { TestDescriptor testDescriptor = MUnitUtils.toTestDescriptor(description); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); } // same callback is executed both for test cases and test suites (for setup/teardown errors) @@ -167,10 +169,11 @@ public void testIgnored(final Description description) { testClass, null, null, - false); + false, + null); } TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSkip(testDescriptor, null); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); } else if (testClass != null) { TestSuiteDescriptor suiteDescriptor = MUnitUtils.toSuiteDescriptor(description); @@ -187,7 +190,8 @@ public void testIgnored(final Description description) { testClass, categories, false, - TestFrameworkInstrumentation.MUNIT); + TestFrameworkInstrumentation.MUNIT, + null); } TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteSkip(suiteDescriptor, null); @@ -196,7 +200,7 @@ public void testIgnored(final Description description) { } if (!suiteStarted) { - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } } } diff --git a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4TracingListener.java b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4TracingListener.java index e40bb104e04..2fe70d0fd97 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4TracingListener.java +++ b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4TracingListener.java @@ -43,7 +43,8 @@ public void testSuiteStarted(final Description description) { testClass, categories, false, - TestFrameworkInstrumentation.JUNIT4); + TestFrameworkInstrumentation.JUNIT4, + null); } public void testSuiteFinished(final Description description) { @@ -55,7 +56,7 @@ public void testSuiteFinished(final Description description) { } TestSuiteDescriptor suiteDescriptor = JUnit4Utils.toSuiteDescriptor(description); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } @Override @@ -86,7 +87,8 @@ public void testStarted(final Description description) { testClass, testMethodName, testMethod, - retryPolicy != null && retryPolicy.currentExecutionIsRetry()); + retryPolicy != null && retryPolicy.currentExecutionIsRetry(), + null); } @Override @@ -96,7 +98,7 @@ public void testFinished(final Description description) { } TestDescriptor testDescriptor = JUnit4Utils.toTestDescriptor(description); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); } // same callback is executed both for test cases and test suites (for setup/teardown errors) @@ -175,7 +177,8 @@ public void testIgnored(final Description description) { testClass, categories, false, - TestFrameworkInstrumentation.JUNIT4); + TestFrameworkInstrumentation.JUNIT4, + null); TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteSkip(suiteDescriptor, reason); List testMethods = JUnit4Utils.getTestMethods(testClass); @@ -183,7 +186,7 @@ public void testIgnored(final Description description) { testIgnored(description, testMethod, reason); } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } } diff --git a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java index 2209d7dd2b9..79521c2bbfd 100644 --- a/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java +++ b/dd-java-agent/instrumentation/junit-5.3/cucumber-junit-5/src/main/java/datadog/trace/instrumentation/junit5/CucumberTracingListener.java @@ -71,7 +71,8 @@ private void containerExecutionStarted(final TestDescriptor suiteDescriptor) { null, tags, false, - TestFrameworkInstrumentation.CUCUMBER); + TestFrameworkInstrumentation.CUCUMBER, + null); } private void containerExecutionFinished( @@ -93,7 +94,7 @@ private void containerExecutionFinished( TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFailure(suiteDescriptor, throwable); } } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } private void testCaseExecutionStarted(final TestDescriptor testDescriptor) { @@ -125,7 +126,8 @@ private void testResourceExecutionStarted( null, null, null, - JUnitPlatformUtils.isRetry(testDescriptor)); + JUnitPlatformUtils.isRetry(testDescriptor), + null); CoveragePerTestBridge.recordCoverage(classpathResourceName); } @@ -149,7 +151,7 @@ private void testResourceExecutionFinished( TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFailure(testDescriptor, throwable); } } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); } @Override diff --git a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java index db554cb127d..583630a324f 100644 --- a/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java +++ b/dd-java-agent/instrumentation/junit-5.3/spock-junit-5/src/main/java/datadog/trace/instrumentation/junit5/SpockTracingListener.java @@ -71,7 +71,8 @@ private void containerExecutionStarted(final TestDescriptor suiteDescriptor) { testClass, tags, false, - TestFrameworkInstrumentation.SPOCK); + TestFrameworkInstrumentation.SPOCK, + null); } private void containerExecutionFinished( @@ -96,7 +97,7 @@ private void containerExecutionFinished( } } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } private void testCaseExecutionStarted(final TestDescriptor testDescriptor) { @@ -128,7 +129,8 @@ private void testMethodExecutionStarted(TestDescriptor testDescriptor, MethodSou testClass, testMethodName, testMethod, - JUnitPlatformUtils.isRetry(testDescriptor)); + JUnitPlatformUtils.isRetry(testDescriptor), + null); } private void testCaseExecutionFinished( @@ -150,7 +152,7 @@ private static void testMethodExecutionFinished( TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFailure(testDescriptor, throwable); } } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); } @Override @@ -186,14 +188,15 @@ private void containerExecutionSkipped( testClass, tags, false, - TestFrameworkInstrumentation.SPOCK); + TestFrameworkInstrumentation.SPOCK, + null); TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteSkip(suiteDescriptor, reason); for (TestDescriptor child : suiteDescriptor.getChildren()) { executionSkipped(child, reason); } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } private void testMethodExecutionSkipped( diff --git a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java index 7cb32504963..ea47868cae3 100644 --- a/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java +++ b/dd-java-agent/instrumentation/junit-5.3/src/main/java/datadog/trace/instrumentation/junit5/TracingListener.java @@ -72,7 +72,8 @@ private void containerExecutionStarted(final TestDescriptor suiteDescriptor) { testClass, tags, false, - TestFrameworkInstrumentation.JUNIT5); + TestFrameworkInstrumentation.JUNIT5, + null); } private void containerExecutionFinished( @@ -94,7 +95,7 @@ private void containerExecutionFinished( TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFailure(suiteDescriptor, throwable); } } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } private void testCaseExecutionStarted(final TestDescriptor testDescriptor) { @@ -138,7 +139,8 @@ private void testMethodExecutionStarted(TestDescriptor testDescriptor, MethodSou testClass, testMethodName, testMethod, - JUnitPlatformUtils.isRetry(testDescriptor)); + JUnitPlatformUtils.isRetry(testDescriptor), + null); } private void testCaseExecutionFinished( @@ -160,7 +162,7 @@ private static void testMethodExecutionFinished( TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFailure(testDescriptor, throwable); } } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); } @Override @@ -197,14 +199,15 @@ private void containerExecutionSkipped( testClass, tags, false, - TestFrameworkInstrumentation.JUNIT5); + TestFrameworkInstrumentation.JUNIT5, + null); TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteSkip(suiteDescriptor, reason); for (TestDescriptor child : suiteDescriptor.getChildren()) { executionSkipped(child, reason); } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } private void testMethodExecutionSkipped( diff --git a/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java b/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java index 141ea88a6ec..777fb8cc761 100644 --- a/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java +++ b/dd-java-agent/instrumentation/karate/src/main/java/datadog/trace/instrumentation/karate/KarateTracingHook.java @@ -55,12 +55,13 @@ public boolean beforeFeature(FeatureRuntime fr) { null, KarateUtils.getCategories(feature.getTags()), suite.parallel, - TestFrameworkInstrumentation.KARATE); + TestFrameworkInstrumentation.KARATE, + null); if (!isFeatureContainingScenarios(fr)) { // Karate will not trigger the afterFeature hook if suite has no scenarios TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteSkip(suiteDescriptor, null); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } return true; @@ -86,7 +87,7 @@ public void afterFeature(FeatureRuntime fr) { } else if (result.isEmpty()) { TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteSkip(suiteDescriptor, null); } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } @Override @@ -145,7 +146,8 @@ public boolean beforeScenario(ScenarioRuntime sr) { null, null, null, - sr.magicVariables.containsKey(KarateUtils.RETRY_MAGIC_VARIABLE)); + sr.magicVariables.containsKey(KarateUtils.RETRY_MAGIC_VARIABLE), + null); return true; } @@ -162,7 +164,7 @@ public void afterScenario(ScenarioRuntime sr) { } else if (result.getStepResults().isEmpty()) { TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSkip(testDescriptor, null); } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, null); Boolean runHooksManually = manualFeatureHooks.remove(sr.featureRuntime); if (runHooksManually != null && runHooksManually) { diff --git a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java index b6e835f0c4c..214d8509e3a 100644 --- a/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java +++ b/dd-java-agent/instrumentation/scalatest/src/main/java/datadog/trace/instrumentation/scalatest/DatadogReporter.java @@ -101,7 +101,8 @@ private static void onSuiteStart(SuiteStarting event) { testClass, categories, parallelized, - TestFrameworkInstrumentation.SCALATEST); + TestFrameworkInstrumentation.SCALATEST, + null); } private static void onSuiteFinish(SuiteCompleted event) { @@ -111,7 +112,7 @@ private static void onSuiteFinish(SuiteCompleted event) { String testSuiteName = event.suiteId(); Class testClass = ScalatestUtils.getClass(event.suiteClassName()); - eventHandler.onTestSuiteFinish(new TestSuiteDescriptor(testSuiteName, testClass)); + eventHandler.onTestSuiteFinish(new TestSuiteDescriptor(testSuiteName, testClass), null); } private static void onSuiteAbort(SuiteAborted event) { @@ -123,7 +124,7 @@ private static void onSuiteAbort(SuiteAborted event) { Class testClass = ScalatestUtils.getClass(event.suiteClassName()); Throwable throwable = event.throwable().getOrElse(null); eventHandler.onTestSuiteFailure(new TestSuiteDescriptor(testSuiteName, testClass), throwable); - eventHandler.onTestSuiteFinish(new TestSuiteDescriptor(testSuiteName, testClass)); + eventHandler.onTestSuiteFinish(new TestSuiteDescriptor(testSuiteName, testClass), null); } private static void onTestStart(TestStarting event) { @@ -159,7 +160,8 @@ private static void onTestStart(TestStarting event) { testClass, testMethodName, testMethod, - retryPolicy != null && retryPolicy.currentExecutionIsRetry()); + retryPolicy != null && retryPolicy.currentExecutionIsRetry(), + null); } private static void onTestSuccess(TestSucceeded event) { @@ -174,7 +176,7 @@ private static void onTestSuccess(TestSucceeded event) { String testParameters = null; TestDescriptor testDescriptor = new TestDescriptor(testSuiteName, testClass, testName, testParameters, testQualifier); - eventHandler.onTestFinish(testDescriptor); + eventHandler.onTestFinish(testDescriptor, null); } private static void onTestFailure(TestFailed event) { @@ -191,7 +193,7 @@ private static void onTestFailure(TestFailed event) { TestDescriptor testDescriptor = new TestDescriptor(testSuiteName, testClass, testName, testParameters, testQualifier); eventHandler.onTestFailure(testDescriptor, throwable); - eventHandler.onTestFinish(testDescriptor); + eventHandler.onTestFinish(testDescriptor, null); } private static void onTestIgnore(TestIgnored event) { @@ -251,7 +253,7 @@ private static void onTestCancel(TestCanceled event) { } else { eventHandler.onTestSkip(testDescriptor, reason); } - eventHandler.onTestFinish(testDescriptor); + eventHandler.onTestFinish(testDescriptor, null); } private static void onTestPending(TestPending event) { @@ -269,6 +271,6 @@ private static void onTestPending(TestPending event) { TestDescriptor testDescriptor = new TestDescriptor(testSuiteName, testClass, testName, testParameters, testQualifier); eventHandler.onTestSkip(testDescriptor, reason); - eventHandler.onTestFinish(testDescriptor); + eventHandler.onTestFinish(testDescriptor, null); } } diff --git a/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TracingListener.java b/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TracingListener.java index 8c1b1b48d7c..50989d92f9f 100644 --- a/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TracingListener.java +++ b/dd-java-agent/instrumentation/testng/src/main/java/datadog/trace/instrumentation/testng/TracingListener.java @@ -42,13 +42,14 @@ protected void onBeforeClass(ITestClass testClass, boolean parallelized) { testSuiteClass, groups, parallelized, - TestFrameworkInstrumentation.TESTNG); + TestFrameworkInstrumentation.TESTNG, + null); } @Override protected void onAfterClass(ITestClass testClass) { TestSuiteDescriptor suiteDescriptor = TestNGUtils.toSuiteDescriptor(testClass); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSuiteFinish(suiteDescriptor, null); } @Override @@ -94,7 +95,8 @@ public void onTestStart(final ITestResult result) { testClass, testMethodName, testMethod, - isRetry(result)); + isRetry(result), + null); } private boolean isRetry(final ITestResult result) { @@ -108,14 +110,14 @@ private boolean isRetry(final ITestResult result) { @Override public void onTestSuccess(final ITestResult result) { - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(result); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(result, null); } @Override public void onTestFailure(final ITestResult result) { Throwable throwable = result.getThrowable(); TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFailure(result, throwable); - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(result); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(result, null); } @Override @@ -137,6 +139,6 @@ public void onTestSkipped(final ITestResult result) { String reason = throwable != null ? throwable.getMessage() : null; TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestSkip(result, reason); } - TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(result); + TestEventsHandlerHolder.TEST_EVENTS_HANDLER.onTestFinish(result, null); } } diff --git a/dd-java-agent/instrumentation/weaver/build.gradle b/dd-java-agent/instrumentation/weaver/build.gradle new file mode 100644 index 00000000000..7957aedbeda --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/build.gradle @@ -0,0 +1,33 @@ +apply from: "$rootDir/gradle/java.gradle" +apply plugin: 'scala' + +muzzle { + pass { + group = 'com.disneystreaming' + module = 'weaver-cats_3' + versions = '[0.8.4,)' + } +} + +addTestSuiteForDir('latestDepTest', 'test') + +dependencies { + compileOnly group: 'com.disneystreaming', name: 'weaver-cats_3', version: '0.8.4' + + testImplementation testFixtures(project(':dd-java-agent:agent-ci-visibility')) + + testImplementation group: 'org.scala-lang', name: 'scala-library', version: '2.12.20' + testImplementation group: 'com.disneystreaming', name: 'weaver-cats_3', version: '0.8.4' + + testImplementation group: 'com.disneystreaming', name: 'weaver-cats_3', version: '+' +} + +compileTestGroovy { + dependsOn compileTestScala + classpath += files(sourceSets.test.scala.destinationDirectory) +} + +compileLatestDepTestGroovy { + dependsOn compileLatestDepTestScala + classpath += files(sourceSets.latestDepTest.scala.destinationDirectory) +} diff --git a/dd-java-agent/instrumentation/weaver/gradle.lockfile b/dd-java-agent/instrumentation/weaver/gradle.lockfile new file mode 100644 index 00000000000..a79bf4fb0da --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/gradle.lockfile @@ -0,0 +1,249 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +cafe.cryptography:curve25519-elisabeth:0.1.0=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +cafe.cryptography:ed25519-elisabeth:0.1.0=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +ch.qos.logback:logback-classic:1.2.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +ch.qos.logback:logback-core:1.2.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.beust:jcommander:1.78=latestDepTestRuntimeClasspath,testRuntimeClasspath +com.blogspot.mydailyjava:weak-lock-free:0.17=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.datadoghq.okhttp3:okhttp:3.12.15=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.datadoghq.okio:okio:1.17.6=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.datadoghq:dd-javac-plugin-client:0.2.2=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.datadoghq:java-dogstatsd-client:4.4.0=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.datadoghq:sketches-java:0.8.3=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.eed3si9n:shaded-jawn-parser_2.13:0.9.1=zinc +com.eed3si9n:shaded-scalajson_2.13:1.0.0-M4=zinc +com.eed3si9n:sjson-new-core_2.13:0.9.1=zinc +com.eed3si9n:sjson-new-scalajson_2.13:0.9.1=zinc +com.fasterxml.jackson.core:jackson-annotations:2.16.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-core:2.16.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-databind:2.16.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson:jackson-bom:2.16.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.github.javaparser:javaparser-core:3.25.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.github.jnr:jffi:1.3.13=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.jnr:jnr-a64asm:1.0.0=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.jnr:jnr-constants:0.10.4=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.jnr:jnr-enxio:0.32.17=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.jnr:jnr-ffi:2.2.16=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.jnr:jnr-posix:3.1.19=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.jnr:jnr-unixsocket:0.38.22=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.jnr:jnr-x86asm:1.0.2=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.github.spotbugs:spotbugs-annotations:4.2.0=compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.github.spotbugs:spotbugs-annotations:4.7.3=spotbugs +com.github.spotbugs:spotbugs:4.7.3=spotbugs +com.github.stefanbirkner:system-rules:1.19.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.auto.service:auto-service-annotations:1.0-rc7=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,testAnnotationProcessor,testCompileClasspath +com.google.auto.service:auto-service:1.0-rc7=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +com.google.auto:auto-common:0.10=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,latestDepTestAnnotationProcessor,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath +com.google.code.gson:gson:2.9.1=spotbugs +com.google.errorprone:error_prone_annotations:2.2.0=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:failureaccess:1.0.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:guava:20.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.guava:guava:27.0.1-jre=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +com.google.j2objc:j2objc-annotations:1.1=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +com.google.re2j:re2j:1.7=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +com.jayway.jsonpath:json-path:2.8.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.lmax:disruptor:3.4.2=zinc +com.squareup.moshi:moshi:1.11.0=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.squareup.okhttp3:logging-interceptor:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.squareup.okhttp3:okhttp:3.12.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +com.squareup.okio:okio:1.17.5=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.swoval:file-tree-views:2.1.10=zinc +com.thoughtworks.qdox:qdox:1.12.1=latestDepTestRuntimeClasspath,testRuntimeClasspath +com.vaadin.external.google:android-json:0.0.20131108.vaadin1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-codec:commons-codec:1.15=spotbugs +commons-fileupload:commons-fileupload:1.5=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +commons-io:commons-io:2.11.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +de.thetaphi:forbiddenapis:3.1=compileClasspath +info.picocli:picocli:4.6.3=latestDepTestRuntimeClasspath,testRuntimeClasspath +io.github.java-diff-utils:java-diff-utils:4.12=zinc +io.sqreen:libsqreen:11.2.0=latestDepTestRuntimeClasspath,testRuntimeClasspath +javax.servlet:javax.servlet-api:3.1.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +jaxen:jaxen:1.2.0=spotbugs +jline:jline:2.14.6=latestDepTestRuntimeClasspath,testRuntimeClasspath +junit:junit-dep:4.11=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +junit:junit:4.13.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy-agent:1.14.18=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.14.18=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +net.java.dev.jna:jna-platform:5.13.0=zinc +net.java.dev.jna:jna-platform:5.8.0=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +net.java.dev.jna:jna:5.13.0=zinc +net.java.dev.jna:jna:5.8.0=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +net.jcip:jcip-annotations:1.0=compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +net.minidev:accessors-smart:2.4.9=latestDepTestRuntimeClasspath,testRuntimeClasspath +net.minidev:json-smart:2.4.10=latestDepTestRuntimeClasspath,testRuntimeClasspath +net.openhft:zero-allocation-hashing:0.10.1=zinc +net.sf.saxon:Saxon-HE:11.4=spotbugs +org.apache.ant:ant-antlr:1.10.12=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.apache.ant:ant-antlr:1.9.15=codenarc +org.apache.ant:ant-junit:1.10.12=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.apache.ant:ant-junit:1.9.15=codenarc +org.apache.ant:ant-launcher:1.10.12=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.apache.ant:ant:1.10.12=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.bcel:bcel:6.5.0=spotbugs +org.apache.commons:commons-lang3:3.12.0=spotbugs +org.apache.commons:commons-text:1.10.0=spotbugs +org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs +org.apache.httpcomponents.core5:httpcore5-h2:5.1.3=spotbugs +org.apache.httpcomponents.core5:httpcore5:5.1.3=spotbugs +org.apache.logging.log4j:log4j-api:2.17.1=zinc +org.apache.logging.log4j:log4j-api:2.19.0=spotbugs +org.apache.logging.log4j:log4j-core:2.17.1=zinc +org.apache.logging.log4j:log4j-core:2.19.0=spotbugs +org.apiguardian:apiguardian-api:1.1.2=latestDepTestCompileClasspath,testCompileClasspath +org.checkerframework:checker-qual:2.5.2=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +org.codehaus.groovy:groovy-all:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-ant:2.5.14=codenarc +org.codehaus.groovy:groovy-ant:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-astbuilder:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-cli-picocli:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-console:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-datetime:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-docgenerator:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-groovydoc:2.5.14=codenarc +org.codehaus.groovy:groovy-groovydoc:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-groovysh:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-jmx:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-json:2.5.14=codenarc +org.codehaus.groovy:groovy-json:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-jsr223:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-macro:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-nio:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-servlet:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-sql:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-swing:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-templates:2.5.14=codenarc +org.codehaus.groovy:groovy-templates:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-test-junit5:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-test:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-testng:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy-xml:2.5.14=codenarc +org.codehaus.groovy:groovy-xml:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.groovy:groovy:2.5.14=codenarc +org.codehaus.groovy:groovy:3.0.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.codehaus.mojo:animal-sniffer-annotations:1.17=annotationProcessor,latestDepTestAnnotationProcessor,testAnnotationProcessor +org.codenarc:CodeNarc:2.2.0=codenarc +org.dom4j:dom4j:2.1.3=spotbugs +org.eclipse.jetty:jetty-http:9.4.56.v20240826=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.eclipse.jetty:jetty-io:9.4.56.v20240826=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.eclipse.jetty:jetty-server:9.4.56.v20240826=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.eclipse.jetty:jetty-util:9.4.56.v20240826=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.freemarker:freemarker:2.3.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.fusesource.jansi:jansi:2.1.0=zinc +org.gmetrics:GMetrics:1.1=codenarc +org.hamcrest:hamcrest-core:1.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jacoco:org.jacoco.core:0.8.12=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.jacoco:org.jacoco.report:0.8.12=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.jctools:jctools-core:3.3.0=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jetbrains.kotlin:kotlin-stdlib:1.6.21=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jetbrains:annotations:13.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.jline:jline-terminal-jansi:3.19.0=zinc +org.jline:jline-terminal-jna:3.19.0=zinc +org.jline:jline-terminal:3.19.0=zinc +org.jline:jline:3.22.0=zinc +org.junit.jupiter:junit-jupiter-api:5.9.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:5.9.2=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:1.9.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:1.9.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-launcher:1.9.2=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-runner:1.9.2=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-suite-api:1.9.2=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-suite-commons:1.9.2=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.junit:junit-bom:5.9.1=spotbugs +org.junit:junit-bom:5.9.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.msgpack:jackson-dataformat-msgpack:0.9.6=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.msgpack:msgpack-core:0.9.6=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.objenesis:objenesis:3.3=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.2.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.ow2.asm:asm-analysis:9.2=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +org.ow2.asm:asm-analysis:9.4=spotbugs +org.ow2.asm:asm-commons:9.2=instrumentPluginClasspath,muzzleTooling,runtimeClasspath +org.ow2.asm:asm-commons:9.4=spotbugs +org.ow2.asm:asm-commons:9.7=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.ow2.asm:asm-tree:9.2=instrumentPluginClasspath,muzzleTooling,runtimeClasspath +org.ow2.asm:asm-tree:9.4=spotbugs +org.ow2.asm:asm-tree:9.7=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.ow2.asm:asm-util:9.2=instrumentPluginClasspath,latestDepTestRuntimeClasspath,muzzleTooling,runtimeClasspath,testRuntimeClasspath +org.ow2.asm:asm-util:9.4=spotbugs +org.ow2.asm:asm:9.2=instrumentPluginClasspath,muzzleTooling,runtimeClasspath +org.ow2.asm:asm:9.4=spotbugs +org.ow2.asm:asm:9.7=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.scala-lang.modules:scala-parallel-collections_2.13:0.2.0=zinc +org.scala-lang.modules:scala-parser-combinators_2.13:1.1.2=zinc +org.scala-lang.modules:scala-xml_2.12:1.2.0=testCompileClasspath,testRuntimeClasspath +org.scala-lang.modules:scala-xml_2.12:2.1.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scala-lang.modules:scala-xml_2.13:1.2.0=compileClasspath +org.scala-lang.modules:scala-xml_2.13:2.1.0=zinc +org.scala-lang:scala-compiler:2.13.11=zinc +org.scala-lang:scala-library:2.12.15=testCompileClasspath,testRuntimeClasspath +org.scala-lang:scala-library:2.12.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scala-lang:scala-library:2.13.0=compileClasspath +org.scala-lang:scala-library:2.13.11=zinc +org.scala-lang:scala-reflect:2.12.10=testCompileClasspath,testRuntimeClasspath +org.scala-lang:scala-reflect:2.12.17=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scala-lang:scala-reflect:2.13.0=compileClasspath +org.scala-lang:scala-reflect:2.13.11=zinc +org.scala-sbt.jline:jline:2.14.7-sbt-a1b0ffbb8f64bb820f4f84a0c07a0c0964507493=zinc +org.scala-sbt:collections_2.13:1.9.2=zinc +org.scala-sbt:compiler-bridge_2.13:1.9.3=zinc +org.scala-sbt:compiler-interface:1.9.3=zinc +org.scala-sbt:core-macros_2.13:1.9.2=zinc +org.scala-sbt:io_2.13:1.9.1=zinc +org.scala-sbt:launcher-interface:1.4.2=zinc +org.scala-sbt:sbinary_2.13:0.5.1=zinc +org.scala-sbt:util-control_2.13:1.9.2=zinc +org.scala-sbt:util-interface:1.9.2=zinc +org.scala-sbt:util-logging_2.13:1.9.2=zinc +org.scala-sbt:util-position_2.13:1.9.2=zinc +org.scala-sbt:util-relation_2.13:1.9.2=zinc +org.scala-sbt:zinc-apiinfo_2.13:1.9.3=zinc +org.scala-sbt:zinc-classfile_2.13:1.9.3=zinc +org.scala-sbt:zinc-classpath_2.13:1.9.3=zinc +org.scala-sbt:zinc-compile-core_2.13:1.9.3=zinc +org.scala-sbt:zinc-core_2.13:1.9.3=zinc +org.scala-sbt:zinc-persist-core-assembly:1.9.3=zinc +org.scala-sbt:zinc-persist_2.13:1.9.3=zinc +org.scala-sbt:zinc_2.13:1.9.3=zinc +org.scalactic:scalactic_2.12:3.1.0=testCompileClasspath,testRuntimeClasspath +org.scalactic:scalactic_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalactic:scalactic_2.13:3.0.8=compileClasspath +org.scalatest:scalatest-compatible:3.1.0=testCompileClasspath,testRuntimeClasspath +org.scalatest:scalatest-compatible:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-core_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-diagrams_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-featurespec_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-flatspec_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-freespec_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-funspec_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-funsuite_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-matchers-core_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-mustmatchers_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-propspec_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-refspec_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-shouldmatchers_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest-wordspec_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest_2.12:3.1.0=testCompileClasspath,testRuntimeClasspath +org.scalatest:scalatest_2.12:3.3.0-SNAP4=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalatest:scalatest_2.13:3.0.8=compileClasspath +org.skyscreamer:jsonassert:1.5.1=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.slf4j:jcl-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.slf4j:jul-to-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.slf4j:log4j-over-slf4j:1.7.30=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.slf4j:slf4j-api:1.7.30=compileClasspath,instrumentPluginClasspath,latestDepTestCompileClasspath,muzzleBootstrap,muzzleTooling,runtimeClasspath,testCompileClasspath +org.slf4j:slf4j-api:1.7.36=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.slf4j:slf4j-api:2.0.0=spotbugs,spotbugsSlf4j +org.slf4j:slf4j-simple:2.0.0=spotbugsSlf4j +org.spockframework:spock-core:2.2-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.spockframework:spock-junit4:2.2-groovy-3.0=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +org.testng:testng:7.5=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.webjars:jquery:3.5.1=latestDepTestRuntimeClasspath,testRuntimeClasspath +org.xmlresolver:xmlresolver:4.4.3=spotbugs +xml-apis:xml-apis:1.4.01=spotbugs +empty=scalaCompilerPlugins,spotbugsPlugins diff --git a/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/DatadogWeaverReporter.java b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/DatadogWeaverReporter.java new file mode 100644 index 00000000000..78180cb65ad --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/DatadogWeaverReporter.java @@ -0,0 +1,137 @@ +package datadog.trace.instrumentation.weaver; + +import datadog.trace.api.civisibility.InstrumentationBridge; +import datadog.trace.api.civisibility.events.TestDescriptor; +import datadog.trace.api.civisibility.events.TestEventsHandler; +import datadog.trace.api.civisibility.events.TestSuiteDescriptor; +import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; +import datadog.trace.api.time.SystemTimeSource; +import datadog.trace.util.AgentThreadFactory; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Collections; +import sbt.testing.TaskDef; +import weaver.Result; +import weaver.TestOutcome; +import weaver.framework.SuiteFinished; +import weaver.framework.SuiteStarted; +import weaver.framework.TestFinished; + +public class DatadogWeaverReporter { + + private static final String TEST_FRAMEWORK = "weaver"; + private static final String TEST_FRAMEWORK_VERSION = WeaverUtils.getWeaverVersion(); + + private static volatile TestEventsHandler + TEST_EVENTS_HANDLER; + + static { + Runtime.getRuntime() + .addShutdownHook( + AgentThreadFactory.newAgentThread( + AgentThreadFactory.AgentThread.CI_TEST_EVENTS_SHUTDOWN_HOOK, + DatadogWeaverReporter::stop, + false)); + } + + public static synchronized void start() { + if (TEST_EVENTS_HANDLER == null) { + TEST_EVENTS_HANDLER = InstrumentationBridge.createTestEventsHandler("weaver", null, null); + } + } + + public static synchronized void stop() { + if (TEST_EVENTS_HANDLER != null) { + TEST_EVENTS_HANDLER.close(); + TEST_EVENTS_HANDLER = null; + } + } + + public static void onSuiteStart(SuiteStarted event) { + String testSuiteName = event.name(); + Class testClass = WeaverUtils.getClass(testSuiteName); + Collection categories = Collections.emptyList(); + boolean parallelized = true; + + TEST_EVENTS_HANDLER.onTestSuiteStart( + new TestSuiteDescriptor(testSuiteName, testClass), + testSuiteName, + TEST_FRAMEWORK, + TEST_FRAMEWORK_VERSION, + testClass, + categories, + parallelized, + TestFrameworkInstrumentation.WEAVER, + null); + } + + public static void onSuiteFinish(SuiteFinished event) { + String testSuiteName = event.name(); + Class testClass = WeaverUtils.getClass(testSuiteName); + + TEST_EVENTS_HANDLER.onTestSuiteFinish(new TestSuiteDescriptor(testSuiteName, testClass), null); + } + + public static void onTestFinished(TestFinished event, TaskDef taskDef) { + if (!(event.outcome() instanceof TestOutcome.Default)) { + // Cannot obtain desired information without the TestOutcome.Default fields + return; + } + + TestOutcome.Default testOutcome = (TestOutcome.Default) event.outcome(); + String testSuiteName = taskDef.fullyQualifiedName(); + Class testClass = WeaverUtils.getClass(testSuiteName); + TestSuiteDescriptor testSuiteDescriptor = new TestSuiteDescriptor(testSuiteName, testClass); + String testName = event.outcome().name(); + Object testQualifier = null; + String testParameters = null; + Collection categories = Collections.emptyList(); + TestDescriptor testDescriptor = + new TestDescriptor(testSuiteName, testClass, testName, testParameters, testQualifier); + String testMethodName = null; + Method testMethod = null; + boolean isRetry = false; + + // Only test finish is reported, so fake test start timestamp + long endMicros = SystemTimeSource.INSTANCE.getCurrentTimeMicros(); + long startMicros = endMicros - testOutcome.duration().toMicros(); + TEST_EVENTS_HANDLER.onTestStart( + testSuiteDescriptor, + testDescriptor, + testSuiteName, + testName, + TEST_FRAMEWORK, + TEST_FRAMEWORK_VERSION, + testParameters, + categories, + testClass, + testMethodName, + testMethod, + isRetry, + startMicros); + + if (testOutcome.result() instanceof Result.Ignored) { + Result.Ignored result = (Result.Ignored) testOutcome.result(); + String reason = result.reason().getOrElse(null); + TEST_EVENTS_HANDLER.onTestSkip(testDescriptor, reason); + } else if (testOutcome.result() instanceof Result.Cancelled) { + Result.Cancelled result = (Result.Cancelled) testOutcome.result(); + String reason = result.reason().getOrElse(null); + TEST_EVENTS_HANDLER.onTestSkip(testDescriptor, reason); + } else if (testOutcome.result() instanceof Result.Failure) { + Result.Failure result = (Result.Failure) testOutcome.result(); + Throwable throwable = result.source().getOrElse(null); + TEST_EVENTS_HANDLER.onTestFailure(testDescriptor, throwable); + } else if (testOutcome.result() instanceof Result.Failures) { + Result.Failures result = (Result.Failures) testOutcome.result(); + Throwable throwable = result.failures().head().source().getOrElse(null); + TEST_EVENTS_HANDLER.onTestFailure(testDescriptor, throwable); + } else if (testOutcome.result() instanceof Result.Exception) { + Result.Exception result = (Result.Exception) testOutcome.result(); + Throwable throwable = result.source(); + TEST_EVENTS_HANDLER.onTestFailure(testDescriptor, throwable); + } + + TEST_EVENTS_HANDLER.onTestFinish(testDescriptor, endMicros); + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/TaskDefAwareQueueProxy.java b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/TaskDefAwareQueueProxy.java new file mode 100644 index 00000000000..e7b79ad2d72 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/TaskDefAwareQueueProxy.java @@ -0,0 +1,37 @@ +package datadog.trace.instrumentation.weaver; + +import java.util.concurrent.ConcurrentLinkedQueue; +import sbt.testing.TaskDef; +import weaver.framework.RunEvent; +import weaver.framework.SuiteFinished; +import weaver.framework.SuiteStarted; +import weaver.framework.TestFinished; + +public final class TaskDefAwareQueueProxy extends ConcurrentLinkedQueue { + + private final TaskDef taskDef; + private final ConcurrentLinkedQueue delegate; + + public TaskDefAwareQueueProxy(TaskDef taskDef, ConcurrentLinkedQueue delegate) { + super(); + this.taskDef = taskDef; + this.delegate = delegate; + DatadogWeaverReporter.start(); + } + + @Override + public T poll() { + T event = delegate.poll(); + if (event instanceof RunEvent) { + // handle event here, using taskDef reference to get suite details + if (event instanceof SuiteStarted) { + DatadogWeaverReporter.onSuiteStart((SuiteStarted) event); + } else if (event instanceof SuiteFinished) { + DatadogWeaverReporter.onSuiteFinish((SuiteFinished) event); + } else if (event instanceof TestFinished) { + DatadogWeaverReporter.onTestFinished((TestFinished) event, taskDef); + } + } + return event; + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/WeaverInstrumentation.java b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/WeaverInstrumentation.java new file mode 100644 index 00000000000..e432561af02 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/WeaverInstrumentation.java @@ -0,0 +1,50 @@ +package datadog.trace.instrumentation.weaver; + +import static net.bytebuddy.matcher.ElementMatchers.isConstructor; + +import com.google.auto.service.AutoService; +import datadog.trace.agent.tooling.Instrumenter; +import datadog.trace.agent.tooling.InstrumenterModule; +import java.util.concurrent.ConcurrentLinkedQueue; +import net.bytebuddy.asm.Advice; +import sbt.testing.TaskDef; +import weaver.framework.SuiteEvent; + +@AutoService(InstrumenterModule.class) +public class WeaverInstrumentation extends InstrumenterModule.CiVisibility + implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice { + + public WeaverInstrumentation() { + super("ci-visibility", "weaver"); + } + + @Override + public String instrumentedType() { + return "weaver.framework.SbtTask"; + } + + @Override + public String[] helperClassNames() { + return new String[] { + packageName + ".DatadogWeaverReporter", + packageName + ".TaskDefAwareQueueProxy", + packageName + ".WeaverUtils", + }; + } + + @Override + public void methodAdvice(MethodTransformer transformer) { + transformer.applyAdvice( + isConstructor(), WeaverInstrumentation.class.getName() + "$SbtTaskCreationAdvice"); + } + + public static class SbtTaskCreationAdvice { + @Advice.OnMethodExit(suppress = Throwable.class) + public static void onTaskCreation( + @Advice.FieldValue(value = "queue", readOnly = false) + ConcurrentLinkedQueue queue, + @Advice.FieldValue("taskDef") TaskDef taskDef) { + queue = new TaskDefAwareQueueProxy(taskDef, queue); + } + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/WeaverUtils.java b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/WeaverUtils.java new file mode 100644 index 00000000000..f86e95212ae --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/main/java/datadog/trace/instrumentation/weaver/WeaverUtils.java @@ -0,0 +1,52 @@ +package datadog.trace.instrumentation.weaver; + +import java.io.InputStream; +import java.net.URL; +import java.util.Properties; +import javax.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.framework.SbtTask; + +public abstract class WeaverUtils { + + private static final Logger log = LoggerFactory.getLogger(WeaverUtils.class); + + private static final ClassLoader CLASS_LOADER = SbtTask.class.getClassLoader(); + + private WeaverUtils() {} + + public static @Nullable String getWeaverVersion() { + try { + String className = '/' + SbtTask.class.getName().replace('.', '/') + ".class"; + URL classResource = SbtTask.class.getResource(className); + if (classResource == null) { + return null; + } + + String classPath = classResource.toString(); + String manifestPath = + classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF"; + try (InputStream manifestStream = new URL(manifestPath).openStream()) { + Properties manifestProperties = new Properties(); + manifestProperties.load(manifestStream); + return manifestProperties.getProperty("Implementation-Version"); + } + } catch (Exception e) { + return null; + } + } + + @Nullable + public static Class getClass(String className) { + if (className.isEmpty()) { + return null; + } + try { + return CLASS_LOADER.loadClass(className); + } catch (Exception e) { + log.debug("Could not load class {}", className, e); + return null; + } + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/main/scala/datadog/trace/instrumentation/weaver/WeaverIntegrationTestRunner.scala b/dd-java-agent/instrumentation/weaver/src/main/scala/datadog/trace/instrumentation/weaver/WeaverIntegrationTestRunner.scala new file mode 100644 index 00000000000..22902a12c4a --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/main/scala/datadog/trace/instrumentation/weaver/WeaverIntegrationTestRunner.scala @@ -0,0 +1,63 @@ +package datadog.trace.instrumentation.weaver + +import sbt.testing.* +import weaver.framework.CatsFingerprints.SuiteFingerprint +import weaver.framework.{CatsEffect, LoggedEvent} + +import java.io.PrintStream +import scala.jdk.CollectionConverters.* + +object WeaverIntegrationTestRunner { + def runTests(testNames: java.util.List[String]): Unit = { + class WeaverTestEventHandler() extends EventHandler { + val events = scala.collection.mutable.ListBuffer.empty[sbt.testing.Event] + + override def handle(event: Event): Unit = synchronized { + val _ = events.append(event) + } + } + + class WeaverTestLogger() extends Logger { + val logs = scala.collection.mutable.ListBuffer.empty[LoggedEvent] + + private def add(event: LoggedEvent): Unit = synchronized { + val _ = logs.append(event) + } + + override def ansiCodesSupported(): Boolean = false + + override def error(msg: String): Unit = + add(LoggedEvent.Error(msg)) + + override def warn(msg: String): Unit = + add(LoggedEvent.Warn(msg)) + + override def info(msg: String): Unit = + add(LoggedEvent.Info(msg)) + + override def debug(msg: String): Unit = + add(LoggedEvent.Debug(msg)) + + override def trace(t: Throwable): Unit = + add(LoggedEvent.Trace(t)) + } + + val framework = new CatsEffect(new PrintStream(System.out)) + val runner = framework.runner(Array.empty, Array.empty, getClass.getClassLoader) + val scalaTestNames: List[String] = testNames.asScala.toList + val taskDefs: Array[TaskDef] = scalaTestNames.map { name => + new TaskDef(name, SuiteFingerprint, false, Array(new SuiteSelector())) + }.toArray + val tasks = runner.tasks(taskDefs) + val eventHandler = new WeaverTestEventHandler() + val logger = new WeaverTestLogger() + tasks.foreach(_.execute(eventHandler, Array(logger))) + logger.logs.foreach { + case LoggedEvent.Error(msg) => println(s"$msg") + case LoggedEvent.Warn(msg) => println(s"$msg") + case LoggedEvent.Info(msg) => println(s"$msg") + case LoggedEvent.Debug(msg) => println(s"$msg") + case LoggedEvent.Trace(t) => t.printStackTrace() + } + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/groovy/WeaverTest.groovy b/dd-java-agent/instrumentation/weaver/src/test/groovy/WeaverTest.groovy new file mode 100644 index 00000000000..b0da13aabe5 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/groovy/WeaverTest.groovy @@ -0,0 +1,53 @@ +import datadog.trace.api.DisableTestTrace +import datadog.trace.civisibility.CiVisibilityInstrumentationTest +import datadog.trace.instrumentation.weaver.DatadogWeaverReporter +import datadog.trace.instrumentation.weaver.WeaverIntegrationTestRunner +import datadog.trace.instrumentation.weaver.WeaverUtils +import org.example.TestCanceled +import org.example.TestFailed +import org.example.TestFailedExceptionPure +import org.example.TestFailedPure +import org.example.TestIgnored +import org.example.TestSucceed +import org.example.TestSucceedGlobalResource +import org.example.TestSucceedPure +import org.example.TestSucceedSuiteResource + +@DisableTestTrace(reason = "avoid self-tracing") +class WeaverTest extends CiVisibilityInstrumentationTest { + + def "test #testcaseName"() { + runTests(tests) + + assertSpansData(testcaseName, expectedTracesCount) + + where: + testcaseName | tests | expectedTracesCount + "test-succeed-pure" | [TestSucceedPure] | 2 + "test-failed-pure" | [TestFailedPure] | 2 + "test-failed-exception-pure" | [TestFailedExceptionPure] | 2 + "test-succeeded" | [TestSucceed] | 2 + "test-failed" | [TestFailed] | 2 + "test-ignored" | [TestIgnored] | 2 + "test-canceled" | [TestCanceled] | 2 + "test-succeed-suite-resource" | [TestSucceedSuiteResource] | 3 + "test-succeed-global-resource" | [TestSucceedGlobalResource] | 2 + } + + @Override + String instrumentedLibraryName() { + return "weaver" + } + + @Override + String instrumentedLibraryVersion() { + return WeaverUtils.weaverVersion + } + + void runTests(List> tests) { + DatadogWeaverReporter.start() + def testNames = tests.collect { it.name } + WeaverIntegrationTestRunner.runTests(testNames) + DatadogWeaverReporter.stop() + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-canceled/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-canceled/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-canceled/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-canceled/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-canceled/events.ftl new file mode 100644 index 00000000000..23b36cb9b1b --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-canceled/events.ftl @@ -0,0 +1,148 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestCanceled", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "skip", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestCanceled", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestCanceled.test canceled", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "skip", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test canceled", + "span.kind" : "test", + "test.suite" : "org.example.TestCanceled", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test.skip_reason" : "cancel reason", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "skip", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "skip", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-exception-pure/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-exception-pure/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-exception-pure/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-exception-pure/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-exception-pure/events.ftl new file mode 100644 index 00000000000..af709986765 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-exception-pure/events.ftl @@ -0,0 +1,150 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestFailedExceptionPure", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestFailedExceptionPure", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestFailedExceptionPure.pure exception test", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 1, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "fail", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "pure exception test", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedExceptionPure", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "error.type" : "java.lang.RuntimeException", + "_dd.profiling.ctx" : "test", + "error.message" : ${content_meta_error_message}, + "error.stack" : ${content_meta_error_stack}, + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "fail", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-pure/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-pure/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-pure/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-pure/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-pure/events.ftl new file mode 100644 index 00000000000..cd1a276e412 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed-pure/events.ftl @@ -0,0 +1,150 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestFailedPure", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestFailedPure", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestFailedPure.pure test fails", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 1, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "fail", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "pure test fails", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedPure", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "error.type" : "weaver.AssertionException", + "_dd.profiling.ctx" : "test", + "error.message" : ${content_meta_error_message}, + "error.stack" : ${content_meta_error_stack}, + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "fail", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed/events.ftl new file mode 100644 index 00000000000..79330afd33c --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-failed/events.ftl @@ -0,0 +1,150 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestFailed", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestFailed", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestFailed.test fails", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 1, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "fail", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test fails", + "span.kind" : "test", + "test.suite" : "org.example.TestFailed", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "error.type" : "weaver.AssertionException", + "_dd.profiling.ctx" : "test", + "error.message" : ${content_meta_error_message}, + "error.stack" : ${content_meta_error_stack}, + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "fail", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-ignored/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-ignored/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-ignored/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-ignored/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-ignored/events.ftl new file mode 100644 index 00000000000..63f06fe8e7c --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-ignored/events.ftl @@ -0,0 +1,148 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestIgnored", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "skip", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestIgnored", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestIgnored.test ignored", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "skip", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test ignored", + "span.kind" : "test", + "test.suite" : "org.example.TestIgnored", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test.skip_reason" : "ignore reason", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "skip", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "skip", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-global-resource/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-global-resource/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-global-resource/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-global-resource/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-global-resource/events.ftl new file mode 100644 index 00000000000..ae32c1ecd3e --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-global-resource/events.ftl @@ -0,0 +1,147 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestSucceedGlobalResource", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedGlobalResource", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestSucceedGlobalResource.Test Global Resource", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "Test Global Resource", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedGlobalResource", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "pass", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-pure/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-pure/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-pure/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-pure/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-pure/events.ftl new file mode 100644 index 00000000000..325ff960e53 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-pure/events.ftl @@ -0,0 +1,147 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestSucceedPure", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedPure", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestSucceedPure.pure test succeeds", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "pure test succeeds", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedPure", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "pass", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-suite-resource/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-suite-resource/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-suite-resource/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-suite-resource/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-suite-resource/events.ftl new file mode 100644 index 00000000000..14707277ee2 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeed-suite-resource/events.ftl @@ -0,0 +1,191 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestSucceedSuiteResource", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedSuiteResource", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestSucceedSuiteResource.Test 1 Shared Suite Resource", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "Test 1 Shared Suite Resource", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedSuiteResource", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestSucceedSuiteResource.Test 2 Shared Suite Resource", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "Test 2 Shared Suite Resource", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedSuiteResource", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "pass", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_5} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeeded/coverages.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeeded/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeeded/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeeded/events.ftl b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeeded/events.ftl new file mode 100644 index 00000000000..0b33b2e60cc --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/resources/test-succeeded/events.ftl @@ -0,0 +1,147 @@ +[ { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_suite", + "resource" : "org.example.TestSucceed", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceed", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test", + "resource" : "org.example.TestSucceed.test succeeds", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0, + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.module" : "weaver", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test succeeds", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceed", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_session", + "resource" : "weaver", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "process_id" : ${content_metrics_process_id}, + "_dd.profiling.enabled" : 0, + "_dd.trace_span_attribute_schema" : 0 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.status" : "pass", + "test_session.name" : "session-name", + "language" : "jvm", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "weaver", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "weaver.test_module", + "resource" : "weaver", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.module" : "weaver", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "weaver", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "weaver" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestCanceled.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestCanceled.scala new file mode 100644 index 00000000000..3c65f02e35c --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestCanceled.scala @@ -0,0 +1,12 @@ +package org.example + +import cats.effect._ +import weaver._ + +object TestCanceled extends SimpleIOSuite { + test("test canceled") { + for { + _ <- cancel("cancel reason") + } yield expect(1 == 1) + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailed.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailed.scala new file mode 100644 index 00000000000..c7ce794a08c --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailed.scala @@ -0,0 +1,13 @@ +package org.example + +import cats.effect._ +import weaver._ + +object TestFailed extends SimpleIOSuite { + test("test fails") { + for { + x <- IO.delay(1) + y <- IO.delay(2) + } yield expect(x == y) + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailedExceptionPure.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailedExceptionPure.scala new file mode 100644 index 00000000000..516f196132c --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailedExceptionPure.scala @@ -0,0 +1,10 @@ +package org.example + +import weaver._ + +object TestFailedExceptionPure extends FunSuite { + test("pure exception test") { + expect(1 == 1) + throw new RuntimeException("Exception inside test.") + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailedPure.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailedPure.scala new file mode 100644 index 00000000000..f8395ce0246 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestFailedPure.scala @@ -0,0 +1,9 @@ +package org.example + +import weaver._ + +object TestFailedPure extends FunSuite { + test("pure test fails") { + expect(2 == 1) + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestIgnored.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestIgnored.scala new file mode 100644 index 00000000000..3b307ba44cc --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestIgnored.scala @@ -0,0 +1,12 @@ +package org.example + +import cats.effect._ +import weaver._ + +object TestIgnored extends SimpleIOSuite { + test("test ignored") { + for { + _ <- ignore("ignore reason") + } yield expect(1 == 1) + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceed.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceed.scala new file mode 100644 index 00000000000..573d1d4266f --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceed.scala @@ -0,0 +1,13 @@ +package org.example + +import cats.effect._ +import weaver._ + +object TestSucceed extends SimpleIOSuite { + test("test succeeds") { + for { + x <- IO.delay(1) + y <- IO.delay(1) + } yield expect(x == y) + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedGlobalResource.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedGlobalResource.scala new file mode 100644 index 00000000000..e09ba4833f4 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedGlobalResource.scala @@ -0,0 +1,32 @@ +package org.example + +import cats.effect.* +import weaver.* + +object MyResource extends GlobalResource { + override def sharedResources(global: GlobalWrite): Resource[IO, Unit] = baseResources.flatMap(global.putR(_)) + + def baseResources: Resource[IO, String] = Resource.pure[IO, String]("hello world!") + + def sharedResourceOrFallback(read: GlobalRead): Resource[IO, String] = + read.getR[String]().flatMap { + case Some(value) => Resource.eval(IO(value)) + case None => baseResources + } +} + +class TestSucceedGlobalResourceClass(global: GlobalRead) extends IOSuite { + + import MyResource.* + + override type Res = String + + override def sharedResource: Resource[IO, String] = sharedResourceOrFallback(global) + + test("Test Global Resource") { sharedString => + IO(expect(sharedString == "hello world!")) + } +} + +object TestSucceedGlobalResource extends TestSucceedGlobalResourceClass(global = GlobalResourceF.Read.empty[IO](IO.asyncForIO)) { +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedPure.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedPure.scala new file mode 100644 index 00000000000..c4b00ad26c2 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedPure.scala @@ -0,0 +1,9 @@ +package org.example + +import weaver._ + +object TestSucceedPure extends FunSuite { + test("pure test succeeds") { + expect(1 == 1) + } +} diff --git a/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedSuiteResource.scala b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedSuiteResource.scala new file mode 100644 index 00000000000..57b7d9f53a1 --- /dev/null +++ b/dd-java-agent/instrumentation/weaver/src/test/scala/org/example/TestSucceedSuiteResource.scala @@ -0,0 +1,19 @@ +package org.example + +import cats.effect._ +import weaver._ + +object TestSucceedSuiteResource extends IOSuite { + + override type Res = Int + + override def sharedResource: Resource[IO, Res] = Resource.pure[IO, Res](42) + + test("Test 1 Shared Suite Resource") { res => + IO(expect(res == 42)) + } + + test("Test 2 Shared Suite Resource") { res => + IO(expect(res != 45)) + } +} diff --git a/gradle/configure_tests.gradle b/gradle/configure_tests.gradle index 79efc51c7e5..60280fa3144 100644 --- a/gradle/configure_tests.gradle +++ b/gradle/configure_tests.gradle @@ -14,7 +14,8 @@ def isTestingInstrumentation(Project project) { "testng-6", "testng-7", "karate", - "scalatest" + "scalatest", + "weaver" ].contains(project.name) } diff --git a/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java b/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java index 767c2663c0c..ddfc9292293 100644 --- a/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java +++ b/internal-api/src/main/java/datadog/trace/api/civisibility/events/TestEventsHandler.java @@ -29,13 +29,14 @@ void onTestSuiteStart( @Nullable Class testClass, @Nullable Collection categories, boolean parallelized, - TestFrameworkInstrumentation instrumentation); + TestFrameworkInstrumentation instrumentation, + @Nullable Long startTime); void onTestSuiteSkip(SuiteKey descriptor, @Nullable String reason); void onTestSuiteFailure(SuiteKey descriptor, @Nullable Throwable throwable); - void onTestSuiteFinish(SuiteKey descriptor); + void onTestSuiteFinish(SuiteKey descriptor, @Nullable Long endTime); void onTestStart( SuiteKey suiteDescriptor, @@ -49,13 +50,14 @@ void onTestStart( @Nullable Class testClass, @Nullable String testMethodName, @Nullable Method testMethod, - boolean isRetry); + boolean isRetry, + @Nullable Long startTime); void onTestSkip(TestKey descriptor, @Nullable String reason); void onTestFailure(TestKey descriptor, @Nullable Throwable throwable); - void onTestFinish(TestKey descriptor); + void onTestFinish(TestKey descriptor, @Nullable Long endTime); void onTestIgnore( SuiteKey suiteDescriptor, diff --git a/internal-api/src/main/java/datadog/trace/api/civisibility/telemetry/tag/TestFrameworkInstrumentation.java b/internal-api/src/main/java/datadog/trace/api/civisibility/telemetry/tag/TestFrameworkInstrumentation.java index d024b7f65e2..eedbaed7e80 100644 --- a/internal-api/src/main/java/datadog/trace/api/civisibility/telemetry/tag/TestFrameworkInstrumentation.java +++ b/internal-api/src/main/java/datadog/trace/api/civisibility/telemetry/tag/TestFrameworkInstrumentation.java @@ -12,6 +12,7 @@ public enum TestFrameworkInstrumentation implements TagValue { MUNIT, SCALATEST, KARATE, + WEAVER, OTHER; private final String s; diff --git a/settings.gradle b/settings.gradle index 9c2f9181340..8dee6a79630 100644 --- a/settings.gradle +++ b/settings.gradle @@ -504,6 +504,7 @@ include ':dd-java-agent:instrumentation:redisson' include ':dd-java-agent:instrumentation:redisson:redisson-2.0.0' include ':dd-java-agent:instrumentation:redisson:redisson-2.3.0' include ':dd-java-agent:instrumentation:redisson:redisson-3.10.3' +include ':dd-java-agent:instrumentation:weaver' include ':dd-java-agent:instrumentation:websphere-jmx' include ':dd-java-agent:instrumentation:wildfly-9' include ':dd-java-agent:instrumentation:zio'