Skip to content

Commit

Permalink
[pinpoint-apm#10993] Add dependency version matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehong-kim committed May 9, 2024
1 parent 5e83c54 commit a3bdda1
Show file tree
Hide file tree
Showing 116 changed files with 3,988 additions and 845 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.ClientRequest;
Expand Down Expand Up @@ -171,4 +173,18 @@ public Flux<String> useStream() {
.map(sequence -> "Stream Data " + sequence)
.take(10);
}


@GetMapping("/client/resttemplate")
public Mono<String> clientRestTemplate(ServerWebExchange exchange) {
RestTemplate restTemplate = new RestTemplate();
String fooResourceUrl
= "http://httpbin.org";
ResponseEntity<String> response
= restTemplate.getForEntity(fooResourceUrl + "/", String.class);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());

return Mono.just("OK");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import io.netty.handler.timeout.WriteTimeoutHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
Expand Down Expand Up @@ -254,4 +256,17 @@ public Mono<String> clientReactorTimeout(ServerWebExchange exchange) {

return Mono.just("OK");
}

@GetMapping("/client/resttemplate")
public Mono<String> clientRestTemplate(ServerWebExchange exchange) {
RestTemplate restTemplate = new RestTemplate();
String fooResourceUrl
= "http://httpbin.org";
ResponseEntity<String> response
= restTemplate.getForEntity(fooResourceUrl + "/", String.class);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());

return Mono.just("OK");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,16 @@ profiler.spring.async.task.class.names=
###########################################################
# Spring WebFlux
###########################################################
# spring 5.x
profiler.spring.webflux.enable=true
# spring 6.x
profiler.spring.webflux6.enable=true

# If you can't find the version, you have to force it to be specified.
# Force to spring 5 version.
profiler.spring.webflux.version.forced.match=false
# Force to spring 6 version.
profiler.spring.webflux6.version.forced.match=false

# Client
# If you are not using Reactor-Netty, set it to true.
Expand Down Expand Up @@ -1262,7 +1271,16 @@ profiler.hystrix=true
###########################################################
# RestTemplate
###########################################################
# spring 5.x
profiler.resttemplate=false
# spring 6.x
profiler.resttemplate6=false

# If you can't find the version, you have to force it to be specified.
# Force to spring 5 version.
profiler.resttemplate.version.forced.match=false
# Force to spring 6 version.
profiler.resttemplate6.version.forced.match=false

###########################################################
# Netty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,16 @@ profiler.spring.async.task.class.names=
###########################################################
# Spring WebFlux
###########################################################
# spring 5.x
profiler.spring.webflux.enable=true
# spring 6.x
profiler.spring.webflux6.enable=true

# If you can't find the version, you have to force it to be specified.
# Force to spring 5 version.
profiler.spring.webflux.version.forced.match=false
# Force to spring 6 version.
profiler.spring.webflux6.version.forced.match=false

# Client
# If you are not using Reactor-Netty, set it to true.
Expand Down Expand Up @@ -1284,7 +1293,16 @@ profiler.hystrix=false
###########################################################
# RestTemplate
###########################################################
# spring 5.x
profiler.resttemplate=false
# spring 6.x
profiler.resttemplate6=false

# If you can't find the version, you have to force it to be specified.
# Force to spring 5 version.
profiler.resttemplate.version.forced.match=false
# Force to spring 6 version.
profiler.resttemplate6.version.forced.match=false

###########################################################
# Netty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
package com.navercorp.pinpoint.bootstrap.instrument.matcher;

import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand;
import com.navercorp.pinpoint.common.annotations.InterfaceStability;

/**
* @author jaehong.kim
*/
@InterfaceStability.Unstable
public interface BasedMatcher extends Matcher {
MatcherOperand getMatcherOperand();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
package com.navercorp.pinpoint.bootstrap.instrument.matcher;

import com.navercorp.pinpoint.common.annotations.InterfaceStability;

/**
* @author jaehong.kim
*/
@InterfaceStability.Unstable
interface ClassBasedMatcher extends BasedMatcher {
String getBaseClassName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand;
import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand;
import com.navercorp.pinpoint.common.annotations.InterfaceStability;

import java.util.Objects;

/**
* @author jaehong.kim
*/
@InterfaceStability.Unstable
public class DefaultClassBasedMatcher implements ClassBasedMatcher {
private final String baseClassName;
private final MatcherOperand matcherOperand;
Expand All @@ -35,7 +33,6 @@ public class DefaultClassBasedMatcher implements ClassBasedMatcher {

DefaultClassBasedMatcher(final String baseClassName, final MatcherOperand additional) {
this.baseClassName = Objects.requireNonNull(baseClassName, "baseClassName");

this.matcherOperand = getMatcherOperand(baseClassName, additional);
}

Expand All @@ -60,10 +57,9 @@ public MatcherOperand getMatcherOperand() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("DefaultClassBasedMatcher{");
sb.append("baseClassName='").append(baseClassName).append('\'');
sb.append(", matcherOperand=").append(matcherOperand);
sb.append('}');
return sb.toString();
return "DefaultClassBasedMatcher{" +
", baseClassName='" + baseClassName + '\'' +
", matcherOperand=" + matcherOperand +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ public int hashCode() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("DefaultClassNameMatcher{");
sb.append(className);
sb.append('}');
return sb.toString();
return "DefaultClassNameMatcher{" +
", className='" + className + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand;
import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand;
import com.navercorp.pinpoint.common.annotations.InterfaceStability;
import com.navercorp.pinpoint.common.util.CollectionUtils;

import java.util.List;

/**
* @author jaehong.kim
*/
@InterfaceStability.Unstable
public class DefaultMultiClassBasedMatcher implements MultiClassBasedMatcher {
private final List<String> baseClassNames;
private final MatcherOperand matcherOperand;
Expand All @@ -39,7 +37,6 @@ public class DefaultMultiClassBasedMatcher implements MultiClassBasedMatcher {
throw new IllegalArgumentException("basePackageNames must not be empty");
}
this.baseClassNames = baseClassNames;

this.matcherOperand = getMatcherOperand(baseClassNames, additional);
}

Expand Down Expand Up @@ -82,10 +79,9 @@ public MatcherOperand getMatcherOperand() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("DefaultMultiClassBasedMatcher{");
sb.append("baseClassNames=").append(baseClassNames);
sb.append(", matcherOperand=").append(matcherOperand);
sb.append('}');
return sb.toString();
return "DefaultMultiClassBasedMatcher{" +
", baseClassNames=" + baseClassNames +
", matcherOperand=" + matcherOperand +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
* @author emeroad
*/
public class DefaultMultiClassNameMatcher implements MultiClassNameMatcher {

private final List<String> classNameList;

DefaultMultiClassNameMatcher(List<String> classNameMatcherList) {
Objects.requireNonNull(classNameMatcherList, "classNameMatcherList");

this.classNameList = Collections.unmodifiableList(classNameMatcherList);
}

Expand All @@ -53,4 +51,11 @@ public boolean equals(Object o) {
public int hashCode() {
return classNameList.hashCode();
}

@Override
public String toString() {
return "DefaultMultiClassNameMatcher{" +
", classNameList=" + classNameList +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand;
import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand;
import com.navercorp.pinpoint.common.annotations.InterfaceStability;
import com.navercorp.pinpoint.common.util.CollectionUtils;
import com.navercorp.pinpoint.common.util.StringUtils;

Expand All @@ -28,7 +27,6 @@
/**
* @author jaehong.kim
*/
@InterfaceStability.Unstable
public class DefaultMultiPackageBasedMatcher implements MultiPackageBasedMatcher {
private final List<String> basePackageNames;
private final MatcherOperand matcherOperand;
Expand All @@ -41,7 +39,6 @@ public class DefaultMultiPackageBasedMatcher implements MultiPackageBasedMatcher
if (CollectionUtils.isEmpty(basePackageNames)) {
throw new IllegalArgumentException("basePackageNames must not be empty");
}

final List<String> buildBasePackageName = buildBasePackageNameList(basePackageNames);
final MatcherOperand operand = joinOr(buildBasePackageName);
if (operand == null) {
Expand Down Expand Up @@ -102,10 +99,9 @@ public MatcherOperand getMatcherOperand() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("DefaultMultiPackageBasedMatcher{");
sb.append("basePackageNames=").append(basePackageNames);
sb.append(", matcherOperand=").append(matcherOperand);
sb.append('}');
return sb.toString();
return "DefaultMultiPackageBasedMatcher{" +
", basePackageNames=" + basePackageNames +
", matcherOperand=" + matcherOperand +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@

import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand;
import com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand;
import com.navercorp.pinpoint.common.annotations.InterfaceStability;
import com.navercorp.pinpoint.common.util.StringUtils;

import java.util.Objects;

/**
* @author jaehong.kim
*/
@InterfaceStability.Unstable
public class DefaultPackageBasedMatcher implements PackageBasedMatcher {
private final String basePackageName;
private final MatcherOperand matcherOperand;
Expand Down Expand Up @@ -61,10 +59,9 @@ public MatcherOperand getMatcherOperand() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("DefaultPackageBasedMatcher{");
sb.append("basePackageName='").append(basePackageName).append('\'');
sb.append(", matcherOperand=").append(matcherOperand);
sb.append('}');
return sb.toString();
return "DefaultPackageBasedMatcher{" +
", basePackageName='" + basePackageName + '\'' +
", matcherOperand=" + matcherOperand +
'}';
}
}
Loading

0 comments on commit a3bdda1

Please sign in to comment.