change module and file names to match version of earliest supported version of spring-context
MODIFY
dd-java-agent/instrumentation/spring-data-1.8/src/main/java/datadog/trace/instrumentation/springdata/SpringRepositoryInstrumentation.java
dd-java-agent/instrumentation/spring-data-1.8/src/main/java/datadog/trace/instrumentation/springdata/SpringRepositoryInstrumentation.java
package datadog.trace.instrumentation.springdata;
+import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
+import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
+import static datadog.trace.instrumentation.springdata.SpringDataDecorator.DECORATOR;
+import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
+import static net.bytebuddy.matcher.ElementMatchers.isInterface;
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.not;
+
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.instrumentation.api.AgentScope;
import datadog.trace.instrumentation.api.AgentSpan;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Map;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -18,18 +29,6 @@ import org.springframework.data.repository.core.RepositoryInformation;
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
import org.springframework.data.repository.core.support.RepositoryProxyPostProcessor;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.Map;
-
-import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
-import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
-import static datadog.trace.instrumentation.springdata.SpringDataDecorator.DECORATOR;
-import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
-import static net.bytebuddy.matcher.ElementMatchers.isInterface;
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import static net.bytebuddy.matcher.ElementMatchers.not;
-
@AutoService(Instrumenter.class)
public final class SpringRepositoryInstrumentation extends Instrumenter.Default {

DELETE
dd-java-agent/instrumentation/spring-scheduling-1/spring-scheduling-1.gradle
-muzzle {
- pass {
- group = 'org.springframework'
- module = 'spring-context'
- versions = "[5.2.3.RELEASE,]"
- assertInverse = true
- }
-}
-
-apply from: "${rootDir}/gradle/java.gradle"
-dependencies {
- compileOnly group: 'org.springframework', name: 'spring-context', version: '5.2.3.RELEASE'
- testCompile group: 'org.springframework', name: 'spring-context', version: '5.2.3.RELEASE'
- testCompile project(':dd-java-agent:instrumentation:trace-annotation')
-}

DELETE
dd-java-agent/instrumentation/spring-scheduling-1/src/test/java/IntervalTask.java
-/*
- * Copyright 2012-2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-@Component
-public class IntervalTask implements Runnable {
-
- private final CountDownLatch latch = new CountDownLatch(1);
-
- @Scheduled(initialDelay = 2, fixedRate = 5000)
- @Override
- public void run() {
- latch.countDown();
- }
-
- public void blockUntilExecute() throws InterruptedException {
- latch.await(5, TimeUnit.SECONDS);
- }
-}

DELETE
dd-java-agent/instrumentation/spring-scheduling-1/src/test/java/TriggerTask.java
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/*
- * Copyright 2012-2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// import datadog.trace.api.DDTags;
-// import datadog.trace.instrumentation.api.AgentScope;
-// import datadog.trace.instrumentation.api.AgentSpan;
-
-@Component
-public class TriggerTask implements Runnable {
-
- public TriggerTask() {
- System.out.println("in the ScheduledTasks constructor");
- }
-
- private final CountDownLatch latch = new CountDownLatch(1);
-
- @Scheduled(cron = "0/5 * * * * *")
- @Override
- public void run() {
- latch.countDown();
- }
-
- public void blockUntilExecute() throws InterruptedException {
- latch.await(5, TimeUnit.SECONDS);
- }
-}

ADD
dd-java-agent/instrumentation/spring-scheduling-3.1/spring-scheduling-3.1.gradle
+muzzle {
+ pass {
+ group = 'org.springframework'
+ module = 'spring-context'
+ versions = "[3.1.0.RELEASE,]"
+ assertInverse = true
+ }
+}
+
+apply from: "${rootDir}/gradle/java.gradle"
+
+apply plugin: 'org.unbroken-dome.test-sets'
+
+testSets {
+ latestDepTest {
+ dirName = 'test'
+ }
+}
+
+dependencies {
+ // 3.2.3 is the first version with which the tests will run. Lower versions require other
+ // classes and packages to be imported. Versions 3.1.0+ work with the instrumentation.
+ compileOnly group: 'org.springframework', name: 'spring-context', version: '3.1.0.RELEASE'
+ testCompile group: 'org.springframework', name: 'spring-context', version: '3.2.3.RELEASE'
+
+ // this is the latest version that supports Java 7
+ latestDepTestCompile group: 'org.springframework', name: 'spring-context', version: '4.+'
+}

RENAME
dd-java-agent/instrumentation/spring-scheduling-1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringSchedulingDecorator.java
dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringSchedulingDecorator.java
RENAME
dd-java-agent/instrumentation/spring-scheduling-1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringSchedulingInstrumentation.java
dd-java-agent/instrumentation/spring-scheduling-3.1/src/main/java/datadog/trace/instrumentation/springscheduling/SpringSchedulingInstrumentation.java
package datadog.trace.instrumentation.springscheduling;
-import com.google.auto.service.AutoService;
-import datadog.trace.agent.tooling.Instrumenter;
-import datadog.trace.instrumentation.api.AgentScope;
-import datadog.trace.instrumentation.api.AgentSpan;
-import net.bytebuddy.asm.Advice;
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.description.type.TypeDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-
-import java.util.Map;
-
import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.instrumentation.springscheduling.SpringSchedulingDecorator.DECORATE;
@@ -21,6 +10,16 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
+import com.google.auto.service.AutoService;
+import datadog.trace.agent.tooling.Instrumenter;
+import datadog.trace.instrumentation.api.AgentScope;
+import datadog.trace.instrumentation.api.AgentSpan;
+import java.util.Map;
+import net.bytebuddy.asm.Advice;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
@AutoService(Instrumenter.class)
public final class SpringSchedulingInstrumentation extends Instrumenter.Default {

RENAME
dd-java-agent/instrumentation/spring-scheduling-1/src/test/groovy/SpringSchedulingTest.groovy
dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/groovy/SpringSchedulingTest.groovy
@@ -4,21 +4,19 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
class SpringSchedulingTest extends AgentTestRunner {
- def "schedule interval test"() {
+ def "schedule trigger test according to cron expression"() {
setup:
- def context = new AnnotationConfigApplicationContext(IntervalTaskConfig)
- def task = context.getBean(IntervalTask)
-
- TEST_WRITER.clear()
+ def context = new AnnotationConfigApplicationContext(TriggerTaskConfig)
+ def task = context.getBean(TriggerTask)
- task.blockUntilExecute();
+ task.blockUntilExecute()
expect:
- assert task != null;
+ assert task != null
assertTraces(1) {
trace(0, 1) {
span(0) {
- resourceName "IntervalTask.run"
+ resourceName "TriggerTask.run"
operationName "scheduled.call"
parent()
errored false
@@ -31,21 +29,19 @@ class SpringSchedulingTest extends AgentTestRunner {
}
}
- def "schedule trigger test according to cron expression"() {
+ def "schedule interval test"() {
setup:
- def context = new AnnotationConfigApplicationContext(TriggerTaskConfig)
- def task = context.getBean(TriggerTask)
-
- TEST_WRITER.clear()
+ def context = new AnnotationConfigApplicationContext(IntervalTaskConfig)
+ def task = context.getBean(IntervalTask)
- task.blockUntilExecute();
+ task.blockUntilExecute()
expect:
- assert task != null;
+ assert task != null
assertTraces(1) {
trace(0, 1) {
span(0) {
- resourceName "TriggerTask.run"
+ resourceName "IntervalTask.run"
operationName "scheduled.call"
parent()
errored false
@@ -56,5 +52,6 @@ class SpringSchedulingTest extends AgentTestRunner {
}
}
}
+
}
}

ADD
dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/java/IntervalTask.java
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class IntervalTask implements Runnable {
+
+ private final CountDownLatch latch = new CountDownLatch(1);
+
+ @Scheduled(fixedRate = 5000)
+ @Override
+ public void run() {
+ latch.countDown();
+ }
+
+ public void blockUntilExecute() throws InterruptedException {
+ latch.await(5, TimeUnit.SECONDS);
+ }
+}

RENAME
dd-java-agent/instrumentation/spring-scheduling-1/src/test/java/IntervalTaskConfig.java
dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/java/IntervalTaskConfig.java
ADD
dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/java/TriggerTask.java
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class TriggerTask implements Runnable {
+
+ private final CountDownLatch latch = new CountDownLatch(1);
+
+ @Scheduled(cron = "0/5 * * * * *")
+ @Override
+ public void run() {
+ latch.countDown();
+ }
+
+ public void blockUntilExecute() throws InterruptedException {
+ latch.await(5, TimeUnit.SECONDS);
+ }
+}

RENAME
dd-java-agent/instrumentation/spring-scheduling-1/src/test/java/TriggerTaskConfig.java
dd-java-agent/instrumentation/spring-scheduling-3.1/src/test/java/TriggerTaskConfig.java
MODIFY
settings.gradle
settings.gradle
@@ -130,7 +130,7 @@ include ':dd-java-agent:instrumentation:servlet:request-3'
include ':dd-java-agent:instrumentation:slf4j-mdc'
include ':dd-java-agent:instrumentation:sparkjava-2.3'
include ':dd-java-agent:instrumentation:spring-data-1.8'
-include ':dd-java-agent:instrumentation:spring-scheduling-1'
+include ':dd-java-agent:instrumentation:spring-scheduling-3.1'
include ':dd-java-agent:instrumentation:spring-webmvc-3.1'
include ':dd-java-agent:instrumentation:spring-webflux-5'
include ':dd-java-agent:instrumentation:spymemcached-2.12'

change module and file names to match version of earliest supported version of spring-context