28namespace kcenon {
namespace monitoring {
31class central_collector;
44 std::chrono::nanoseconds dur,
49 ,
timestamp(std::chrono::steady_clock::now())
76 std::shared_ptr<central_collector> collector =
nullptr);
Thread-local buffer for lock-free metric collection.
~thread_local_buffer()
Destructor - flushes any remaining samples.
size_t flush()
Flush buffered samples to central collector.
thread_local_buffer & operator=(thread_local_buffer &&)=delete
std::shared_ptr< central_collector > collector_
size_t size() const
Get current number of buffered samples.
thread_local_buffer & operator=(const thread_local_buffer &)=delete
bool record_auto_flush(const metric_sample &sample)
Record a metric sample with automatic flush on overflow.
bool is_full() const
Check if buffer is full.
std::vector< metric_sample > buffer_
const stats & get_stats() const
Get buffer statistics.
size_t capacity() const
Get buffer capacity.
void set_collector(std::shared_ptr< central_collector > collector)
Set the central collector.
static constexpr size_t DEFAULT_CAPACITY
thread_local_buffer(thread_local_buffer &&)=delete
thread_local_buffer(const thread_local_buffer &)=delete
thread_local_buffer(size_t capacity=DEFAULT_CAPACITY, std::shared_ptr< central_collector > collector=nullptr)
Construct a thread-local buffer.
bool record(const metric_sample &sample)
Record a metric sample (lock-free)
Sample data structure for metric recording.
std::chrono::steady_clock::time_point timestamp
std::chrono::nanoseconds duration
std::string operation_name
metric_sample(const std::string &name, std::chrono::nanoseconds dur, bool succ)
Get statistics about buffer operations.
size_t auto_flushes
Flushes triggered by auto_flush.
size_t total_flushes
Total flush operations.
size_t total_records
Total records written.