change module and file names to match version of earliest supported version of spring-context
This commit is contained in:
parent
9eb51248cd
commit
f3537e1665
|
@ -2,10 +2,21 @@
|
||||||
|
|
||||||
package datadog.trace.instrumentation.springdata;
|
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 com.google.auto.service.AutoService;
|
||||||
import datadog.trace.agent.tooling.Instrumenter;
|
import datadog.trace.agent.tooling.Instrumenter;
|
||||||
import datadog.trace.instrumentation.api.AgentScope;
|
import datadog.trace.instrumentation.api.AgentScope;
|
||||||
import datadog.trace.instrumentation.api.AgentSpan;
|
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.asm.Advice;
|
||||||
import net.bytebuddy.description.method.MethodDescription;
|
import net.bytebuddy.description.method.MethodDescription;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
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.RepositoryFactorySupport;
|
||||||
import org.springframework.data.repository.core.support.RepositoryProxyPostProcessor;
|
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)
|
@AutoService(Instrumenter.class)
|
||||||
public final class SpringRepositoryInstrumentation extends Instrumenter.Default {
|
public final class SpringRepositoryInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
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')
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
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.+'
|
||||||
|
}
|
|
@ -1,16 +1,5 @@
|
||||||
package datadog.trace.instrumentation.springscheduling;
|
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.activateSpan;
|
||||||
import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
|
import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
|
||||||
import static datadog.trace.instrumentation.springscheduling.SpringSchedulingDecorator.DECORATE;
|
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.not;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
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)
|
@AutoService(Instrumenter.class)
|
||||||
public final class SpringSchedulingInstrumentation extends Instrumenter.Default {
|
public final class SpringSchedulingInstrumentation extends Instrumenter.Default {
|
||||||
|
|
|
@ -4,44 +4,15 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||||
|
|
||||||
class SpringSchedulingTest extends AgentTestRunner {
|
class SpringSchedulingTest extends AgentTestRunner {
|
||||||
|
|
||||||
def "schedule interval test"() {
|
|
||||||
setup:
|
|
||||||
def context = new AnnotationConfigApplicationContext(IntervalTaskConfig)
|
|
||||||
def task = context.getBean(IntervalTask)
|
|
||||||
|
|
||||||
TEST_WRITER.clear()
|
|
||||||
|
|
||||||
task.blockUntilExecute();
|
|
||||||
|
|
||||||
expect:
|
|
||||||
assert task != null;
|
|
||||||
assertTraces(1) {
|
|
||||||
trace(0, 1) {
|
|
||||||
span(0) {
|
|
||||||
resourceName "IntervalTask.run"
|
|
||||||
operationName "scheduled.call"
|
|
||||||
parent()
|
|
||||||
errored false
|
|
||||||
tags {
|
|
||||||
"$Tags.COMPONENT" "spring-scheduling"
|
|
||||||
defaultTags()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def "schedule trigger test according to cron expression"() {
|
def "schedule trigger test according to cron expression"() {
|
||||||
setup:
|
setup:
|
||||||
def context = new AnnotationConfigApplicationContext(TriggerTaskConfig)
|
def context = new AnnotationConfigApplicationContext(TriggerTaskConfig)
|
||||||
def task = context.getBean(TriggerTask)
|
def task = context.getBean(TriggerTask)
|
||||||
|
|
||||||
TEST_WRITER.clear()
|
task.blockUntilExecute()
|
||||||
|
|
||||||
task.blockUntilExecute();
|
|
||||||
|
|
||||||
expect:
|
expect:
|
||||||
assert task != null;
|
assert task != null
|
||||||
assertTraces(1) {
|
assertTraces(1) {
|
||||||
trace(0, 1) {
|
trace(0, 1) {
|
||||||
span(0) {
|
span(0) {
|
||||||
|
@ -57,4 +28,30 @@ class SpringSchedulingTest extends AgentTestRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "schedule interval test"() {
|
||||||
|
setup:
|
||||||
|
def context = new AnnotationConfigApplicationContext(IntervalTaskConfig)
|
||||||
|
def task = context.getBean(IntervalTask)
|
||||||
|
|
||||||
|
task.blockUntilExecute()
|
||||||
|
|
||||||
|
expect:
|
||||||
|
assert task != null
|
||||||
|
assertTraces(1) {
|
||||||
|
trace(0, 1) {
|
||||||
|
span(0) {
|
||||||
|
resourceName "IntervalTask.run"
|
||||||
|
operationName "scheduled.call"
|
||||||
|
parent()
|
||||||
|
errored false
|
||||||
|
tags {
|
||||||
|
"$Tags.COMPONENT" "spring-scheduling"
|
||||||
|
defaultTags()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -130,7 +130,7 @@ include ':dd-java-agent:instrumentation:servlet:request-3'
|
||||||
include ':dd-java-agent:instrumentation:slf4j-mdc'
|
include ':dd-java-agent:instrumentation:slf4j-mdc'
|
||||||
include ':dd-java-agent:instrumentation:sparkjava-2.3'
|
include ':dd-java-agent:instrumentation:sparkjava-2.3'
|
||||||
include ':dd-java-agent:instrumentation:spring-data-1.8'
|
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-webmvc-3.1'
|
||||||
include ':dd-java-agent:instrumentation:spring-webflux-5'
|
include ':dd-java-agent:instrumentation:spring-webflux-5'
|
||||||
include ':dd-java-agent:instrumentation:spymemcached-2.12'
|
include ':dd-java-agent:instrumentation:spymemcached-2.12'
|
||||||
|
|
Loading…
Reference in New Issue