-
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)
- Loading branch information
Showing
8 changed files
with
127 additions
and
19 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
32 changes: 25 additions & 7 deletions
32
...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,37 @@ | ||
package rocks.inspectit.gepard.agent.internal.instrumentation.model; | ||
|
||
import java.util.Collections; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* 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) { | ||
|
||
/** The configuration representing that no instrumentation of the class if performed. */ | ||
public static final ClassInstrumentationConfiguration NO_INSTRUMENTATION = | ||
new ClassInstrumentationConfiguration(Collections.emptySet()); | ||
|
||
/** Currently, only true */ | ||
private final boolean isInstrumented; | ||
@Override | ||
public boolean equals(Object o) { | ||
if (o instanceof ClassInstrumentationConfiguration otherConfig) | ||
return activeScopes.equals(otherConfig.activeScopes); | ||
return false; | ||
} | ||
|
||
public ClassInstrumentationConfiguration(boolean isInstrumented) { | ||
this.isInstrumented = isInstrumented; | ||
@Override | ||
public int hashCode() { | ||
return Objects.hash(activeScopes); | ||
} | ||
|
||
public boolean isInstrumented() { | ||
return 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(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...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,32 @@ | ||
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 | ||
* @param methods | ||
*/ | ||
public record InstrumentationScope(String fqn, List<String> methods) { | ||
|
||
/** | ||
* @param scope | ||
* @return | ||
*/ | ||
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); | ||
} | ||
} |
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