Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring beans transformer #2143

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>