util::log_rate_limit_check (private)

 util::log_rate_limit_check severity key interval

Defined in packages/acs-tcl/tcl/utilities-procs.tcl

Return {suppressed reference}. A suppressed count of -1 means that this call should not log. Otherwise, it is the number of suppressed calls collected for this notice. Reference identifies the original logging thread. The caller must supply a positive interval in seconds.

Parameters:
severity (required)
key (required)
interval (required)

Partial Call Graph (max 5 caller/called nodes):
ad_log ad_log (public) util::log_rate_limit_check util::log_rate_limit_check ad_log->util::log_rate_limit_check

Testcases:
No testcase defined.
Source code:
    set severity [string tolower $severity]
    set group [list $severity $key]

    set count_key [list pending $group]
    set reference_key [list reference $group]

    #
    # This local variable changes only when this caller evaluates
    # the cache-miss script. Cache hits retain the suppression decision.
    #
    set decision [list -1 ""]

    ::acs::misc_cache eval -expires $interval -- log-rate-$group {
        #
        # Initialize the counter and original reference atomically.
        # These values survive expiration of the cache marker.
        #
        nsv_set -default ad_log_rate_limited $count_key 0
        set reference [nsv_set -default  ad_log_rate_limited $reference_key  [ns_thread name]]

        #
        # Collect previous suppressions and start a new count.
        #
        set suppressed [nsv_set -reset  ad_log_rate_limited $count_key 0]

        set decision [list $suppressed $reference]

        #
        # Cache only a marker, not this caller's logging decision.
        #
        set marker 1
    }

    if {[lindex $decision 0] < 0} {
        nsv_incr ad_log_rate_limited $count_key
    }

    return $decision
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-tcl/tcl/utilities-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: