ns::stats::Sampler method retainSample (protected)

 <instance of ns::stats::Sampler[i]> retainSample sample

Defined in

Called while holding the existing ns_stats coordination lock. Keep bounded endpoint CPU counters for display-window calculations. Raw baselines and derived per-thread maps are not retained.

Parameters:
sample (required)

Testcases:
No testcase defined.
Source code:
set record [dict remove $sample raw]
if {[dict exists $record cpuPercent threads]} {
    dict unset record cpuPercent threads
}
set records [nsv_get ns_stats recent]
lappend records $record
set cutoff [expr {[dict get $record timestamp]-900000000}]
set dropped [nsv_get ns_stats recentDroppedThrough]
while {[llength $records]>180
       || ([llength $records]>1 && [dict get [lindex $records 0] timestamp]<$cutoff)} {
    set dropped [dict get [lindex $records 0] timestamp]
    set records [lrange $records 1 end]
}
nsv_set ns_stats recent $records
nsv_set ns_stats recentDroppedThrough $dropped
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: