From 407e5c74aa02f05d8661380f8248ccca56dce40c Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Tue, 26 Nov 2024 12:32:49 +0100 Subject: [PATCH 01/10] add tracing for junit4 setup/teardown actions --- .../JUnit4BeforeAfterInstrumentation.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java diff --git a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java new file mode 100644 index 00000000000..407505144a2 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java @@ -0,0 +1,67 @@ +package datadog.trace.instrumentation.junit4; + +import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; + +import com.google.auto.service.AutoService; +import datadog.trace.agent.tooling.Instrumenter; +import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.bootstrap.instrumentation.api.AgentScope; +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentTracer; +import datadog.trace.bootstrap.instrumentation.api.Tags; +import net.bytebuddy.asm.Advice; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.runners.model.FrameworkMethod; + +@AutoService(InstrumenterModule.class) +public class JUnit4BeforeAfterInstrumentation extends InstrumenterModule.CiVisibility + implements Instrumenter.ForKnownTypes { + + public JUnit4BeforeAfterInstrumentation() { + super("ci-visibility", "junit-4", "setup-teardown"); + } + + @Override + public String[] knownMatchingTypes() { + return new String[] { + "org.junit.internal.runners.statements.RunBefores", + "org.junit.internal.runners.statements.RunAfters" + }; + } + + @Override + public void methodAdvice(MethodTransformer transformer) { + transformer.applyAdvice( + named("invokeMethod") + .and(takesArgument(0, named("org.junit.runners.model.FrameworkMethod"))), + JUnit4BeforeAfterInstrumentation.class.getName() + "$RunBeforesAftersAdvice"); + } + + public static class RunBeforesAftersAdvice { + @Advice.OnMethodEnter(suppress = Throwable.class) + public static AgentScope startCallSpan(@Advice.Argument(0) final FrameworkMethod method) { + final AgentSpan span = AgentTracer.startSpan("junit", method.getMethod().getName()); + if (method.getMethod().isAnnotationPresent(Before.class)) { + span.setTag(Tags.TEST_CALLBACK, "Before"); + } else if (method.getMethod().isAnnotationPresent(After.class)) { + span.setTag(Tags.TEST_CALLBACK, "After"); + } else if (method.getMethod().isAnnotationPresent(BeforeClass.class)) { + span.setTag(Tags.TEST_CALLBACK, "BeforeClass"); + } else if (method.getMethod().isAnnotationPresent(AfterClass.class)) { + span.setTag(Tags.TEST_CALLBACK, "AfterClass"); + } + return AgentTracer.activateSpan(span); + } + + @Advice.OnMethodExit(suppress = Throwable.class) + public static void finishCallSpan(@Advice.Enter final AgentScope scope) { + AgentSpan span = scope.span(); + scope.close(); + span.finish(); + } + } +} From 43ffd7e9db3f09035f72515e8e6a2d983f0cefc7 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Tue, 26 Nov 2024 15:17:16 +0100 Subject: [PATCH 02/10] update instrumentation test fixtures --- .../JUnit4BeforeAfterInstrumentation.java | 2 +- .../src/test/groovy/JUnit4Test.groovy | 4 + .../org/example/TestSucceedBeforeAfter.java | 20 ++ .../TestSucceedBeforeClassAfterClass.java | 20 ++ .../events.ftl | 37 +++- .../test-succeed-before-after/coverages.ftl | 1 + .../test-succeed-before-after/events.ftl | 190 +++++++++++++++++ .../coverages.ftl | 1 + .../events.ftl | 192 ++++++++++++++++++ .../test-suite-setup-failure/events.ftl | 36 +++- .../test-suite-teardown-failure/events.ftl | 38 +++- 11 files changed, 534 insertions(+), 7 deletions(-) create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeAfter.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl diff --git a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java index 407505144a2..50cd22fb7b1 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java @@ -57,7 +57,7 @@ public static AgentScope startCallSpan(@Advice.Argument(0) final FrameworkMethod return AgentTracer.activateSpan(span); } - @Advice.OnMethodExit(suppress = Throwable.class) + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void finishCallSpan(@Advice.Enter final AgentScope scope) { AgentSpan span = scope.span(); scope.close(); diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy index a97d82a7225..729b3be2c0f 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy @@ -20,6 +20,8 @@ import org.example.TestSkipped import org.example.TestSkippedClass import org.example.TestSucceed import org.example.TestSucceedAndSkipped +import org.example.TestSucceedBeforeAfter +import org.example.TestSucceedBeforeClassAfterClass import org.example.TestSucceedExpectedException import org.example.TestSucceedKotlin import org.example.TestSucceedLegacy @@ -54,6 +56,8 @@ class JUnit4Test extends CiVisibilityInstrumentationTest { "test-success-and-failure" | [TestFailedAndSucceed] | 4 "test-suite-teardown-failure" | [TestFailedSuiteTearDown] | 1 "test-suite-setup-failure" | [TestFailedSuiteSetup] | 1 + "test-succeed-before-after" | [TestSucceedBeforeAfter] | 2 + "test-succeed-before-class-after-class" | [TestSucceedBeforeClassAfterClass] | 2 "test-assumption-failure" | [TestAssumption] | 2 "test-categories-are-included-in-spans" | [TestSucceedWithCategories] | 2 "test-assumption-failure-during-suite-setup" | [TestFailedSuiteSetUpAssumption] | 2 diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeAfter.java b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeAfter.java new file mode 100644 index 00000000000..24c44c7b7bb --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeAfter.java @@ -0,0 +1,20 @@ +package org.example; + +import static org.junit.Assert.assertTrue; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TestSucceedBeforeAfter { + @Before + public void testSetup() {} + + @After + public void testTeardown() {} + + @Test + public void testSucceed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java new file mode 100644 index 00000000000..93b931312ab --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java @@ -0,0 +1,20 @@ +package org.example; + +import static org.junit.Assert.assertTrue; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class TestSucceedBeforeClassAfterClass { + @BeforeClass + public static void classSetup() {} + + @AfterClass + public static void classTeardown() {} + + @Test + public void testSucceed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl index 748735d7f94..6c8f99c1a10 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl @@ -10,11 +10,13 @@ "duration" : ${content_duration}, "error" : 0, "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, "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}, "test.type" : "test", "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.status" : "skip", @@ -44,8 +46,11 @@ "start" : ${content_start_2}, "duration" : ${content_duration_2}, "error" : 0, - "metrics" : { }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, "test.type" : "test", "test.module" : "junit-4.10", "test.status" : "skip", @@ -72,8 +77,13 @@ "start" : ${content_start_3}, "duration" : ${content_duration_3}, "error" : 0, - "metrics" : { }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, "test.type" : "test", "test.source.file" : "dummy_source_path", "test.module" : "junit-4.10", @@ -82,6 +92,7 @@ "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" : "junit", "span.kind" : "test_suite_end", @@ -110,6 +121,7 @@ "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_4}, "test.source.end" : 18, "test.source.start" : 12 }, @@ -137,4 +149,25 @@ "test.framework" : "junit4" } } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "suiteSetup", + "resource" : "suiteSetup", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.callback" : "BeforeClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } } ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl new file mode 100644 index 00000000000..7b96c221c64 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl @@ -0,0 +1,190 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.10", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.10", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.10", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.10", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestSucceedBeforeAfter", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.10", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedBeforeAfter", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestSucceedBeforeAfter.testSucceed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "testSucceed()V", + "test.module" : "junit-4.10", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "testSucceed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeAfter", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_span_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "testSetup", + "resource" : "testSetup", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 0, + "metrics" : { }, + "meta" : { + "test.callback" : "Before", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_span_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "testTeardown", + "resource" : "testTeardown", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "test.callback" : "After", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl new file mode 100644 index 00000000000..c1f0556161d --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl @@ -0,0 +1,192 @@ +[ { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "classSetup", + "resource" : "classSetup", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.callback" : "BeforeClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "classTeardown", + "resource" : "classTeardown", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.callback" : "AfterClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_trace_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.10", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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_3}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.10", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_trace_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_module", + "resource" : "junit-4.10", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.type" : "test", + "test.module" : "junit-4.10", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_trace_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_suite", + "resource" : "org.example.TestSucceedBeforeClassAfterClass", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.10", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_parent_id_2}, + "test_session_id" : ${content_trace_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test", + "resource" : "org.example.TestSucceedBeforeClassAfterClass.testSucceed", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "testSucceed()V", + "test.module" : "junit-4.10", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "testSucceed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl index e86af3ff941..bdda689d8a3 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl @@ -10,11 +10,13 @@ "duration" : ${content_duration}, "error" : 0, "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, "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}, "test.type" : "test", "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.status" : "fail", @@ -44,8 +46,11 @@ "start" : ${content_start_2}, "duration" : ${content_duration_2}, "error" : 0, - "metrics" : { }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, "test.type" : "test", "test.module" : "junit-4.10", "test.status" : "fail", @@ -72,8 +77,13 @@ "start" : ${content_start_3}, "duration" : ${content_duration_3}, "error" : 1, - "metrics" : { }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, "test.type" : "test", "test.source.file" : "dummy_source_path", "test.module" : "junit-4.10", @@ -81,6 +91,7 @@ "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" : "junit", "error.type" : "java.lang.RuntimeException", @@ -92,4 +103,25 @@ "test.framework" : "junit4" } } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "suiteSetup", + "resource" : "suiteSetup", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.callback" : "BeforeClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } } ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl index d947354a795..f0c9cb24398 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl @@ -10,11 +10,13 @@ "duration" : ${content_duration}, "error" : 0, "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, "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}, "test.type" : "test", "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.status" : "fail", @@ -44,8 +46,11 @@ "start" : ${content_start_2}, "duration" : ${content_duration_2}, "error" : 0, - "metrics" : { }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, "test.type" : "test", "test.module" : "junit-4.10", "test.status" : "fail", @@ -72,8 +77,13 @@ "start" : ${content_start_3}, "duration" : ${content_duration_3}, "error" : 1, - "metrics" : { }, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, "test.type" : "test", "test.source.file" : "dummy_source_path", "test.module" : "junit-4.10", @@ -81,6 +91,7 @@ "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" : "junit", "error.type" : "java.lang.RuntimeException", @@ -112,6 +123,7 @@ "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_4}, "test.source.end" : 18, "test.source.start" : 12 }, @@ -158,6 +170,7 @@ "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_5}, "test.source.end" : 18, "test.source.start" : 12 }, @@ -184,4 +197,25 @@ "test.framework" : "junit4" } } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "suiteTearDown", + "resource" : "suiteTearDown", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.callback" : "AfterClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } } ] \ No newline at end of file From a52a40067e660f728bbba25548fdcc25bddfd77b Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Wed, 27 Nov 2024 09:14:55 +0100 Subject: [PATCH 03/10] add new instrumentation for junit4.13 --- .../junit-4.10/junit-4.13/build.gradle | 29 +++ .../junit-4.10/junit-4.13/gradle.lockfile | 228 ++++++++++++++++++ .../junit4/BeforeAfterOperationsTracer.java | 33 +++ .../JUnit4BeforeAfterInstrumentation.java | 30 +-- .../src/test/groovy/JUnit413Test.groovy | 45 ++++ .../org/example/TestSucceedBeforeAfter.java | 0 .../TestSucceedBeforeClassAfterClass.java | 0 .../src/test/groovy/JUnit4Test.groovy | 4 - .../test-succeed-before-after/coverages.ftl | 1 - .../test-succeed-before-after/events.ftl | 190 --------------- .../coverages.ftl | 1 - .../events.ftl | 192 --------------- settings.gradle | 1 + 13 files changed, 345 insertions(+), 409 deletions(-) create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/gradle.lockfile create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/BeforeAfterOperationsTracer.java rename dd-java-agent/instrumentation/junit-4.10/{ => junit-4.13}/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java (61%) create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy rename dd-java-agent/instrumentation/junit-4.10/{ => junit-4.13}/src/test/java/org/example/TestSucceedBeforeAfter.java (100%) rename dd-java-agent/instrumentation/junit-4.10/{ => junit-4.13}/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java (100%) delete mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl delete mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl delete mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl delete mode 100644 dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle new file mode 100644 index 00000000000..fd24cf77e20 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle @@ -0,0 +1,29 @@ +apply from: "$rootDir/gradle/java.gradle" + +muzzle { + pass { + group = 'junit' + module = 'junit' + versions = '[4.13,5)' + assertInverse = true + } +} + +addTestSuiteForDir('latestDepTest', 'test') + +dependencies { + implementation project(':dd-java-agent:instrumentation:junit-4.10') + compileOnly group: 'junit', name: 'junit', version: '4.13' + + testImplementation testFixtures(project(':dd-java-agent:agent-ci-visibility')) + + // version used below is not the minimum one that we support, + // but the tests need to use it in order to be compliant with Spock 2.x + testImplementation(group: 'junit', name: 'junit') { + version { + strictly '4.13.2' + } + } + + latestDepTestImplementation group: 'junit', name: 'junit', version: '4.+' +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/gradle.lockfile b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/gradle.lockfile new file mode 100644 index 00000000000..092cf2a268d --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/gradle.lockfile @@ -0,0 +1,228 @@ +# 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.1.7=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.1.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=compileClasspath,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=compileClasspath,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.13:2.1.0=zinc +org.scala-lang:scala-compiler:2.13.11=zinc +org.scala-lang:scala-library:2.13.10=testCompileClasspath,testRuntimeClasspath +org.scala-lang:scala-library:2.13.11=zinc +org.scala-lang:scala-library:2.13.14=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scala-lang:scala-library:2.13.6=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:test-interface:1.0=compileClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath +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.scalameta:junit-interface:0.7.28=compileClasspath,testCompileClasspath,testRuntimeClasspath +org.scalameta:junit-interface:1.0.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalameta:munit-diff_2.13:1.0.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +org.scalameta:munit_2.13:0.7.28=compileClasspath,testCompileClasspath,testRuntimeClasspath +org.scalameta:munit_2.13:1.0.2=latestDepTestCompileClasspath,latestDepTestRuntimeClasspath +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/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/BeforeAfterOperationsTracer.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/BeforeAfterOperationsTracer.java new file mode 100644 index 00000000000..22ebcd931d9 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/BeforeAfterOperationsTracer.java @@ -0,0 +1,33 @@ +package datadog.trace.instrumentation.junit4; + +import datadog.trace.bootstrap.instrumentation.api.AgentScope; +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; +import datadog.trace.bootstrap.instrumentation.api.AgentTracer; +import datadog.trace.bootstrap.instrumentation.api.Tags; +import java.lang.reflect.Method; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; + +public class BeforeAfterOperationsTracer { + public static AgentScope startTrace(final Method method) { + final AgentSpan span = AgentTracer.startSpan("junit", method.getName()); + if (method.isAnnotationPresent(Before.class)) { + span.setTag(Tags.TEST_CALLBACK, "Before"); + } else if (method.isAnnotationPresent(After.class)) { + span.setTag(Tags.TEST_CALLBACK, "After"); + } else if (method.isAnnotationPresent(BeforeClass.class)) { + span.setTag(Tags.TEST_CALLBACK, "BeforeClass"); + } else if (method.isAnnotationPresent(AfterClass.class)) { + span.setTag(Tags.TEST_CALLBACK, "AfterClass"); + } + return AgentTracer.activateSpan(span); + } + + public static void endTrace(final AgentScope scope) { + final AgentSpan span = scope.span(); + scope.close(); + span.finish(); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java similarity index 61% rename from dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java rename to dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java index 50cd22fb7b1..40ca8755591 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java @@ -7,14 +7,7 @@ import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.instrumentation.api.AgentScope; -import datadog.trace.bootstrap.instrumentation.api.AgentSpan; -import datadog.trace.bootstrap.instrumentation.api.AgentTracer; -import datadog.trace.bootstrap.instrumentation.api.Tags; import net.bytebuddy.asm.Advice; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.runners.model.FrameworkMethod; @AutoService(InstrumenterModule.class) @@ -33,6 +26,13 @@ public String[] knownMatchingTypes() { }; } + @Override + public String[] helperClassNames() { + return new String[] { + packageName + ".BeforeAfterOperationsTracer", + }; + } + @Override public void methodAdvice(MethodTransformer transformer) { transformer.applyAdvice( @@ -44,24 +44,12 @@ public void methodAdvice(MethodTransformer transformer) { public static class RunBeforesAftersAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static AgentScope startCallSpan(@Advice.Argument(0) final FrameworkMethod method) { - final AgentSpan span = AgentTracer.startSpan("junit", method.getMethod().getName()); - if (method.getMethod().isAnnotationPresent(Before.class)) { - span.setTag(Tags.TEST_CALLBACK, "Before"); - } else if (method.getMethod().isAnnotationPresent(After.class)) { - span.setTag(Tags.TEST_CALLBACK, "After"); - } else if (method.getMethod().isAnnotationPresent(BeforeClass.class)) { - span.setTag(Tags.TEST_CALLBACK, "BeforeClass"); - } else if (method.getMethod().isAnnotationPresent(AfterClass.class)) { - span.setTag(Tags.TEST_CALLBACK, "AfterClass"); - } - return AgentTracer.activateSpan(span); + return BeforeAfterOperationsTracer.startTrace(method.getMethod()); } @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void finishCallSpan(@Advice.Enter final AgentScope scope) { - AgentSpan span = scope.span(); - scope.close(); - span.finish(); + BeforeAfterOperationsTracer.endTrace(scope); } } } diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy new file mode 100644 index 00000000000..c659f30bcc2 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy @@ -0,0 +1,45 @@ +import datadog.trace.api.DisableTestTrace +import datadog.trace.civisibility.CiVisibilityInstrumentationTest +import datadog.trace.instrumentation.junit4.TestEventsHandlerHolder +import junit.runner.Version +import org.example.TestSucceedBeforeAfter +import org.example.TestSucceedBeforeClassAfterClass +import org.junit.runner.JUnitCore + +@DisableTestTrace(reason = "avoid self-tracing") +class JUnit413Test extends CiVisibilityInstrumentationTest { + + def runner = new JUnitCore() + + def "test #testcaseName"() { + runTests(tests) + + assertSpansData(testcaseName, expectedTracesCount) + + where: + testcaseName | tests | expectedTracesCount + "test-succeed-before-after" | [TestSucceedBeforeAfter] | 2 + "test-succeed-beforeclass-afterclass" | [TestSucceedBeforeClassAfterClass] | 2 + } + + private void runTests(Collection> tests) { + TestEventsHandlerHolder.start() + try { + Class[] array = tests.toArray(new Class[0]) + runner.run(array) + } catch (Throwable ignored) { + // Ignored + } + TestEventsHandlerHolder.stop() + } + + @Override + String instrumentedLibraryName() { + return "junit4" + } + + @Override + String instrumentedLibraryVersion() { + return Version.id() + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeAfter.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeAfter.java similarity index 100% rename from dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeAfter.java rename to dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeAfter.java diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java similarity index 100% rename from dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java rename to dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy index 729b3be2c0f..a97d82a7225 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy @@ -20,8 +20,6 @@ import org.example.TestSkipped import org.example.TestSkippedClass import org.example.TestSucceed import org.example.TestSucceedAndSkipped -import org.example.TestSucceedBeforeAfter -import org.example.TestSucceedBeforeClassAfterClass import org.example.TestSucceedExpectedException import org.example.TestSucceedKotlin import org.example.TestSucceedLegacy @@ -56,8 +54,6 @@ class JUnit4Test extends CiVisibilityInstrumentationTest { "test-success-and-failure" | [TestFailedAndSucceed] | 4 "test-suite-teardown-failure" | [TestFailedSuiteTearDown] | 1 "test-suite-setup-failure" | [TestFailedSuiteSetup] | 1 - "test-succeed-before-after" | [TestSucceedBeforeAfter] | 2 - "test-succeed-before-class-after-class" | [TestSucceedBeforeClassAfterClass] | 2 "test-assumption-failure" | [TestAssumption] | 2 "test-categories-are-included-in-spans" | [TestSucceedWithCategories] | 2 "test-assumption-failure-during-suite-setup" | [TestFailedSuiteSetUpAssumption] | 2 diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl deleted file mode 100644 index 8878e547a79..00000000000 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/coverages.ftl +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl deleted file mode 100644 index 7b96c221c64..00000000000 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-after/events.ftl +++ /dev/null @@ -1,190 +0,0 @@ -[ { - "type" : "test_session_end", - "version" : 1, - "content" : { - "test_session_id" : ${content_test_session_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "junit.test_session", - "resource" : "junit-4.10", - "start" : ${content_start}, - "duration" : ${content_duration}, - "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, - "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}, - "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" : "junit", - "_dd.profiling.ctx" : "test", - "span.kind" : "test_session_end", - "runtime-id" : ${content_meta_runtime_id}, - "test.command" : "junit-4.10", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -}, { - "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" : "junit.test_module", - "resource" : "junit-4.10", - "start" : ${content_start_2}, - "duration" : ${content_duration_2}, - "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} - }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_2}, - "test.type" : "test", - "test.module" : "junit-4.10", - "test.status" : "pass", - "test_session.name" : "session-name", - "env" : "none", - "dummy_ci_tag" : "dummy_ci_tag_value", - "library_version" : ${content_meta_library_version}, - "component" : "junit", - "span.kind" : "test_module_end", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -}, { - "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" : "junit.test_suite", - "resource" : "org.example.TestSucceedBeforeAfter", - "start" : ${content_start_3}, - "duration" : ${content_duration_3}, - "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, - "test.source.end" : 19, - "test.source.start" : 11 - }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_3}, - "test.type" : "test", - "test.source.file" : "dummy_source_path", - "test.module" : "junit-4.10", - "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" : "junit", - "span.kind" : "test_suite_end", - "test.suite" : "org.example.TestSucceedBeforeAfter", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -}, { - "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" : "junit.test", - "resource" : "org.example.TestSucceedBeforeAfter.testSucceed", - "start" : ${content_start_4}, - "duration" : ${content_duration_4}, - "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_4}, - "test.source.end" : 18, - "test.source.start" : 12 - }, - "meta" : { - "_dd.tracer_host" : ${content_meta__dd_tracer_host}, - "test.source.file" : "dummy_source_path", - "test.source.method" : "testSucceed()V", - "test.module" : "junit-4.10", - "test.status" : "pass", - "language" : "jvm", - "test.codeowners" : "[\"owner1\",\"owner2\"]", - "library_version" : ${content_meta_library_version}, - "test.name" : "testSucceed", - "span.kind" : "test", - "test.suite" : "org.example.TestSucceedBeforeAfter", - "runtime-id" : ${content_meta_runtime_id}, - "test.type" : "test", - "test_session.name" : "session-name", - "env" : "none", - "dummy_ci_tag" : "dummy_ci_tag_value", - "component" : "junit", - "_dd.profiling.ctx" : "test", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -}, { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id_2}, - "parent_id" : ${content_span_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "testSetup", - "resource" : "testSetup", - "start" : ${content_start_5}, - "duration" : ${content_duration_5}, - "error" : 0, - "metrics" : { }, - "meta" : { - "test.callback" : "Before", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } -}, { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id_3}, - "parent_id" : ${content_span_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "testTeardown", - "resource" : "testTeardown", - "start" : ${content_start_6}, - "duration" : ${content_duration_6}, - "error" : 0, - "metrics" : { }, - "meta" : { - "test.callback" : "After", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } -} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl deleted file mode 100644 index 8878e547a79..00000000000 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/coverages.ftl +++ /dev/null @@ -1 +0,0 @@ -[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl deleted file mode 100644 index c1f0556161d..00000000000 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-succeed-before-class-after-class/events.ftl +++ /dev/null @@ -1,192 +0,0 @@ -[ { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id}, - "parent_id" : ${content_parent_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "classSetup", - "resource" : "classSetup", - "start" : ${content_start}, - "duration" : ${content_duration}, - "error" : 0, - "metrics" : { }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid}, - "test.callback" : "BeforeClass", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } -}, { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id_2}, - "parent_id" : ${content_parent_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "classTeardown", - "resource" : "classTeardown", - "start" : ${content_start_2}, - "duration" : ${content_duration_2}, - "error" : 0, - "metrics" : { }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_2}, - "test.callback" : "AfterClass", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } -}, { - "type" : "test_session_end", - "version" : 1, - "content" : { - "test_session_id" : ${content_trace_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "junit.test_session", - "resource" : "junit-4.10", - "start" : ${content_start_3}, - "duration" : ${content_duration_3}, - "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, - "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_3}, - "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" : "junit", - "_dd.profiling.ctx" : "test", - "span.kind" : "test_session_end", - "runtime-id" : ${content_meta_runtime_id}, - "test.command" : "junit-4.10", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -}, { - "type" : "test_module_end", - "version" : 1, - "content" : { - "test_session_id" : ${content_trace_id}, - "test_module_id" : ${content_test_module_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "junit.test_module", - "resource" : "junit-4.10", - "start" : ${content_start_4}, - "duration" : ${content_duration_4}, - "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} - }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_4}, - "test.type" : "test", - "test.module" : "junit-4.10", - "test.status" : "pass", - "test_session.name" : "session-name", - "env" : "none", - "dummy_ci_tag" : "dummy_ci_tag_value", - "library_version" : ${content_meta_library_version}, - "component" : "junit", - "span.kind" : "test_module_end", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -}, { - "type" : "test_suite_end", - "version" : 1, - "content" : { - "test_session_id" : ${content_trace_id}, - "test_module_id" : ${content_test_module_id}, - "test_suite_id" : ${content_parent_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "junit.test_suite", - "resource" : "org.example.TestSucceedBeforeClassAfterClass", - "start" : ${content_start_5}, - "duration" : ${content_duration_5}, - "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, - "test.source.end" : 19, - "test.source.start" : 11 - }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_5}, - "test.type" : "test", - "test.source.file" : "dummy_source_path", - "test.module" : "junit-4.10", - "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" : "junit", - "span.kind" : "test_suite_end", - "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -}, { - "type" : "test", - "version" : 2, - "content" : { - "trace_id" : ${content_trace_id_2}, - "span_id" : ${content_span_id_3}, - "parent_id" : ${content_parent_id_2}, - "test_session_id" : ${content_trace_id}, - "test_module_id" : ${content_test_module_id}, - "test_suite_id" : ${content_parent_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "junit.test", - "resource" : "org.example.TestSucceedBeforeClassAfterClass.testSucceed", - "start" : ${content_start_6}, - "duration" : ${content_duration_6}, - "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_4}, - "test.source.end" : 18, - "test.source.start" : 12 - }, - "meta" : { - "_dd.tracer_host" : ${content_meta__dd_tracer_host}, - "test.source.file" : "dummy_source_path", - "test.source.method" : "testSucceed()V", - "test.module" : "junit-4.10", - "test.status" : "pass", - "language" : "jvm", - "test.codeowners" : "[\"owner1\",\"owner2\"]", - "library_version" : ${content_meta_library_version}, - "test.name" : "testSucceed", - "span.kind" : "test", - "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", - "runtime-id" : ${content_meta_runtime_id}, - "test.type" : "test", - "test_session.name" : "session-name", - "env" : "none", - "dummy_ci_tag" : "dummy_ci_tag_value", - "component" : "junit", - "_dd.profiling.ctx" : "test", - "test.framework_version" : ${content_meta_test_framework_version}, - "test.framework" : "junit4" - } - } -} ] \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 60456d9c0be..fb2bb69f846 100644 --- a/settings.gradle +++ b/settings.gradle @@ -336,6 +336,7 @@ include ':dd-java-agent:instrumentation:org-json' include ':dd-java-agent:instrumentation:jsp-2.3' include ':dd-java-agent:instrumentation:junit-4.10' include ':dd-java-agent:instrumentation:junit-4.10:cucumber-junit-4' +include ':dd-java-agent:instrumentation:junit-4.10:junit-4.13' include ':dd-java-agent:instrumentation:junit-4.10:munit-junit-4' include ':dd-java-agent:instrumentation:junit-5.3' include ':dd-java-agent:instrumentation:junit-5.3:junit-5.8' From 4b1a69e74e51c573dd6cc42249aa09f4823d4741 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Wed, 27 Nov 2024 09:17:32 +0100 Subject: [PATCH 04/10] Revert test fixture changes --- .../events.ftl | 37 +----------------- .../test-suite-setup-failure/events.ftl | 36 +----------------- .../test-suite-teardown-failure/events.ftl | 38 +------------------ 3 files changed, 6 insertions(+), 105 deletions(-) diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl index 6c8f99c1a10..748735d7f94 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl @@ -10,13 +10,11 @@ "duration" : ${content_duration}, "error" : 0, "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, "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}, "test.type" : "test", "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.status" : "skip", @@ -46,11 +44,8 @@ "start" : ${content_start_2}, "duration" : ${content_duration_2}, "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} - }, + "metrics" : { }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_2}, "test.type" : "test", "test.module" : "junit-4.10", "test.status" : "skip", @@ -77,13 +72,8 @@ "start" : ${content_start_3}, "duration" : ${content_duration_3}, "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, - "test.source.end" : 19, - "test.source.start" : 11 - }, + "metrics" : { }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_3}, "test.type" : "test", "test.source.file" : "dummy_source_path", "test.module" : "junit-4.10", @@ -92,7 +82,6 @@ "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" : "junit", "span.kind" : "test_suite_end", @@ -121,7 +110,6 @@ "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_4}, "test.source.end" : 18, "test.source.start" : 12 }, @@ -149,25 +137,4 @@ "test.framework" : "junit4" } } -}, { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_test_session_id}, - "span_id" : ${content_span_id_2}, - "parent_id" : ${content_test_suite_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "suiteSetup", - "resource" : "suiteSetup", - "start" : ${content_start_5}, - "duration" : ${content_duration_5}, - "error" : 0, - "metrics" : { }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_4}, - "test.callback" : "BeforeClass", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } } ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl index bdda689d8a3..e86af3ff941 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-setup-failure/events.ftl @@ -10,13 +10,11 @@ "duration" : ${content_duration}, "error" : 0, "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, "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}, "test.type" : "test", "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.status" : "fail", @@ -46,11 +44,8 @@ "start" : ${content_start_2}, "duration" : ${content_duration_2}, "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} - }, + "metrics" : { }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_2}, "test.type" : "test", "test.module" : "junit-4.10", "test.status" : "fail", @@ -77,13 +72,8 @@ "start" : ${content_start_3}, "duration" : ${content_duration_3}, "error" : 1, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, - "test.source.end" : 19, - "test.source.start" : 11 - }, + "metrics" : { }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_3}, "test.type" : "test", "test.source.file" : "dummy_source_path", "test.module" : "junit-4.10", @@ -91,7 +81,6 @@ "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" : "junit", "error.type" : "java.lang.RuntimeException", @@ -103,25 +92,4 @@ "test.framework" : "junit4" } } -}, { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_test_session_id}, - "span_id" : ${content_span_id}, - "parent_id" : ${content_test_suite_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "suiteSetup", - "resource" : "suiteSetup", - "start" : ${content_start_4}, - "duration" : ${content_duration_4}, - "error" : 0, - "metrics" : { }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_4}, - "test.callback" : "BeforeClass", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } } ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl index f0c9cb24398..d947354a795 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-suite-teardown-failure/events.ftl @@ -10,13 +10,11 @@ "duration" : ${content_duration}, "error" : 0, "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, "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}, "test.type" : "test", "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.status" : "fail", @@ -46,11 +44,8 @@ "start" : ${content_start_2}, "duration" : ${content_duration_2}, "error" : 0, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} - }, + "metrics" : { }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_2}, "test.type" : "test", "test.module" : "junit-4.10", "test.status" : "fail", @@ -77,13 +72,8 @@ "start" : ${content_start_3}, "duration" : ${content_duration_3}, "error" : 1, - "metrics" : { - "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, - "test.source.end" : 19, - "test.source.start" : 11 - }, + "metrics" : { }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_3}, "test.type" : "test", "test.source.file" : "dummy_source_path", "test.module" : "junit-4.10", @@ -91,7 +81,6 @@ "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" : "junit", "error.type" : "java.lang.RuntimeException", @@ -123,7 +112,6 @@ "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_4}, "test.source.end" : 18, "test.source.start" : 12 }, @@ -170,7 +158,6 @@ "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_5}, "test.source.end" : 18, "test.source.start" : 12 }, @@ -197,25 +184,4 @@ "test.framework" : "junit4" } } -}, { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_test_session_id}, - "span_id" : ${content_span_id_3}, - "parent_id" : ${content_test_suite_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "suiteTearDown", - "resource" : "suiteTearDown", - "start" : ${content_start_6}, - "duration" : ${content_duration_6}, - "error" : 0, - "metrics" : { }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_4}, - "test.callback" : "AfterClass", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } } ] \ No newline at end of file From b4f036b98e4c3981a11c28bcd6414033a5836dbc Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Wed, 27 Nov 2024 09:52:44 +0100 Subject: [PATCH 05/10] generate test fixtures for junit 4.13 instrumentation --- .../test-succeed-before-after/coverages.ftl | 1 + .../test-succeed-before-after/events.ftl | 190 +++++++++++++++++ .../coverages.ftl | 1 + .../events.ftl | 192 ++++++++++++++++++ 4 files changed, 384 insertions(+) create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/events.ftl diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl new file mode 100644 index 00000000000..36477903b6c --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl @@ -0,0 +1,190 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestSucceedBeforeAfter", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedBeforeAfter", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestSucceedBeforeAfter.testSucceed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "testSucceed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "testSucceed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeAfter", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_span_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "testSetup", + "resource" : "testSetup", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 0, + "metrics" : { }, + "meta" : { + "test.callback" : "Before", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_span_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "testTeardown", + "resource" : "testTeardown", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "test.callback" : "After", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/events.ftl new file mode 100644 index 00000000000..b1730ac98d3 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/events.ftl @@ -0,0 +1,192 @@ +[ { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "classSetup", + "resource" : "classSetup", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid}, + "test.callback" : "BeforeClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "classTeardown", + "resource" : "classTeardown", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.callback" : "AfterClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_trace_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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_3}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "test_module_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_trace_id}, + "test_module_id" : ${content_test_module_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "test_suite_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_trace_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_suite", + "resource" : "org.example.TestSucceedBeforeClassAfterClass", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "test", + "version" : 2, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_parent_id_2}, + "test_session_id" : ${content_trace_id}, + "test_module_id" : ${content_test_module_id}, + "test_suite_id" : ${content_parent_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test", + "resource" : "org.example.TestSucceedBeforeClassAfterClass.testSucceed", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "testSucceed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "testSucceed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +} ] \ No newline at end of file From 5497d99e3438e14ee91a6b749c590e99b78d7c22 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Wed, 27 Nov 2024 13:45:35 +0100 Subject: [PATCH 06/10] junit4.13 muzzle check --- .../JUnit4BeforeAfterInstrumentation.java | 17 ++++++++++++++--- ...a => JUnit4BeforeAfterOperationsTracer.java} | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) rename dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/{BeforeAfterOperationsTracer.java => JUnit4BeforeAfterOperationsTracer.java} (96%) diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java index 40ca8755591..5c25d849fa0 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java @@ -8,6 +8,8 @@ import datadog.trace.agent.tooling.InstrumenterModule; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import net.bytebuddy.asm.Advice; +import org.junit.runner.manipulation.InvalidOrderingException; +import org.junit.runner.manipulation.Ordering; import org.junit.runners.model.FrameworkMethod; @AutoService(InstrumenterModule.class) @@ -29,7 +31,7 @@ public String[] knownMatchingTypes() { @Override public String[] helperClassNames() { return new String[] { - packageName + ".BeforeAfterOperationsTracer", + packageName + ".JUnit4BeforeAfterOperationsTracer", }; } @@ -44,12 +46,21 @@ public void methodAdvice(MethodTransformer transformer) { public static class RunBeforesAftersAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) public static AgentScope startCallSpan(@Advice.Argument(0) final FrameworkMethod method) { - return BeforeAfterOperationsTracer.startTrace(method.getMethod()); + return JUnit4BeforeAfterOperationsTracer.startTrace(method.getMethod()); } @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) public static void finishCallSpan(@Advice.Enter final AgentScope scope) { - BeforeAfterOperationsTracer.endTrace(scope); + JUnit4BeforeAfterOperationsTracer.endTrace(scope); + } + + // JUnit 4.13 and above + public static void muzzleCheck(final Ordering ord) { + try { + ord.apply(null); + } catch (InvalidOrderingException e) { + throw new RuntimeException(e); + } } } } diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/BeforeAfterOperationsTracer.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java similarity index 96% rename from dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/BeforeAfterOperationsTracer.java rename to dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java index 22ebcd931d9..2a71cfbf985 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/BeforeAfterOperationsTracer.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java @@ -10,7 +10,7 @@ import org.junit.Before; import org.junit.BeforeClass; -public class BeforeAfterOperationsTracer { +public class JUnit4BeforeAfterOperationsTracer { public static AgentScope startTrace(final Method method) { final AgentSpan span = AgentTracer.startSpan("junit", method.getName()); if (method.isAnnotationPresent(Before.class)) { From e8ae39268b2ef986a3f846c6170c169227653a57 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Thu, 28 Nov 2024 11:21:04 +0100 Subject: [PATCH 07/10] remove inverse muzzle assert --- dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle index fd24cf77e20..0de58ffa9c0 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/build.gradle @@ -5,7 +5,6 @@ muzzle { group = 'junit' module = 'junit' versions = '[4.13,5)' - assertInverse = true } } From 0df9f72dc9703e797832607b3d4e914e395ebfb6 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Thu, 28 Nov 2024 13:44:48 +0100 Subject: [PATCH 08/10] additional tests for failing setup and teardown --- .../JUnit4BeforeAfterInstrumentation.java | 5 +- .../JUnit4BeforeAfterOperationsTracer.java | 5 +- .../src/test/groovy/JUnit413Test.groovy | 14 +- .../java/org/example/TestFailedAfter.java | 23 ++ .../org/example/TestFailedAfterClass.java | 23 ++ .../java/org/example/TestFailedBefore.java | 23 ++ .../org/example/TestFailedBeforeClass.java | 23 ++ .../org/example/TestSucceedBeforeAfter.java | 11 +- .../TestSucceedBeforeClassAfterClass.java | 11 +- .../coverages.ftl | 0 .../test-failed-after-class/events.ftl | 224 ++++++++++++++++ .../resources/test-failed-after/coverages.ftl | 1 + .../resources/test-failed-after/events.ftl | 249 ++++++++++++++++++ .../test-failed-before-class/coverages.ftl | 1 + .../test-failed-before-class/events.ftl | 130 +++++++++ .../test-failed-before/coverages.ftl | 1 + .../resources/test-failed-before/events.ftl | 249 ++++++++++++++++++ .../test-succeed-before-after/events.ftl | 113 +++++++- .../coverages.ftl | 1 + .../events.ftl | 177 ++++++++----- 20 files changed, 1194 insertions(+), 90 deletions(-) create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfter.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterClass.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBefore.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeClass.java rename dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/{test-succeed-beforeclass-afterclass => test-failed-after-class}/coverages.ftl (100%) create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-class/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-class-after-class/coverages.ftl rename dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/{test-succeed-beforeclass-afterclass => test-succeed-before-class-after-class}/events.ftl (71%) diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java index 5c25d849fa0..d1be2b3ab46 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java @@ -50,8 +50,9 @@ public static AgentScope startCallSpan(@Advice.Argument(0) final FrameworkMethod } @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void finishCallSpan(@Advice.Enter final AgentScope scope) { - JUnit4BeforeAfterOperationsTracer.endTrace(scope); + public static void finishCallSpan( + @Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) { + JUnit4BeforeAfterOperationsTracer.endTrace(scope, throwable); } // JUnit 4.13 and above diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java index 2a71cfbf985..56df16cd86c 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java @@ -25,8 +25,11 @@ public static AgentScope startTrace(final Method method) { return AgentTracer.activateSpan(span); } - public static void endTrace(final AgentScope scope) { + public static void endTrace(final AgentScope scope, final Throwable throwable) { final AgentSpan span = scope.span(); + if (throwable != null) { + span.addThrowable(throwable); + } scope.close(); span.finish(); } diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy index c659f30bcc2..d621d4b7ac3 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy @@ -2,6 +2,10 @@ import datadog.trace.api.DisableTestTrace import datadog.trace.civisibility.CiVisibilityInstrumentationTest import datadog.trace.instrumentation.junit4.TestEventsHandlerHolder import junit.runner.Version +import org.example.TestFailedAfter +import org.example.TestFailedAfterClass +import org.example.TestFailedBefore +import org.example.TestFailedBeforeClass import org.example.TestSucceedBeforeAfter import org.example.TestSucceedBeforeClassAfterClass import org.junit.runner.JUnitCore @@ -17,9 +21,13 @@ class JUnit413Test extends CiVisibilityInstrumentationTest { assertSpansData(testcaseName, expectedTracesCount) where: - testcaseName | tests | expectedTracesCount - "test-succeed-before-after" | [TestSucceedBeforeAfter] | 2 - "test-succeed-beforeclass-afterclass" | [TestSucceedBeforeClassAfterClass] | 2 + testcaseName | tests | expectedTracesCount + "test-succeed-before-after" | [TestSucceedBeforeAfter] | 3 + "test-succeed-before-class-after-class" | [TestSucceedBeforeClassAfterClass] | 3 + "test-failed-before-class" | [TestFailedBeforeClass] | 1 + "test-failed-after-class" | [TestFailedAfterClass] | 3 + "test-failed-before" | [TestFailedBefore] | 3 + "test-failed-after" | [TestFailedAfter] | 3 } private void runTests(Collection> tests) { diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfter.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfter.java new file mode 100644 index 00000000000..7581a79c5ca --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfter.java @@ -0,0 +1,23 @@ +package org.example; + +import static org.junit.Assert.assertTrue; + +import org.junit.After; +import org.junit.Test; + +public class TestFailedAfter { + @After + public void tearDown() { + throw new RuntimeException("testcase teardown failed"); + } + + @Test + public void test_succeed() { + assertTrue(true); + } + + @Test + public void another_test_succeed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterClass.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterClass.java new file mode 100644 index 00000000000..24470257301 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterClass.java @@ -0,0 +1,23 @@ +package org.example; + +import static org.junit.Assert.assertTrue; + +import org.junit.AfterClass; +import org.junit.Test; + +public class TestFailedAfterClass { + @AfterClass + public static void tearDown() { + throw new RuntimeException("suite teardown failed"); + } + + @Test + public void test_succeed() { + assertTrue(true); + } + + @Test + public void another_test_succeed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBefore.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBefore.java new file mode 100644 index 00000000000..bca82898209 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBefore.java @@ -0,0 +1,23 @@ +package org.example; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +public class TestFailedBefore { + @Before + public void setup() { + throw new RuntimeException("testcase setup failed"); + } + + @Test + public void test_succeed() { + assertTrue(true); + } + + @Test + public void another_test_succeed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeClass.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeClass.java new file mode 100644 index 00000000000..a7b0c38b059 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeClass.java @@ -0,0 +1,23 @@ +package org.example; + +import static org.junit.Assert.assertTrue; + +import org.junit.BeforeClass; +import org.junit.Test; + +public class TestFailedBeforeClass { + @BeforeClass + public static void setup() { + throw new RuntimeException("suite setup failed"); + } + + @Test + public void test_succeed() { + assertTrue(true); + } + + @Test + public void another_test_succeed() { + assertTrue(true); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeAfter.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeAfter.java index 24c44c7b7bb..347c4ce185c 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeAfter.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeAfter.java @@ -8,13 +8,18 @@ public class TestSucceedBeforeAfter { @Before - public void testSetup() {} + public void setup() {} @After - public void testTeardown() {} + public void tearDown() {} @Test - public void testSucceed() { + public void test_succeed() { + assertTrue(true); + } + + @Test + public void another_test_succeed() { assertTrue(true); } } diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java index 93b931312ab..6c39c071486 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeClassAfterClass.java @@ -8,13 +8,18 @@ public class TestSucceedBeforeClassAfterClass { @BeforeClass - public static void classSetup() {} + public static void setup() {} @AfterClass - public static void classTeardown() {} + public static void tearDown() {} @Test - public void testSucceed() { + public void test_succeed() { + assertTrue(true); + } + + @Test + public void another_test_succeed() { assertTrue(true); } } diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-class/coverages.ftl similarity index 100% rename from dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/coverages.ftl rename to dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-class/coverages.ftl diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-class/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-class/events.ftl new file mode 100644 index 00000000000..25474df8081 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-class/events.ftl @@ -0,0 +1,224 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestFailedAfterClass", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 1, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "error.type" : "java.lang.RuntimeException", + "span.kind" : "test_suite_end", + "error.message" : ${content_meta_error_message}, + "test.suite" : "org.example.TestFailedAfterClass", + "error.stack" : ${content_meta_error_stack}, + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedAfterClass.another_test_succeed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "another_test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "another_test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedAfterClass", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedAfterClass.test_succeed", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "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_5}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedAfterClass", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 1, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "error.stack" : ${content_meta_error_stack_2}, + "test.callback" : "AfterClass", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/events.ftl new file mode 100644 index 00000000000..bf98663d9e0 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after/events.ftl @@ -0,0 +1,249 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestFailedAfter", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestFailedAfter", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedAfter.another_test_succeed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "another_test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "fail", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "another_test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedAfter", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "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" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedAfter.test_succeed", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "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_5}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "fail", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedAfter", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "error.type" : "java.lang.RuntimeException", + "_dd.profiling.ctx" : "test", + "error.message" : ${content_meta_error_message}, + "error.stack" : ${content_meta_error_stack_2}, + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_span_id_2}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 1, + "metrics" : { }, + "meta" : { + "error.stack" : ${content_meta_error_stack_3}, + "test.callback" : "After", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_4}, + "parent_id" : ${content_span_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, + "error" : 1, + "metrics" : { }, + "meta" : { + "error.stack" : ${content_meta_error_stack_4}, + "test.callback" : "After", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/events.ftl new file mode 100644 index 00000000000..ee89aa70ba7 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-class/events.ftl @@ -0,0 +1,130 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestFailedBeforeClass", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 1, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "error.type" : "java.lang.RuntimeException", + "span.kind" : "test_suite_end", + "error.message" : ${content_meta_error_message}, + "test.suite" : "org.example.TestFailedBeforeClass", + "error.stack" : ${content_meta_error_stack}, + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 1, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "error.stack" : ${content_meta_error_stack_2}, + "test.callback" : "BeforeClass", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/events.ftl new file mode 100644 index 00000000000..8ffd3be0f0e --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before/events.ftl @@ -0,0 +1,249 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "fail", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestFailedBefore", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestFailedBefore", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedBefore.another_test_succeed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "another_test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "fail", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "another_test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedBefore", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "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" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedBefore.test_succeed", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "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_5}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "fail", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedBefore", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "error.type" : "java.lang.RuntimeException", + "_dd.profiling.ctx" : "test", + "error.message" : ${content_meta_error_message}, + "error.stack" : ${content_meta_error_stack_2}, + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_span_id_2}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 1, + "metrics" : { }, + "meta" : { + "error.stack" : ${content_meta_error_stack_3}, + "test.callback" : "Before", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id}, + "span_id" : ${content_span_id_4}, + "parent_id" : ${content_span_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, + "error" : 1, + "metrics" : { }, + "meta" : { + "error.stack" : ${content_meta_error_stack_4}, + "test.callback" : "Before", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl index 36477903b6c..4d08b025bb8 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-after/events.ftl @@ -112,7 +112,7 @@ "test_suite_id" : ${content_test_suite_id}, "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", "name" : "junit.test", - "resource" : "org.example.TestSucceedBeforeAfter.testSucceed", + "resource" : "org.example.TestSucceedBeforeAfter.another_test_succeed", "start" : ${content_start_4}, "duration" : ${content_duration_4}, "error" : 0, @@ -127,13 +127,13 @@ "meta" : { "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.source.file" : "dummy_source_path", - "test.source.method" : "testSucceed()V", + "test.source.method" : "another_test_succeed()V", "test.module" : "junit-4.13", "test.status" : "pass", "language" : "jvm", "test.codeowners" : "[\"owner1\",\"owner2\"]", "library_version" : ${content_meta_library_version}, - "test.name" : "testSucceed", + "test.name" : "another_test_succeed", "span.kind" : "test", "test.suite" : "org.example.TestSucceedBeforeAfter", "runtime-id" : ${content_meta_runtime_id}, @@ -147,18 +147,85 @@ "test.framework" : "junit4" } } +}, { + "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" : "junit.test", + "resource" : "org.example.TestSucceedBeforeAfter.test_succeed", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "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_5}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeAfter", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_span_id_2}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "test.callback" : "Before", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } }, { "type" : "span", "version" : 1, "content" : { "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id_2}, + "span_id" : ${content_span_id_4}, "parent_id" : ${content_span_id}, "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "testSetup", - "resource" : "testSetup", - "start" : ${content_start_5}, - "duration" : ${content_duration_5}, + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, "error" : 0, "metrics" : { }, "meta" : { @@ -167,18 +234,38 @@ "env" : "none" } } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_trace_id_2}, + "span_id" : ${content_span_id_5}, + "parent_id" : ${content_span_id_2}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_8}, + "duration" : ${content_duration_8}, + "error" : 0, + "metrics" : { }, + "meta" : { + "test.callback" : "After", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } }, { "type" : "span", "version" : 1, "content" : { "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id_3}, + "span_id" : ${content_span_id_6}, "parent_id" : ${content_span_id}, "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "testTeardown", - "resource" : "testTeardown", - "start" : ${content_start_6}, - "duration" : ${content_duration_6}, + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_9}, + "duration" : ${content_duration_9}, "error" : 0, "metrics" : { }, "meta" : { diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-class-after-class/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-class-after-class/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-class-after-class/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-class-after-class/events.ftl similarity index 71% rename from dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/events.ftl rename to dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-class-after-class/events.ftl index b1730ac98d3..03682ac982c 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-beforeclass-afterclass/events.ftl +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-class-after-class/events.ftl @@ -1,55 +1,13 @@ [ { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id}, - "parent_id" : ${content_parent_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "classSetup", - "resource" : "classSetup", - "start" : ${content_start}, - "duration" : ${content_duration}, - "error" : 0, - "metrics" : { }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid}, - "test.callback" : "BeforeClass", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } -}, { - "type" : "span", - "version" : 1, - "content" : { - "trace_id" : ${content_trace_id}, - "span_id" : ${content_span_id_2}, - "parent_id" : ${content_parent_id}, - "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", - "name" : "classTeardown", - "resource" : "classTeardown", - "start" : ${content_start_2}, - "duration" : ${content_duration_2}, - "error" : 0, - "metrics" : { }, - "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_2}, - "test.callback" : "AfterClass", - "library_version" : ${content_meta_library_version}, - "env" : "none" - } - } -}, { "type" : "test_session_end", "version" : 1, "content" : { - "test_session_id" : ${content_trace_id}, + "test_session_id" : ${content_test_session_id}, "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", "name" : "junit.test_session", "resource" : "junit-4.13", - "start" : ${content_start_3}, - "duration" : ${content_duration_3}, + "start" : ${content_start}, + "duration" : ${content_duration}, "error" : 0, "metrics" : { "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, @@ -58,7 +16,7 @@ "_dd.trace_span_attribute_schema" : 0 }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "_dd.p.tid" : ${content_meta__dd_p_tid}, "test.type" : "test", "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.status" : "pass", @@ -80,19 +38,19 @@ "type" : "test_module_end", "version" : 1, "content" : { - "test_session_id" : ${content_trace_id}, + "test_session_id" : ${content_test_session_id}, "test_module_id" : ${content_test_module_id}, "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", "name" : "junit.test_module", "resource" : "junit-4.13", - "start" : ${content_start_4}, - "duration" : ${content_duration_4}, + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, "error" : 0, "metrics" : { "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, "test.type" : "test", "test.module" : "junit-4.13", "test.status" : "pass", @@ -110,14 +68,14 @@ "type" : "test_suite_end", "version" : 1, "content" : { - "test_session_id" : ${content_trace_id}, + "test_session_id" : ${content_test_session_id}, "test_module_id" : ${content_test_module_id}, - "test_suite_id" : ${content_parent_id}, + "test_suite_id" : ${content_test_suite_id}, "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", "name" : "junit.test_suite", "resource" : "org.example.TestSucceedBeforeClassAfterClass", - "start" : ${content_start_5}, - "duration" : ${content_duration_5}, + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, "error" : 0, "metrics" : { "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, @@ -125,7 +83,7 @@ "test.source.start" : 11 }, "meta" : { - "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, "test.type" : "test", "test.source.file" : "dummy_source_path", "test.module" : "junit-4.13", @@ -146,17 +104,17 @@ "type" : "test", "version" : 2, "content" : { - "trace_id" : ${content_trace_id_2}, - "span_id" : ${content_span_id_3}, - "parent_id" : ${content_parent_id_2}, - "test_session_id" : ${content_trace_id}, + "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_parent_id}, + "test_suite_id" : ${content_test_suite_id}, "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", "name" : "junit.test", - "resource" : "org.example.TestSucceedBeforeClassAfterClass.testSucceed", - "start" : ${content_start_6}, - "duration" : ${content_duration_6}, + "resource" : "org.example.TestSucceedBeforeClassAfterClass.another_test_succeed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, "error" : 0, "metrics" : { "process_id" : ${content_metrics_process_id}, @@ -169,13 +127,13 @@ "meta" : { "_dd.tracer_host" : ${content_meta__dd_tracer_host}, "test.source.file" : "dummy_source_path", - "test.source.method" : "testSucceed()V", + "test.source.method" : "another_test_succeed()V", "test.module" : "junit-4.13", "test.status" : "pass", "language" : "jvm", "test.codeowners" : "[\"owner1\",\"owner2\"]", "library_version" : ${content_meta_library_version}, - "test.name" : "testSucceed", + "test.name" : "another_test_succeed", "span.kind" : "test", "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", "runtime-id" : ${content_meta_runtime_id}, @@ -189,4 +147,93 @@ "test.framework" : "junit4" } } +}, { + "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" : "junit.test", + "resource" : "org.example.TestSucceedBeforeClassAfterClass.test_succeed", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "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_5}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeClassAfterClass", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.callback" : "BeforeClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_4}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "test.callback" : "AfterClass", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } } ] \ No newline at end of file From 500430071671d613154c9097417c71db673d030b Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Thu, 28 Nov 2024 15:37:55 +0100 Subject: [PATCH 09/10] add junit 4.13 instrumentation to instrumentation testing config --- gradle/configure_tests.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle/configure_tests.gradle b/gradle/configure_tests.gradle index a06eeaf4ddb..79efc51c7e5 100644 --- a/gradle/configure_tests.gradle +++ b/gradle/configure_tests.gradle @@ -5,6 +5,7 @@ def isTestingInstrumentation(Project project) { return [ "junit-4.10", "cucumber-junit-4", + "junit-4.13", "munit-junit-4", "junit-5.3", "junit-5.8", From 948fe8ac303c9e96e03402a394e6618f69120cc7 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Fri, 29 Nov 2024 12:32:33 +0100 Subject: [PATCH 10/10] add support for BeforeParam and AfterParam --- .../JUnit4BeforeAfterInstrumentation.java | 4 +- .../JUnit4BeforeAfterOperationsTracer.java | 5 + .../src/test/groovy/JUnit413Test.groovy | 6 + .../org/example/TestFailedAfterParam.java | 40 +++ .../org/example/TestFailedBeforeParam.java | 40 +++ .../TestSucceedBeforeParamAfterParam.java | 38 +++ .../test-failed-after-param/coverages.ftl | 1 + .../test-failed-after-param/events.ftl | 289 ++++++++++++++++++ .../test-failed-before-param/coverages.ftl | 1 + .../test-failed-before-param/events.ftl | 193 ++++++++++++ .../coverages.ftl | 1 + .../events.ftl | 283 +++++++++++++++++ 12 files changed, 900 insertions(+), 1 deletion(-) create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterParam.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeParam.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeParamAfterParam.java create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/events.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/coverages.ftl create mode 100644 dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/events.ftl diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java index d1be2b3ab46..64fa95ca93c 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java @@ -24,7 +24,9 @@ public JUnit4BeforeAfterInstrumentation() { public String[] knownMatchingTypes() { return new String[] { "org.junit.internal.runners.statements.RunBefores", - "org.junit.internal.runners.statements.RunAfters" + "org.junit.internal.runners.statements.RunAfters", + "org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters$RunBeforeParams", + "org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters$RunAfterParams", }; } diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java index 56df16cd86c..1e41f817349 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterOperationsTracer.java @@ -9,6 +9,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.runners.Parameterized; public class JUnit4BeforeAfterOperationsTracer { public static AgentScope startTrace(final Method method) { @@ -21,6 +22,10 @@ public static AgentScope startTrace(final Method method) { span.setTag(Tags.TEST_CALLBACK, "BeforeClass"); } else if (method.isAnnotationPresent(AfterClass.class)) { span.setTag(Tags.TEST_CALLBACK, "AfterClass"); + } else if (method.isAnnotationPresent(Parameterized.BeforeParam.class)) { + span.setTag(Tags.TEST_CALLBACK, "BeforeParam"); + } else if (method.isAnnotationPresent(Parameterized.AfterParam.class)) { + span.setTag(Tags.TEST_CALLBACK, "AfterParam"); } return AgentTracer.activateSpan(span); } diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy index d621d4b7ac3..a31d757f760 100644 --- a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/groovy/JUnit413Test.groovy @@ -4,10 +4,13 @@ import datadog.trace.instrumentation.junit4.TestEventsHandlerHolder import junit.runner.Version import org.example.TestFailedAfter import org.example.TestFailedAfterClass +import org.example.TestFailedAfterParam import org.example.TestFailedBefore import org.example.TestFailedBeforeClass +import org.example.TestFailedBeforeParam import org.example.TestSucceedBeforeAfter import org.example.TestSucceedBeforeClassAfterClass +import org.example.TestSucceedBeforeParamAfterParam import org.junit.runner.JUnitCore @DisableTestTrace(reason = "avoid self-tracing") @@ -24,10 +27,13 @@ class JUnit413Test extends CiVisibilityInstrumentationTest { testcaseName | tests | expectedTracesCount "test-succeed-before-after" | [TestSucceedBeforeAfter] | 3 "test-succeed-before-class-after-class" | [TestSucceedBeforeClassAfterClass] | 3 + "test-succeed-before-param-after-param" | [TestSucceedBeforeParamAfterParam] | 2 "test-failed-before-class" | [TestFailedBeforeClass] | 1 "test-failed-after-class" | [TestFailedAfterClass] | 3 "test-failed-before" | [TestFailedBefore] | 3 "test-failed-after" | [TestFailedAfter] | 3 + "test-failed-before-param" | [TestFailedBeforeParam] | 2 + "test-failed-after-param" | [TestFailedAfterParam] | 2 } private void runTests(Collection> tests) { diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterParam.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterParam.java new file mode 100644 index 00000000000..6faee23ed5d --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedAfterParam.java @@ -0,0 +1,40 @@ +package org.example; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class TestFailedAfterParam { + private final int num1; + private final int num2; + private final int sum; + + public TestFailedAfterParam(final int num1, final int num2, final int sum) { + this.num1 = num1; + this.num2 = num2; + this.sum = sum; + } + + @Parameterized.BeforeParam + public static void setup() {} + + @Parameterized.AfterParam + public static void tearDown() { + throw new RuntimeException("after param setup failed"); + } + + @Parameterized.Parameters + public static Collection data() { + return Arrays.asList(new Object[][] {{0, 0, 0}, {1, 1, 2}}); + } + + @Test + public void parameterized_test_succeed() { + assertEquals(num1 + num2, sum); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeParam.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeParam.java new file mode 100644 index 00000000000..77f5b1a682b --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestFailedBeforeParam.java @@ -0,0 +1,40 @@ +package org.example; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class TestFailedBeforeParam { + private final int num1; + private final int num2; + private final int sum; + + public TestFailedBeforeParam(final int num1, final int num2, final int sum) { + this.num1 = num1; + this.num2 = num2; + this.sum = sum; + } + + @Parameterized.BeforeParam + public static void setup() { + throw new RuntimeException("before param setup failed"); + } + + @Parameterized.AfterParam + public static void tearDown() {} + + @Parameterized.Parameters + public static Collection data() { + return Arrays.asList(new Object[][] {{0, 0, 0}, {1, 1, 2}}); + } + + @Test + public void parameterized_test_succeed() { + assertEquals(num1 + num2, sum); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeParamAfterParam.java b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeParamAfterParam.java new file mode 100644 index 00000000000..a5ffd17a693 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/java/org/example/TestSucceedBeforeParamAfterParam.java @@ -0,0 +1,38 @@ +package org.example; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class TestSucceedBeforeParamAfterParam { + private final int num1; + private final int num2; + private final int sum; + + public TestSucceedBeforeParamAfterParam(final int num1, final int num2, final int sum) { + this.num1 = num1; + this.num2 = num2; + this.sum = sum; + } + + @Parameterized.BeforeParam + public static void setup() {} + + @Parameterized.AfterParam + public static void tearDown() {} + + @Parameterized.Parameters + public static Collection data() { + return Arrays.asList(new Object[][] {{0, 0, 0}, {1, 1, 2}}); + } + + @Test + public void parameterized_test_succeed() { + assertEquals(num1 + num2, sum); + } +} diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/events.ftl new file mode 100644 index 00000000000..33a0c175bfd --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-after-param/events.ftl @@ -0,0 +1,289 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestFailedAfterParam", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestFailedAfterParam", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedAfterParam.parameterized_test_succeed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "parameterized_test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "parameterized_test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedAfterParam", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.parameters" : "{\"metadata\":{\"test_name\":\"parameterized_test_succeed[0]\"}}", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestFailedAfterParam.parameterized_test_succeed", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "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_5}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "parameterized_test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "parameterized_test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestFailedAfterParam", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.parameters" : "{\"metadata\":{\"test_name\":\"parameterized_test_succeed[1]\"}}", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.callback" : "BeforeParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_4}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "test.callback" : "BeforeParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_5}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_8}, + "duration" : ${content_duration_8}, + "error" : 1, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_6}, + "error.stack" : ${content_meta_error_stack}, + "test.callback" : "AfterParam", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_6}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_9}, + "duration" : ${content_duration_9}, + "error" : 1, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_7}, + "error.stack" : ${content_meta_error_stack_2}, + "test.callback" : "AfterParam", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/events.ftl new file mode 100644 index 00000000000..2399e8b5b57 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-failed-before-param/events.ftl @@ -0,0 +1,193 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "skip", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestFailedBeforeParam", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestFailedBeforeParam", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "error" : 1, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "error.stack" : ${content_meta_error_stack}, + "test.callback" : "BeforeParam", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_2}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "error" : 1, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "error.stack" : ${content_meta_error_stack_2}, + "test.callback" : "BeforeParam", + "library_version" : ${content_meta_library_version}, + "error.type" : "java.lang.RuntimeException", + "env" : "none", + "error.message" : ${content_meta_error_message} + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_6}, + "test.callback" : "AfterParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_4}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_7}, + "test.callback" : "AfterParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +} ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/coverages.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/coverages.ftl new file mode 100644 index 00000000000..8878e547a79 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/coverages.ftl @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/events.ftl b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/events.ftl new file mode 100644 index 00000000000..d74bcbb5294 --- /dev/null +++ b/dd-java-agent/instrumentation/junit-4.10/junit-4.13/src/test/resources/test-succeed-before-param-after-param/events.ftl @@ -0,0 +1,283 @@ +[ { + "type" : "test_session_end", + "version" : 1, + "content" : { + "test_session_id" : ${content_test_session_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "junit.test_session", + "resource" : "junit-4.13", + "start" : ${content_start}, + "duration" : ${content_duration}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}, + "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}, + "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" : "junit", + "_dd.profiling.ctx" : "test", + "span.kind" : "test_session_end", + "runtime-id" : ${content_meta_runtime_id}, + "test.command" : "junit-4.13", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_module", + "resource" : "junit-4.13", + "start" : ${content_start_2}, + "duration" : ${content_duration_2}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2} + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_2}, + "test.type" : "test", + "test.module" : "junit-4.13", + "test.status" : "pass", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "library_version" : ${content_meta_library_version}, + "component" : "junit", + "span.kind" : "test_module_end", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test_suite", + "resource" : "org.example.TestSucceedBeforeParamAfterParam", + "start" : ${content_start_3}, + "duration" : ${content_duration_3}, + "error" : 0, + "metrics" : { + "_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3}, + "test.source.end" : 19, + "test.source.start" : 11 + }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_3}, + "test.type" : "test", + "test.source.file" : "dummy_source_path", + "test.module" : "junit-4.13", + "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" : "junit", + "span.kind" : "test_suite_end", + "test.suite" : "org.example.TestSucceedBeforeParamAfterParam", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestSucceedBeforeParamAfterParam.parameterized_test_succeed", + "start" : ${content_start_4}, + "duration" : ${content_duration_4}, + "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_4}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "parameterized_test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "parameterized_test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeParamAfterParam", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.parameters" : "{\"metadata\":{\"test_name\":\"parameterized_test_succeed[0]\"}}", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "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" : "junit.test", + "resource" : "org.example.TestSucceedBeforeParamAfterParam.parameterized_test_succeed", + "start" : ${content_start_5}, + "duration" : ${content_duration_5}, + "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_5}, + "test.source.end" : 18, + "test.source.start" : 12 + }, + "meta" : { + "_dd.tracer_host" : ${content_meta__dd_tracer_host}, + "test.source.file" : "dummy_source_path", + "test.source.method" : "parameterized_test_succeed()V", + "test.module" : "junit-4.13", + "test.status" : "pass", + "language" : "jvm", + "test.codeowners" : "[\"owner1\",\"owner2\"]", + "library_version" : ${content_meta_library_version}, + "test.name" : "parameterized_test_succeed", + "span.kind" : "test", + "test.suite" : "org.example.TestSucceedBeforeParamAfterParam", + "runtime-id" : ${content_meta_runtime_id}, + "test.type" : "test", + "test_session.name" : "session-name", + "env" : "none", + "dummy_ci_tag" : "dummy_ci_tag_value", + "test.parameters" : "{\"metadata\":{\"test_name\":\"parameterized_test_succeed[1]\"}}", + "component" : "junit", + "_dd.profiling.ctx" : "test", + "test.framework_version" : ${content_meta_test_framework_version}, + "test.framework" : "junit4" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_3}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_6}, + "duration" : ${content_duration_6}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_4}, + "test.callback" : "BeforeParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_4}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "setup", + "resource" : "setup", + "start" : ${content_start_7}, + "duration" : ${content_duration_7}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_5}, + "test.callback" : "BeforeParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_5}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_8}, + "duration" : ${content_duration_8}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_6}, + "test.callback" : "AfterParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +}, { + "type" : "span", + "version" : 1, + "content" : { + "trace_id" : ${content_test_session_id}, + "span_id" : ${content_span_id_6}, + "parent_id" : ${content_test_suite_id}, + "service" : "worker.org.gradle.process.internal.worker.gradleworkermain", + "name" : "tearDown", + "resource" : "tearDown", + "start" : ${content_start_9}, + "duration" : ${content_duration_9}, + "error" : 0, + "metrics" : { }, + "meta" : { + "_dd.p.tid" : ${content_meta__dd_p_tid_7}, + "test.callback" : "AfterParam", + "library_version" : ${content_meta_library_version}, + "env" : "none" + } + } +} ] \ No newline at end of file