-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* extend ClassInstrumentationConfiguration (wip) * extend ClassInstrumentationConfiguration and adjust tests * add test * improve tests * apply requested changes * optimize method call order * apply spotless
- Loading branch information
Showing
39 changed files
with
759 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 0 additions & 78 deletions
78
...main/java/rocks/inspectit/gepard/agent/internal/instrumentation/InstrumentationState.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 30 additions & 7 deletions
37
...pectit/gepard/agent/internal/instrumentation/model/ClassInstrumentationConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,42 @@ | ||
package rocks.inspectit.gepard.agent.internal.instrumentation.model; | ||
|
||
import java.util.Collections; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import net.bytebuddy.description.method.MethodDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
import net.bytebuddy.matcher.ElementMatchers; | ||
|
||
/** | ||
* Stores the instrumentation configuration for a specific class. Currently, a class can only be | ||
* instrumented or not. Later, we could add a list of active rules for example. | ||
*/ | ||
public class ClassInstrumentationConfiguration { | ||
public record ClassInstrumentationConfiguration( | ||
Set<InstrumentationScope> activeScopes, | ||
ElementMatcher.Junction<MethodDescription> methodMatcher) { | ||
|
||
/** The configuration representing that no instrumentation of the class if performed. */ | ||
public static final ClassInstrumentationConfiguration NO_INSTRUMENTATION = | ||
new ClassInstrumentationConfiguration(Collections.emptySet(), ElementMatchers.none()); | ||
|
||
/** Currently, only true */ | ||
private final boolean isInstrumented; | ||
/** | ||
* Checks, if this configuration induces bytecode changes to the target class. | ||
* | ||
* @return true, if this configuration expects instrumentation | ||
*/ | ||
public boolean isActive() { | ||
return !activeScopes.isEmpty(); | ||
} | ||
|
||
public ClassInstrumentationConfiguration(boolean isInstrumented) { | ||
this.isInstrumented = isInstrumented; | ||
@Override | ||
public boolean equals(Object o) { | ||
if (o instanceof ClassInstrumentationConfiguration otherConfig) | ||
return activeScopes.equals(otherConfig.activeScopes); | ||
return false; | ||
} | ||
|
||
public boolean isInstrumented() { | ||
return isInstrumented; | ||
@Override | ||
public int hashCode() { | ||
return Objects.hash(activeScopes); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ava/rocks/inspectit/gepard/agent/internal/instrumentation/model/InstrumentationScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package rocks.inspectit.gepard.agent.internal.instrumentation.model; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import rocks.inspectit.gepard.agent.internal.configuration.model.instrumentation.Scope; | ||
|
||
/** | ||
* @param fqn the fully qualified name of a class | ||
* @param methods the methods of the class to instrument | ||
*/ | ||
public record InstrumentationScope(String fqn, List<String> methods) { | ||
|
||
/** | ||
* Creates an {@link InstrumentationScope} out of a {@link Scope} | ||
* | ||
* @param scope the scope | ||
* @return the instrumentation scope | ||
*/ | ||
public static InstrumentationScope create(Scope scope) { | ||
return new InstrumentationScope(scope.getFqn(), scope.getMethods()); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (o instanceof InstrumentationScope otherScope) | ||
return fqn.equals(otherScope.fqn) && methods.equals(otherScope.methods); | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(fqn, methods); | ||
} | ||
} |
Oops, something went wrong.