Add setting to filter out trace views that aren't interesting
This commit is contained in:
parent
a43ff6464b
commit
e34047c54d
|
@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. This change
|
||||||
* Setting to control how many epochs are retained
|
* Setting to control how many epochs are retained
|
||||||
* Setting to reset all epochs
|
* Setting to reset all epochs
|
||||||
* Setting to ignore epochs
|
* Setting to ignore epochs
|
||||||
|
* Setting to filter out trace for views from uninteresting namespaces
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
external-window? (localstorage/get "external-window?" false)
|
external-window? (localstorage/get "external-window?" false)
|
||||||
using-trace? (localstorage/get "using-trace?" true)
|
using-trace? (localstorage/get "using-trace?" true)
|
||||||
ignored-events (localstorage/get "ignored-events" {})
|
ignored-events (localstorage/get "ignored-events" {})
|
||||||
|
filtered-view-trace (localstorage/get "filtered-view-trace" (let [id1 (random-uuid)
|
||||||
|
id2 (random-uuid)]
|
||||||
|
{id1 {:id id1 :ns-str "re-com.box" :ns 're-com.box :sort 0}
|
||||||
|
id2 {:id id2 :ns-str "re-com.input-text" :ns 're-com.input-text :sort 1}}))
|
||||||
num-epochs (localstorage/get "retained-epochs" 5)
|
num-epochs (localstorage/get "retained-epochs" 5)
|
||||||
categories (localstorage/get "categories" #{:event :sub/run :sub/create :sub/dispose})]
|
categories (localstorage/get "categories" #{:event :sub/run :sub/create :sub/dispose})]
|
||||||
(when using-trace?
|
(when using-trace?
|
||||||
|
@ -20,6 +24,7 @@
|
||||||
(rf/dispatch [:settings/show-panel? show-panel?])
|
(rf/dispatch [:settings/show-panel? show-panel?])
|
||||||
(rf/dispatch [:settings/selected-tab selected-tab])
|
(rf/dispatch [:settings/selected-tab selected-tab])
|
||||||
(rf/dispatch [:settings/set-ignored-events ignored-events])
|
(rf/dispatch [:settings/set-ignored-events ignored-events])
|
||||||
|
(rf/dispatch [:settings/set-filtered-view-trace filtered-view-trace])
|
||||||
(rf/dispatch [:settings/set-number-of-retained-epochs num-epochs])
|
(rf/dispatch [:settings/set-number-of-retained-epochs num-epochs])
|
||||||
(when external-window?
|
(when external-window?
|
||||||
(rf/dispatch [:global/launch-external]))
|
(rf/dispatch [:global/launch-external]))
|
||||||
|
|
|
@ -194,6 +194,38 @@
|
||||||
(fn [_ [_ ignored-events]]
|
(fn [_ [_ ignored-events]]
|
||||||
ignored-events))
|
ignored-events))
|
||||||
|
|
||||||
|
(def filtered-view-trace-mw
|
||||||
|
[(rf/path [:settings :filtered-view-trace]) (rf/after #(localstorage/save! "filtered-view-trace" %))])
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
:settings/add-filtered-view-trace
|
||||||
|
filtered-view-trace-mw
|
||||||
|
(fn [filtered-view-trace _]
|
||||||
|
(let [id (random-uuid)]
|
||||||
|
(assoc filtered-view-trace id {:id id :ns-str "" :ns nil :sort (js/Date.now)}))))
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
:settings/remove-filtered-view-trace
|
||||||
|
filtered-view-trace-mw
|
||||||
|
(fn [filtered-view-trace [_ id]]
|
||||||
|
(dissoc filtered-view-trace id)))
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
:settings/update-filtered-view-trace
|
||||||
|
filtered-view-trace-mw
|
||||||
|
(fn [filtered-view-trace [_ id ns-str]]
|
||||||
|
;; TODO: this won't inform users if they type bad strings in.
|
||||||
|
(let [event (read-string-maybe ns-str)]
|
||||||
|
(-> filtered-view-trace
|
||||||
|
(assoc-in [id :ns-str] ns-str)
|
||||||
|
(update-in [id :ns] (fn [old-event] (if event event old-event)))))))
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
:settings/set-filtered-view-trace
|
||||||
|
filtered-view-trace-mw
|
||||||
|
(fn [_ [_ ignored-events]]
|
||||||
|
ignored-events))
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-db
|
||||||
:settings/low-level-trace
|
:settings/low-level-trace
|
||||||
[(rf/path [:settings :low-level-trace])]
|
[(rf/path [:settings :low-level-trace])]
|
||||||
|
|
|
@ -142,6 +142,9 @@
|
||||||
(defn subscription-not-run? [trace]
|
(defn subscription-not-run? [trace]
|
||||||
false)
|
false)
|
||||||
|
|
||||||
|
(defn render? [trace]
|
||||||
|
(= :render (:op-type trace)))
|
||||||
|
|
||||||
(defn unchanged-l2-subscription? [sub]
|
(defn unchanged-l2-subscription? [sub]
|
||||||
;; TODO: check if value changed
|
;; TODO: check if value changed
|
||||||
(and
|
(and
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
(ns day8.re-frame.trace.subs
|
(ns day8.re-frame.trace.subs
|
||||||
(:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
|
(:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
|
||||||
[day8.re-frame.trace.metamorphic :as metam]
|
[day8.re-frame.trace.metamorphic :as metam]
|
||||||
[day8.re-frame.trace.utils.utils :as utils]))
|
[day8.re-frame.trace.utils.utils :as utils]
|
||||||
|
[clojure.string :as str]))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:settings/root
|
:settings/root
|
||||||
|
@ -46,6 +47,12 @@
|
||||||
(fn [settings]
|
(fn [settings]
|
||||||
(sort-by :sort (vals (:ignored-events settings)))))
|
(sort-by :sort (vals (:ignored-events settings)))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:settings/filtered-view-trace
|
||||||
|
:<- [:settings/root]
|
||||||
|
(fn [settings]
|
||||||
|
(sort-by :sort (vals (:filtered-view-trace settings)))))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:settings/low-level-trace
|
:settings/low-level-trace
|
||||||
;; TODO: filter from traces panel
|
;; TODO: filter from traces panel
|
||||||
|
@ -139,8 +146,23 @@
|
||||||
(count traces)))
|
(count traces)))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:traces/current-event-traces
|
:traces/all-visible-traces
|
||||||
:<- [:traces/all-traces]
|
:<- [:traces/all-traces]
|
||||||
|
:<- [:settings/filtered-view-trace]
|
||||||
|
(fn [[all-traces filtered-views] _]
|
||||||
|
(let [munged-ns (->> filtered-views
|
||||||
|
(map (comp munge :ns-str))
|
||||||
|
(set))]
|
||||||
|
(into []
|
||||||
|
;; Filter out view namespaces we don't care about.
|
||||||
|
(remove
|
||||||
|
(fn [trace] (and (metam/render? trace)
|
||||||
|
(contains? munged-ns (subs (:operation trace) 0 (str/last-index-of (:operation trace) "."))))))
|
||||||
|
all-traces))))
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:traces/current-event-traces
|
||||||
|
:<- [:traces/all-visible-traces]
|
||||||
:<- [:epochs/beginning-trace-id]
|
:<- [:epochs/beginning-trace-id]
|
||||||
:<- [:epochs/ending-trace-id]
|
:<- [:epochs/ending-trace-id]
|
||||||
(fn [[traces beginning ending] _]
|
(fn [[traces beginning ending] _]
|
||||||
|
@ -354,13 +376,13 @@
|
||||||
:<- [:subs/all-sub-traces]
|
:<- [:subs/all-sub-traces]
|
||||||
:<- [:app-db/reagent-id]
|
:<- [:app-db/reagent-id]
|
||||||
(fn [[traces app-db-id]]
|
(fn [[traces app-db-id]]
|
||||||
(let [raw (map (fn [trace] (let [pod-type (sub-op-type->type trace)
|
(let [raw (map (fn [trace] (let [pod-type (sub-op-type->type trace)
|
||||||
path-data (get-in trace [:tags :query-v])
|
path-data (get-in trace [:tags :query-v])
|
||||||
;; TODO: detect layer 2/3 for sub/create and sub/destroy
|
;; TODO: detect layer 2/3 for sub/create and sub/destroy
|
||||||
;; This information needs to be accumulated.
|
;; This information needs to be accumulated.
|
||||||
layer (if (some #(= app-db-id %) (get-in trace [:tags :input-signals]))
|
layer (if (some #(= app-db-id %) (get-in trace [:tags :input-signals]))
|
||||||
2
|
2
|
||||||
3)]
|
3)]
|
||||||
{:id (str pod-type (get-in trace [:tags :reaction]))
|
{:id (str pod-type (get-in trace [:tags :reaction]))
|
||||||
:type pod-type
|
:type pod-type
|
||||||
:layer layer
|
:layer layer
|
||||||
|
@ -379,17 +401,17 @@
|
||||||
(filter #(= :created (:type %)))
|
(filter #(= :created (:type %)))
|
||||||
(map (juxt :path-data identity))
|
(map (juxt :path-data identity))
|
||||||
(into {}))
|
(into {}))
|
||||||
raw (keep (fn [sub]
|
raw (keep (fn [sub]
|
||||||
(case (:type sub)
|
(case (:type sub)
|
||||||
:created (if-some [re-run-sub (get re-run (:path-data sub))]
|
:created (if-some [re-run-sub (get re-run (:path-data sub))]
|
||||||
(assoc sub :value (:value re-run-sub))
|
(assoc sub :value (:value re-run-sub))
|
||||||
sub)
|
sub)
|
||||||
|
|
||||||
:re-run (when-not (contains? created (:path-data sub))
|
:re-run (when-not (contains? created (:path-data sub))
|
||||||
sub)
|
sub)
|
||||||
|
|
||||||
sub))
|
sub))
|
||||||
raw)
|
raw)
|
||||||
|
|
||||||
;; Filter out run if it was created
|
;; Filter out run if it was created
|
||||||
;; Group together run time
|
;; Group together run time
|
||||||
|
@ -397,7 +419,7 @@
|
||||||
(filter (fn [[k v]] (< 1 v)))
|
(filter (fn [[k v]] (< 1 v)))
|
||||||
(frequencies (map :id raw)))
|
(frequencies (map :id raw)))
|
||||||
|
|
||||||
output (map (fn [sub] (assoc sub :run-times (get run-multiple? (:id sub)))) raw)]
|
output (map (fn [sub] (assoc sub :run-times (get run-multiple? (:id sub)))) raw)]
|
||||||
(sort-by identity subscription-comparator output))))
|
(sort-by identity subscription-comparator output))))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
|
|
|
@ -15,34 +15,6 @@
|
||||||
(def settings-box-81 (render-css (units/px- common/gs-81 (units/px* 2 settings-box-vertical-padding))))
|
(def settings-box-81 (render-css (units/px- common/gs-81 (units/px* 2 settings-box-vertical-padding))))
|
||||||
(def settings-box-131 (render-css (units/px- common/gs-131 (units/px* 2 settings-box-vertical-padding))))
|
(def settings-box-131 (render-css (units/px- common/gs-131 (units/px* 2 settings-box-vertical-padding))))
|
||||||
|
|
||||||
;; TODO: START ========== LOCAL DATA - REPLACE WITH SUBS AND EVENTS
|
|
||||||
|
|
||||||
(def *ignore-items (r/atom [{:id (gensym) :text ":some/event-id"}]))
|
|
||||||
|
|
||||||
(def *filter-items (r/atom [{:id (gensym) :text "re-com.h-box"}
|
|
||||||
{:id (gensym) :text "re-com.input-text"}]))
|
|
||||||
|
|
||||||
(defn add-item [*items]
|
|
||||||
(let [id (gensym)]
|
|
||||||
(println "Added item" id)
|
|
||||||
(swap! *items concat [{:id id :text ""}])))
|
|
||||||
|
|
||||||
(defn delete-item [*items id]
|
|
||||||
(println "Deleted item" id)
|
|
||||||
(reset! *items (filterv #(not= id (:id %)) @*items)))
|
|
||||||
|
|
||||||
(defn update-item-field
|
|
||||||
[*items id field new-val]
|
|
||||||
(let [f (fn [item]
|
|
||||||
(if (= id (:id item))
|
|
||||||
(do
|
|
||||||
(println "Updated" field "in" (:id item) "from" (get item field) "to" new-val)
|
|
||||||
(assoc item field new-val))
|
|
||||||
item))]
|
|
||||||
(reset! *items (mapv f @*items))))
|
|
||||||
|
|
||||||
;; TODO: END ========== LOCAL DATA - REPLACE WITH SUBS AND EVENTS
|
|
||||||
|
|
||||||
(def settings-styles
|
(def settings-styles
|
||||||
[:#--re-frame-trace--
|
[:#--re-frame-trace--
|
||||||
[:.settings
|
[:.settings
|
||||||
|
@ -149,9 +121,8 @@
|
||||||
[:p "Useful if you want to ignore a periodic background polling event."]]
|
[:p "Useful if you want to ignore a periodic background polling event."]]
|
||||||
settings-box-131]
|
settings-box-131]
|
||||||
|
|
||||||
;; TODO: filter out view trace
|
[rc/line]
|
||||||
#_[rc/line]
|
[settings-box
|
||||||
#_[settings-box
|
|
||||||
[[rc/h-box
|
[[rc/h-box
|
||||||
:align :center
|
:align :center
|
||||||
:gap horizontal-gap
|
:gap horizontal-gap
|
||||||
|
@ -162,18 +133,19 @@
|
||||||
:label [rc/v-box
|
:label [rc/v-box
|
||||||
:align :center
|
:align :center
|
||||||
:children ["+ namespace"]]
|
:children ["+ namespace"]]
|
||||||
:on-click #(add-item *filter-items)]]]
|
:on-click #(rf/dispatch [:settings/add-filtered-view-trace])]]]
|
||||||
[rc/v-box
|
[rc/v-box
|
||||||
:width comp-section-width
|
:width comp-section-width
|
||||||
:gap vertical-gap
|
:gap vertical-gap
|
||||||
:children (for [item @*filter-items]
|
:children (for [item @(rf/subscribe [:settings/filtered-view-trace])
|
||||||
^{:key (:id item)}
|
:let [id (:id item)]]
|
||||||
|
^{:key id}
|
||||||
[closeable-text-box
|
[closeable-text-box
|
||||||
:model (:text item)
|
:model (:ns-str item)
|
||||||
:width "343px"
|
:width "343px"
|
||||||
:on-close #(delete-item *filter-items (:id item))
|
:on-close #(rf/dispatch [:settings/remove-filtered-view-trace id])
|
||||||
:on-change #(update-item-field *filter-items (:id item) :text %)])]]
|
:on-change #(rf/dispatch [:settings/update-filtered-view-trace id %])])]]
|
||||||
[[:p "Sometimes you want to focus on just your own views, and the trace associated with library views is just noise."]
|
[[:p "Sometimes you want to focus on your own views, and the trace associated with library views is just noise."]
|
||||||
[:p "Nominate one or more namespaces."]]
|
[:p "Nominate one or more namespaces."]]
|
||||||
settings-box-131]
|
settings-box-131]
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
trace-detail-expansions (rf/subscribe [:traces/expansions])
|
trace-detail-expansions (rf/subscribe [:traces/expansions])
|
||||||
beginning (rf/subscribe [:epochs/beginning-trace-id])
|
beginning (rf/subscribe [:epochs/beginning-trace-id])
|
||||||
end (rf/subscribe [:epochs/ending-trace-id])
|
end (rf/subscribe [:epochs/ending-trace-id])
|
||||||
|
traces (rf/subscribe [:traces/all-traces])
|
||||||
current-traces (rf/subscribe [:traces/current-event-traces])
|
current-traces (rf/subscribe [:traces/current-event-traces])
|
||||||
show-epoch-traces? (rf/subscribe [:traces/show-epoch-traces?])]
|
show-epoch-traces? (rf/subscribe [:traces/show-epoch-traces?])]
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -173,5 +174,3 @@
|
||||||
[:span "(" [:button.text-button {:on-click #(rf/dispatch [:epochs/reset])} "clear"] ")"])]
|
[:span "(" [:button.text-button {:on-click #(rf/dispatch [:epochs/reset])} "clear"] ")"])]
|
||||||
[:th {:style {:text-align "right"}} "meta"]]
|
[:th {:style {:text-align "right"}} "meta"]]
|
||||||
[:tbody (render-traces visible-traces filter-items filter-input trace-detail-expansions)]]]]))))
|
[:tbody (render-traces visible-traces filter-items filter-input trace-detail-expansions)]]]]))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue