Skip to content

Commit

Permalink
add spring beans component-scan
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehong-kim authored and emeroad committed Oct 12, 2016
1 parent b289306 commit c59f3aa
Show file tree
Hide file tree
Showing 26 changed files with 957 additions and 248 deletions.
36 changes: 33 additions & 3 deletions agent/src/main/resources-local/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,46 @@ profiler.orm.mybatis=true
###########################################################
# Profile spring-beans
profiler.spring.beans=true

# filters
# filter
# filter OR filters
# filter
# value
# value AND filter
# value
# profiler.spring.beans.n.name.pattern
# profiler.spring.beans.n.class.pattern
# profiler.spring.beans.n.annotation
# token
# token OR token
# token
# profiler.spring.beans.n.scope= [component-scan | post-processor] default is component-scan.
# profiler.spring.beans.n.base-packages= [package name, ...]
# profiler.spring.beans.n.name.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.class.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.annotation= [annotation name, ...]
#
# Scope:
# component-scan: <context:component-scan ... /> or @ComponentScan
# post-processor: BeanPostProcessor - Slow!!!
#
# ANT Style pattern rules:
# ? - matches on character
# * - matches zero or more characters

# Examples
# profiler.spring.beans.1.name.scope=component-scan
# profiler.spring.beans.1.base-packages=com.foo, com.bar
# profiler.spring.beans.1.name.pattern=.*Foo, regex:.*Bar, antstyle:*Controller
# profiler.spring.beans.1.class.pattern=
# profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
#
# profiler.spring.beans.2.name.scope=post-processor
# profiler.spring.beans.2.base-packages=com.foo
# profiler.spring.beans.2.name.pattern=
# profiler.spring.beans.2.class.pattern=antstyle:com.foo.repository.*Repository, antstyle:com.foo.Service.Main*
# profiler.spring.beans.2.annotation=

profiler.spring.beans.1.name.scope=component-scan
profiler.spring.beans.1.base-packages=
profiler.spring.beans.1.name.pattern=
profiler.spring.beans.1.class.pattern=
profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
Expand Down
36 changes: 33 additions & 3 deletions agent/src/main/resources-release/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,46 @@ profiler.orm.mybatis=true
###########################################################
# Profile spring-beans
profiler.spring.beans=true

# filters
# filter
# filter OR filters
# filter
# value
# value AND filter
# value
# profiler.spring.beans.n.name.pattern
# profiler.spring.beans.n.class.pattern
# profiler.spring.beans.n.annotation
# token
# token OR token
# token
# profiler.spring.beans.n.scope= [component-scan | post-processor] default is component-scan.
# profiler.spring.beans.n.base-packages= [package name, ...]
# profiler.spring.beans.n.name.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.class.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.annotation= [annotation name, ...]
#
# Scope:
# component-scan: <context:component-scan ... /> or @ComponentScan
# post-processor: BeanPostProcessor - Slow!!!
#
# ANT Style pattern rules:
# ? - matches on character
# * - matches zero or more characters

# Examples
# profiler.spring.beans.1.name.scope=component-scan
# profiler.spring.beans.1.base-packages=com.foo, com.bar
# profiler.spring.beans.1.name.pattern=.*Foo, regex:.*Bar, antstyle:*Controller
# profiler.spring.beans.1.class.pattern=
# profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
#
# profiler.spring.beans.2.name.scope=post-processor
# profiler.spring.beans.2.base-packages=com.foo
# profiler.spring.beans.2.name.pattern=
# profiler.spring.beans.2.class.pattern=antstyle:com.foo.repository.*Repository, antstyle:com.foo.Service.Main*
# profiler.spring.beans.2.annotation=

profiler.spring.beans.1.name.scope=component-scan
profiler.spring.beans.1.base-packages=
profiler.spring.beans.1.name.pattern=
profiler.spring.beans.1.class.pattern=
profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,51 @@ profiler.orm.mybatis=true
###########################################################
# Profile spring-beans
profiler.spring.beans=true
profiler.spring.beans.name.pattern=
profiler.spring.beans.class.pattern=
profiler.spring.beans.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
profiler.spring.beans.mark.error=false

# filters
# filter
# filter OR filters
# filter
# value
# value AND filter
# value
# token
# token OR token
# token
# profiler.spring.beans.n.scope= [component-scan | post-processor] default is component-scan.
# profiler.spring.beans.n.base-packages= [package name, ...]
# profiler.spring.beans.n.name.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.class.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.annotation= [annotation name, ...]
#
# Scope:
# component-scan: <context:component-scan ... /> or @ComponentScan
# post-processor: BeanPostProcessor - Slow!!!
#
# ANT Style pattern rules:
# ? - matches on character
# * - matches zero or more characters

# Examples
# profiler.spring.beans.1.name.scope=component-scan
# profiler.spring.beans.1.base-packages=com.foo, com.bar
# profiler.spring.beans.1.name.pattern=.*Foo, regex:.*Bar, antstyle:*Controller
# profiler.spring.beans.1.class.pattern=
# profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
#
# profiler.spring.beans.2.name.scope=post-processor
# profiler.spring.beans.2.base-packages=com.foo
# profiler.spring.beans.2.name.pattern=
# profiler.spring.beans.2.class.pattern=antstyle:com.foo.repository.*Repository, antstyle:com.foo.Service.Main*
# profiler.spring.beans.2.annotation=

profiler.spring.beans.1.name.scope=component-scan
profiler.spring.beans.1.base-packages=
profiler.spring.beans.1.name.pattern=
profiler.spring.beans.1.class.pattern=
profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository

profiler.spring.beans.mark.error=false
###########################################################
# log4j (guide url : https://github.com/naver/pinpoint/blob/master/doc/per-request_feature_guide.md)
###########################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ public void test() throws Exception {

verifier.verifyTraceCount(0);
}
}
}
35 changes: 32 additions & 3 deletions agent/src/test/resources/pinpoint-disabled-plugin-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,48 @@ profiler.orm.mybatis=true
###########################################################
# Profile spring-beans
profiler.spring.beans=true

# filters
# filter
# filter OR filters
# filter
# value
# value AND filter
# value
# profiler.spring.beans.n.name.pattern
# profiler.spring.beans.n.class.pattern
# profiler.spring.beans.n.annotation
# token
# token OR token
# token
# profiler.spring.beans.n.scope= [component-scan | post-processor] default is component-scan.
# profiler.spring.beans.n.base-packages= [package name, ...]
# profiler.spring.beans.n.name.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.class.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.annotation= [annotation name, ...]
#
# Scope:
# component-scan: <context:component-scan ... /> or @ComponentScan
# post-processor: BeanPostProcessor - Slow!!!
#
# ANT Style pattern rules:
# ? - matches on character
# * - matches zero or more characters

# Examples
# profiler.spring.beans.1.name.scope=component-scan
# profiler.spring.beans.1.base-packages=com.foo, com.bar
# profiler.spring.beans.1.name.pattern=.*Foo, regex:.*Bar, antstyle:*Controller
# profiler.spring.beans.1.class.pattern=
# profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
#
# profiler.spring.beans.2.name.scope=post-processor
# profiler.spring.beans.2.base-packages=com.foo
# profiler.spring.beans.2.name.pattern=
# profiler.spring.beans.2.class.pattern=antstyle:com.foo.repository.*Repository, antstyle:com.foo.Service.Main*
# profiler.spring.beans.2.annotation=

profiler.spring.beans.1.name.pattern=ma.*, outer
profiler.spring.beans.2.class.pattern=.*Morae
profiler.spring.beans.3.annotation=org.springframework.stereotype.Component

profiler.spring.beans.mark.error=false

###########################################################
Expand Down
47 changes: 42 additions & 5 deletions agent/src/test/resources/pinpoint-spring-bean-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ profiler.agentInfo.send.retry.interval=300000
# Allows TCP data command
profiler.tcpdatasender.command.accept.enable=true

# Allow bytecode framework (JAVASSIST or ASM)
profiler.instrument.engine=JAVASSIST
# Allow bytecode framework
profiler.instrument.asm=true

###########################################################
# application type #
Expand Down Expand Up @@ -204,19 +204,56 @@ profiler.orm.mybatis=true
###########################################################
# Profile spring-beans
profiler.spring.beans=true

# filters
# filter
# filter OR filters
# filter
# value
# value AND filter
# value
# profiler.spring.beans.n.name.pattern
# profiler.spring.beans.n.class.pattern
# profiler.spring.beans.n.annotation
# token
# token OR token
# token
# profiler.spring.beans.n.scope= [component-scan | post-processor] default is component-scan.
# profiler.spring.beans.n.base-packages= [package name, ...]
# profiler.spring.beans.n.name.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.class.pattern= [regex pattern, regex:regex pattern, antstyle:antstyle pattern, ...]
# profiler.spring.beans.n.annotation= [annotation name, ...]
#
# Scope:
# component-scan: <context:component-scan ... /> or @ComponentScan
# post-processor: BeanPostProcessor - Slow!!!
#
# ANT Style pattern rules:
# ? - matches on character
# * - matches zero or more characters

# Examples:
# profiler.spring.beans.1.name.scope=component-scan
# profiler.spring.beans.1.base-packages=com.foo, com.bar
# profiler.spring.beans.1.name.pattern=.*Foo, regex:.*Bar, antstyle:*Controller
# profiler.spring.beans.1.class.pattern=
# profiler.spring.beans.1.annotation=org.springframework.stereotype.Controller,org.springframework.stereotype.Service,org.springframework.stereotype.Repository
#
# profiler.spring.beans.2.name.scope=post-processor
# profiler.spring.beans.2.base-packages=com.foo
# profiler.spring.beans.2.name.pattern=
# profiler.spring.beans.2.class.pattern=antstyle:com.foo.repository.*Repository, antstyle:com.foo.Service.Main*
# profiler.spring.beans.2.annotation=

profiler.spring.beans.1.scope=post-processor
profiler.spring.beans.1.base-packages=com.navercorp.test.pinpoint
profiler.spring.beans.1.name.pattern=ma.*, outer

profiler.spring.beans.2.scope=post-processor
profiler.spring.beans.2.base-packages=com.navercorp.test.pinpoint
profiler.spring.beans.2.class.pattern=.*Morae

profiler.spring.beans.3.scope=post-processor
profiler.spring.beans.3.base-packages=com.navercorp.test.pinpoint
profiler.spring.beans.3.annotation=org.springframework.stereotype.Component

profiler.spring.beans.mark.error=false

###########################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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
*
* http://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.
*/
package com.navercorp.pinpoint.bootstrap.util;

import java.util.regex.Pattern;

/**
* @author jaehong.kim
*/
public class RegexPathMatcher implements PathMatcher {

private final Pattern pattern;

public RegexPathMatcher(final Pattern pattern) {
this.pattern = pattern;
}

@Override
public boolean isMatched(String path) {
return pattern.matcher(path).matches();
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("RegexPathMatcher{");
sb.append("pattern=").append(pattern);
sb.append('}');
return sb.toString();
}
}
6 changes: 6 additions & 0 deletions plugins/spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@
<artifactId>pinpoint-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

0 comments on commit c59f3aa

Please sign in to comment.