-
Notifications
You must be signed in to change notification settings - Fork 313
Cleanup InstrumenterModule
enablement
#9027
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,20 +32,13 @@ public abstract class InstrumenterModule implements Instrumenter { | |
/** | ||
* Since several systems share the same instrumentation infrastructure in order to enable only the | ||
* applicable {@link Instrumenter instrumenters} on startup each {@linkplain InstrumenterModule} | ||
* must declare its target system. The systems currently supported include: | ||
* | ||
* <ul> | ||
* <li>{@link TargetSystem#TRACING tracing} | ||
* <li>{@link TargetSystem#PROFILING profiling} | ||
* <li>{@link TargetSystem#APPSEC appsec} | ||
* <li>{@link TargetSystem#IAST iast} | ||
* <li>{@link TargetSystem#CIVISIBILITY ci-visibility} | ||
* <li>{@link TargetSystem#USM usm} | ||
* </ul> | ||
* must declare its target system. | ||
*/ | ||
public enum TargetSystem { | ||
COMMON, // instrumentation common to every system | ||
TRACING, | ||
PROFILING, | ||
SECURITY, // instrumentation shared between APPSEC and IAST | ||
APPSEC, | ||
IAST, | ||
CIVISIBILITY, | ||
|
@@ -177,25 +170,16 @@ public Map<String, String> contextStore() { | |
return emptyMap(); | ||
} | ||
|
||
public abstract TargetSystem targetSystem(); | ||
|
||
protected boolean defaultEnabled() { | ||
return InstrumenterConfig.get().isIntegrationsEnabled(); | ||
} | ||
|
||
public boolean isEnabled() { | ||
public boolean isEnabled(Set<TargetSystem> enabledSystems) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: I found the What about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily for this PR, but I've been pondering whether annotations would be a better way to specify this type of information. |
||
return enabled; | ||
} | ||
|
||
/** | ||
* Indicates the applicability of an {@linkplain InstrumenterModule} to the given system.<br> | ||
* | ||
* @param enabledSystems a set of all the enabled target systems | ||
* @return {@literal true} if the set of enabled systems contains all the ones required by this | ||
* particular {@linkplain InstrumenterModule} | ||
*/ | ||
public boolean isApplicable(Set<TargetSystem> enabledSystems) { | ||
return false; | ||
} | ||
|
||
protected final boolean isShortcutMatchingEnabled(boolean defaultToShortcut) { | ||
return InstrumenterConfig.get() | ||
.isIntegrationShortcutMatchingEnabled(singletonList(name()), defaultToShortcut); | ||
|
@@ -208,8 +192,8 @@ public Tracing(String instrumentationName, String... additionalNames) { | |
} | ||
|
||
@Override | ||
public boolean isApplicable(Set<TargetSystem> enabledSystems) { | ||
return enabledSystems.contains(TargetSystem.TRACING); | ||
public TargetSystem targetSystem() { | ||
return TargetSystem.TRACING; | ||
} | ||
} | ||
|
||
|
@@ -220,13 +204,13 @@ public Profiling(String instrumentationName, String... additionalNames) { | |
} | ||
|
||
@Override | ||
public boolean isApplicable(Set<TargetSystem> enabledSystems) { | ||
return enabledSystems.contains(TargetSystem.PROFILING); | ||
public TargetSystem targetSystem() { | ||
return TargetSystem.PROFILING; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return super.isEnabled() | ||
public boolean isEnabled(Set<TargetSystem> enabledSystems) { | ||
return super.isEnabled(enabledSystems) | ||
&& !ConfigProvider.getInstance() | ||
.getBoolean(ProfilingConfig.PROFILING_ULTRA_MINIMAL, false); | ||
} | ||
|
@@ -239,8 +223,8 @@ public AppSec(String instrumentationName, String... additionalNames) { | |
} | ||
|
||
@Override | ||
public boolean isApplicable(Set<TargetSystem> enabledSystems) { | ||
return enabledSystems.contains(TargetSystem.APPSEC); | ||
public TargetSystem targetSystem() { | ||
return TargetSystem.APPSEC; | ||
} | ||
} | ||
|
||
|
@@ -251,14 +235,22 @@ public Iast(String instrumentationName, String... additionalNames) { | |
super(instrumentationName, additionalNames); | ||
} | ||
|
||
@Override | ||
public TargetSystem targetSystem() { | ||
return TargetSystem.SECURITY; | ||
} | ||
|
||
@Override | ||
public List<Instrumenter> typeInstrumentations() { | ||
preloadClassNames(); | ||
return super.typeInstrumentations(); | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(Set<TargetSystem> enabledSystems) { | ||
public boolean isEnabled(Set<TargetSystem> enabledSystems) { | ||
if (!super.isEnabled(enabledSystems)) { | ||
return false; | ||
} | ||
if (enabledSystems.contains(TargetSystem.IAST)) { | ||
return true; | ||
} | ||
|
@@ -307,8 +299,8 @@ public Usm(String instrumentationName, String... additionalNames) { | |
} | ||
|
||
@Override | ||
public boolean isApplicable(Set<TargetSystem> enabledSystems) { | ||
return enabledSystems.contains(TargetSystem.USM); | ||
public TargetSystem targetSystem() { | ||
return TargetSystem.USM; | ||
} | ||
} | ||
|
||
|
@@ -319,8 +311,8 @@ public CiVisibility(String instrumentationName, String... additionalNames) { | |
} | ||
|
||
@Override | ||
public boolean isApplicable(Set<TargetSystem> enabledSystems) { | ||
return enabledSystems.contains(TargetSystem.CIVISIBILITY); | ||
public TargetSystem targetSystem() { | ||
return TargetSystem.CIVISIBILITY; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it fail with
assert
?