Skip to content

Commit

Permalink
Add support for superTypeRestriction in instrumentation config JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
jaikiran authored and trask committed May 6, 2017
1 parent 2095f46 commit 2e762fe
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 0 deletions.
Expand Up @@ -58,6 +58,12 @@ public String subTypeRestriction() {
return "";
}

@Value.Default
@JsonInclude(value = Include.NON_EMPTY)
public String superTypeRestriction() {
return "";
}

// pointcuts with methodDeclaringClassName are no longer supported in 0.9.16, but included here
// to help with transitioning of old instrumentation config
@Deprecated
Expand Down Expand Up @@ -237,6 +243,7 @@ public AgentConfig.InstrumentationConfig toProto() {
.setClassName(className())
.setClassAnnotation(classAnnotation())
.setSubTypeRestriction(subTypeRestriction())
.setSuperTypeRestriction(superTypeRestriction())
// pointcuts with methodDeclaringClassName are no longer supported in
// 0.9.16, but included here to help with transitioning of old
// instrumentation config
Expand Down Expand Up @@ -277,6 +284,7 @@ public static InstrumentationConfig create(AgentConfig.InstrumentationConfig con
.className(config.getClassName())
.classAnnotation(config.getClassAnnotation())
.subTypeRestriction(config.getSubTypeRestriction())
.superTypeRestriction(config.getSuperTypeRestriction())
// pointcuts with methodDeclaringClassName are no longer supported in 0.9.16, but
// included here to help with transitioning of old instrumentation config
.methodDeclaringClassName(config.getMethodDeclaringClassName())
Expand Down
Expand Up @@ -143,6 +143,7 @@ public ClassLoader run() {
builder.pointcutClassNamePattern(buildPattern(pointcut.className()));
builder.pointcutClassAnnotationPattern(buildPattern(pointcut.classAnnotation()));
builder.pointcutSubTypeRestrictionPattern(buildPattern(pointcut.subTypeRestriction()));
builder.pointcutSuperTypeRestrictionPattern(buildPattern(pointcut.superTypeRestriction()));
builder.pointcutMethodNamePattern(buildPattern(pointcut.methodName()));
builder.pointcutMethodAnnotationPattern(buildPattern(pointcut.methodAnnotation()));
builder.pointcutMethodParameterTypes(buildPatterns(pointcut.methodParameterTypes()));
Expand Down
Expand Up @@ -155,6 +155,7 @@ private void addClassAnnotation(ClassWriter cw) {
annotationVisitor.visit("className", config.className());
annotationVisitor.visit("classAnnotation", config.classAnnotation());
annotationVisitor.visit("subTypeRestriction", config.subTypeRestriction());
annotationVisitor.visit("superTypeRestriction", config.superTypeRestriction());
annotationVisitor.visit("methodName", config.methodName());
annotationVisitor.visit("methodAnnotation", config.methodAnnotation());
AnnotationVisitor arrayAnnotationVisitor =
Expand Down
1 change: 1 addition & 0 deletions ui/app/scripts/controllers/config/instrumentation-list.js
Expand Up @@ -162,6 +162,7 @@ glowroot.controller('ConfigInstrumentationListCtrl', [
var base = {
classAnnotation: '',
subTypeRestriction: '',
superTypeRestriction: '',
methodAnnotation: '',
methodReturnType: '',
nestingGroup: '',
Expand Down
1 change: 1 addition & 0 deletions ui/app/scripts/controllers/config/instrumentation.js
Expand Up @@ -113,6 +113,7 @@ glowroot.controller('ConfigInstrumentationCtrl', [
// (see instrumentation-list.js)
classAnnotation: '',
subTypeRestriction: '',
superTypeRestriction: '',
methodAnnotation: '',
nestingGroup: '',
order: 0,
Expand Down
3 changes: 3 additions & 0 deletions ui/app/scripts/services/instrumentation-export.js
Expand Up @@ -26,6 +26,9 @@ glowroot.factory('instrumentationExport', [
if (!config.subTypeRestriction) {
delete config.subTypeRestriction;
}
if (!config.superTypeRestriction) {
delete config.superTypeRestriction;
}
if (!config.methodAnnotation) {
delete config.methodAnnotation;
}
Expand Down
Expand Up @@ -324,6 +324,7 @@ abstract static class InstrumentationConfigDto {
abstract String className();
abstract String classAnnotation();
abstract String subTypeRestriction();
abstract String superTypeRestriction();
// pointcuts with methodDeclaringClassName are no longer supported in 0.9.16, but
// included here to help with transitioning of old instrumentation config
//
Expand Down Expand Up @@ -358,6 +359,7 @@ private InstrumentationConfig convert() {
.setClassName(className())
.setClassAnnotation(classAnnotation())
.setSubTypeRestriction(subTypeRestriction())
.setSuperTypeRestriction(superTypeRestriction())
// pointcuts with methodDeclaringClassName are no longer supported in 0.9.16,
// but included here to help with transitioning of old instrumentation config
//
Expand Down Expand Up @@ -402,6 +404,7 @@ private static InstrumentationConfigDto create(InstrumentationConfig config) {
.className(config.getClassName())
.classAnnotation(config.getClassAnnotation())
.subTypeRestriction(config.getSubTypeRestriction())
.superTypeRestriction(config.getSuperTypeRestriction())
// pointcuts with methodDeclaringClassName are no longer supported in
// 0.9.16, but included here to help with transitioning of old
// instrumentation config
Expand Down
1 change: 1 addition & 0 deletions wire-api/src/main/proto/AgentConfig.proto
Expand Up @@ -99,6 +99,7 @@ message AgentConfig {
string class_name = 1;
string class_annotation = 2;
string sub_type_restriction = 24;
string super_type_restriction = 25;
string method_declaring_class_name = 3; // deprecated in 0.9.16, still supported here for
// glowroot central 0.9.16 or newer running agent 0.9.15
// or older
Expand Down

0 comments on commit 2e762fe

Please sign in to comment.