Skip to content

Commit

Permalink
Add support for instr skip regex management
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmonettas committed Apr 6, 2024
1 parent d062e15 commit b130178
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

## master (unreleased)

### New Features

- Add support for instr skip regex management

### Changes

### Bugs fixed
12 changes: 12 additions & 0 deletions src/main/clojure/cljs/storm/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,20 @@
(when touch-path
(storm-utils/touch-cljs-files touch-path))))

(defn set-instr-skip-regex [re]
(emitter/set-instrumentation-skip-regex re))

(defn rm-instr-skip-regex []
(emitter/remove-instrumentation-skip-regex))

(defn get-instr-prefixes []
emitter/instrument-only-prefixes)

(defn get-skip-prefixes []
emitter/instrument-skip-prefixes)

(defn get-skip-regex []
emitter/instrument-skip-regex)

(defn set-instrumentation [on?]
(emitter/set-instrumentation on?))
16 changes: 15 additions & 1 deletion src/main/clojure/cljs/storm/emitter.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
(str/split #",")))
:cljs (def instrument-skip-prefixes nil))

#?(:clj (def instrument-skip-regex
(when-let [re (System/getProperty "cljs.storm.instrumentSkipRegex")]
(re-pattern re)))
:cljs (def instrument-skip-regex nil))

#?(:clj (defn set-instrumentation [on?]
(alter-var-root #'instrument-enable (constantly on?))))

Expand All @@ -31,6 +36,12 @@
#?(:clj (defn remove-instrumentation-skip-prefix [p]
(alter-var-root #'instrument-skip-prefixes (fn [isp] (remove #(= % p) isp)))))

#?(:clj (defn set-instrumentation-skip-regex [re]
(alter-var-root #'instrument-skip-regex (constantly (re-pattern re)))))

#?(:clj (defn remove-instrumentation-skip-regex []
(alter-var-root #'instrument-skip-regex (constantly nil))))

#?(:clj (defn skip-instrumentation? [ns-symb]
(let [nsname (str ns-symb)
instrument? false
Expand All @@ -41,7 +52,10 @@
instrument? (reduce (fn [inst? p]
(and inst? (not (str/starts-with? nsname p))))
instrument?
instrument-skip-prefixes)]
instrument-skip-prefixes)
instrument? (if-not instrument-skip-regex
instrument?
(and instrument? (not (re-find instrument-skip-regex nsname))))]
;; skip iff
(or (not instrument-enable)
(not instrument?)))))

0 comments on commit b130178

Please sign in to comment.