Skip to content

Commit a83e5b0

Browse files
committed
Support multiple clojure.storm.instrumentOnlyPrefixes.* and clojure.storm.instrumentSkipPrefixes.* that will get merged
1 parent b8c45da commit a83e5b0

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## master (unreleased)
44

55
### New Features
6+
7+
- Support multiple clojure.storm.instrumentOnlyPrefixes.* and clojure.storm.instrumentSkipPrefixes.* that will get merged
68

79
### Changes
810

src/jvm/clojure/storm/Emitter.java

+5-17
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,19 @@ public class Emitter {
6969
{
7070
// This is kind of hacky because ClojureStorm shouldn't have anything related to
7171
// flow-storm, but we want to be sure that we never automatically instrument flow-storm root
72-
if(!autoPrefix.equals("flow-storm")) {
72+
if(!autoPrefix.equals("flow-storm") && !autoPrefix.equals("clojure")) {
7373
System.out.println("ClojureStorm adding instrumentation auto prefix " + autoPrefix);
7474
addInstrumentationOnlyPrefix(autoPrefix);
7575
}
7676

7777
}
7878
}
7979

80-
String onlyPrefixesProp = System.getProperty("clojure.storm.instrumentOnlyPrefixes");
81-
if(onlyPrefixesProp != null && !onlyPrefixesProp.isBlank())
82-
{
83-
String[] prefixes = onlyPrefixesProp.split(",");
84-
for(String p : prefixes)
85-
addInstrumentationOnlyPrefix(p);
86-
87-
}
80+
for(String p : Utils.prefixesForPropStartingWith("clojure.storm.instrumentOnlyPrefixes"))
81+
addInstrumentationOnlyPrefix(p);
8882

89-
String skipPrefixesProp = System.getProperty("clojure.storm.instrumentSkipPrefixes");
90-
if(skipPrefixesProp != null && !skipPrefixesProp.isBlank())
91-
{
92-
String[] prefixes = skipPrefixesProp.split(",");
93-
for(String p : prefixes)
94-
addInstrumentationSkipPrefix(p);
95-
96-
}
83+
for(String p : Utils.prefixesForPropStartingWith("clojure.storm.instrumentSkipPrefixes"))
84+
addInstrumentationSkipPrefix(p);
9785

9886
String skipRegexProp = System.getProperty("clojure.storm.instrumentSkipRegex");
9987
if(skipRegexProp != null)

src/jvm/clojure/storm/Utils.java

+22
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.util.ArrayList;
2929
import java.util.Set;
3030
import java.util.HashSet;
31+
import java.util.Map;
32+
import java.util.Properties;
3133
import java.io.File;
3234
import java.util.regex.Matcher;
3335
import java.util.regex.Pattern;
@@ -335,4 +337,24 @@ public static boolean isAnnoyingLeinNreplForm(Object form) {
335337
return false;
336338
}
337339

340+
public static List<String> prefixesForPropStartingWith(String propPrefix) {
341+
List foundPrefixes = new ArrayList<String>();
342+
343+
Properties properties = System.getProperties();
344+
for(Map.Entry<Object, Object> propEntry : properties.entrySet()) {
345+
String propKey = (String)propEntry.getKey();
346+
if (propKey.startsWith(propPrefix)) {
347+
String propVal = (String)propEntry.getValue();
348+
349+
if(propVal != null && !propVal.isBlank()) {
350+
String[] prefixes = propVal.split(",");
351+
for(String p : prefixes)
352+
foundPrefixes.add(p);
353+
}
354+
}
355+
}
356+
357+
return foundPrefixes;
358+
}
359+
338360
}

0 commit comments

Comments
 (0)