mirror of
https://github.com/taoensso/telemere.git
synced 2025-12-17 01:51:10 +00:00
[new] Add :rate-limit-by option to all signal creators
When present, will cause limits to be per [expansion, by-value]
This commit is contained in:
parent
f703630914
commit
d9c3583631
5 changed files with 24 additions and 21 deletions
|
|
@ -79,6 +79,7 @@ It enables you to write code that is **information-verbose by default**.
|
||||||
:when (my-conditional)
|
:when (my-conditional)
|
||||||
:rate-limit {"1 per sec" [1 1000]
|
:rate-limit {"1 per sec" [1 1000]
|
||||||
"5 per min" [5 60000]}
|
"5 per min" [5 60000]}
|
||||||
|
:rate-limit-by my-user-ip-address ; Optional rate-limit scope
|
||||||
|
|
||||||
:do (inc-my-metric!)
|
:do (inc-my-metric!)
|
||||||
:let
|
:let
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
:when (my-conditional)
|
:when (my-conditional)
|
||||||
:rate-limit {"1 per sec" [1 1000]
|
:rate-limit {"1 per sec" [1 1000]
|
||||||
"5 per min" [5 60000]}
|
"5 per min" [5 60000]}
|
||||||
|
:rate-limit-by my-user-ip-address ; Optional rate-limit scope
|
||||||
|
|
||||||
:do (inc-my-metric!)
|
:do (inc-my-metric!)
|
||||||
:let
|
:let
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ Signal options (shared by all signal creators):
|
||||||
`:sample-rate` - ?rate ∈ℝ[0,1] for signal sampling (0.75 => allow 75% of signals, nil => allow all)
|
`:sample-rate` - ?rate ∈ℝ[0,1] for signal sampling (0.75 => allow 75% of signals, nil => allow all)
|
||||||
`:when` -------- Arb ?form; when present, form must return truthy to allow signal
|
`:when` -------- Arb ?form; when present, form must return truthy to allow signal
|
||||||
`:rate-limit` -- ?spec as given to `taoensso.telemere/rate-limiter`, see its docstring for details
|
`:rate-limit` -- ?spec as given to `taoensso.telemere/rate-limiter`, see its docstring for details
|
||||||
|
`:rate-limit-by` When present, rate limits will be enforced independently for each id (any Clojure value!)
|
||||||
`:middleware` -- Optional (fn [signal]) => ?modified-signal to apply when signal is created
|
`:middleware` -- Optional (fn [signal]) => ?modified-signal to apply when signal is created
|
||||||
`:trace?` ------ Should tracing be enabled for `:run` form?
|
`:trace?` ------ Should tracing be enabled for `:run` form?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -378,14 +378,14 @@
|
||||||
'([{:as opts :keys
|
'([{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
[#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error run & kvs]}])
|
ctx parent root trace?, do let data msg error run & kvs]}])
|
||||||
|
|
||||||
:signal-allowed?
|
:signal-allowed?
|
||||||
'([{:as opts :keys
|
'([{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
[#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
||||||
elidable? location #_location* #_inst #_uid #_middleware,
|
elidable? location #_location* #_inst #_uid #_middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
#_ctx #_parent #_root #_trace?, #_do #_let #_data #_msg #_error #_run #_& #_kvs]}])
|
#_ctx #_parent #_root #_trace?, #_do #_let #_data #_msg #_error #_run #_& #_kvs]}])
|
||||||
|
|
||||||
:event! ; [id] [id level-or-opts] => allowed?
|
:event! ; [id] [id level-or-opts] => allowed?
|
||||||
|
|
@ -395,7 +395,7 @@
|
||||||
{:as opts :keys
|
{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id,
|
[#_defaults #_elide? #_allow? #_expansion-id,
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error #_run & kvs]}])
|
ctx parent root trace?, do let data msg error #_run & kvs]}])
|
||||||
|
|
||||||
:log! ; [msg] [level-or-opts msg] => allowed?
|
:log! ; [msg] [level-or-opts msg] => allowed?
|
||||||
|
|
@ -404,7 +404,7 @@
|
||||||
[{:as opts :keys
|
[{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id,
|
[#_defaults #_elide? #_allow? #_expansion-id,
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error #_run & kvs]}
|
ctx parent root trace?, do let data msg error #_run & kvs]}
|
||||||
msg])
|
msg])
|
||||||
|
|
||||||
|
|
@ -414,7 +414,7 @@
|
||||||
[{:as opts :keys
|
[{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id,
|
[#_defaults #_elide? #_allow? #_expansion-id,
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error #_run & kvs]}
|
ctx parent root trace?, do let data msg error #_run & kvs]}
|
||||||
error])
|
error])
|
||||||
|
|
||||||
|
|
@ -424,7 +424,7 @@
|
||||||
[{:as opts :keys
|
[{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id,
|
[#_defaults #_elide? #_allow? #_expansion-id,
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error run & kvs]}
|
ctx parent root trace?, do let data msg error run & kvs]}
|
||||||
form])
|
form])
|
||||||
|
|
||||||
|
|
@ -434,7 +434,7 @@
|
||||||
[{:as opts :keys
|
[{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id, rethrow? catch-val,
|
[#_defaults #_elide? #_allow? #_expansion-id, rethrow? catch-val,
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error #_run & kvs]}
|
ctx parent root trace?, do let data msg error #_run & kvs]}
|
||||||
form])
|
form])
|
||||||
|
|
||||||
|
|
@ -444,7 +444,7 @@
|
||||||
[{:as opts :keys
|
[{:as opts :keys
|
||||||
[#_defaults #_elide? #_allow? #_expansion-id,
|
[#_defaults #_elide? #_allow? #_expansion-id,
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error #_run & kvs]}])
|
ctx parent root trace?, do let data msg error #_run & kvs]}])
|
||||||
|
|
||||||
(enc/unexpected-arg! macro-id))))
|
(enc/unexpected-arg! macro-id))))
|
||||||
|
|
@ -616,7 +616,7 @@
|
||||||
(not-empty
|
(not-empty
|
||||||
(dissoc opts
|
(dissoc opts
|
||||||
:elidable? :location :location* :inst :uid :middleware,
|
:elidable? :location :location* :inst :uid :middleware,
|
||||||
:sample-rate :ns :kind :id :level :filter :when #_:rate-limit,
|
:sample-rate :ns :kind :id :level :filter :when #_:rate-limit #_:rate-limit-by,
|
||||||
:ctx :parent #_:trace?, :do :let :data :msg :error :run,
|
:ctx :parent #_:trace?, :do :let :data :msg :error :run,
|
||||||
:elide? :allow? #_:expansion-id :otel/context))
|
:elide? :allow? #_:expansion-id :otel/context))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@
|
||||||
[fallback, ; Unique to shell
|
[fallback, ; Unique to shell
|
||||||
#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
||||||
elidable? location #_location* inst uid middleware,
|
elidable? location #_location* inst uid middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
ctx parent root trace?, do let data msg error run & kvs]}])}
|
ctx parent root trace?, do let data msg error run & kvs]}])}
|
||||||
|
|
||||||
[opts]
|
[opts]
|
||||||
|
|
@ -172,7 +172,7 @@
|
||||||
[#_fallback, ; Unique to shell
|
[#_fallback, ; Unique to shell
|
||||||
#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
#_defaults #_elide? #_allow? #_expansion-id, ; Undocumented
|
||||||
elidable? location #_location* #_inst #_uid #_middleware,
|
elidable? location #_location* #_inst #_uid #_middleware,
|
||||||
sample-rate kind ns id level when rate-limit,
|
sample-rate kind ns id level when rate-limit rate-limit-by,
|
||||||
#_ctx #_parent #_root #_trace?, #_do #_let #_data #_msg #_error #_run #_& #_kvs]}])}
|
#_ctx #_parent #_root #_trace?, #_do #_let #_data #_msg #_error #_run #_& #_kvs]}])}
|
||||||
|
|
||||||
[opts]
|
[opts]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue