PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::network::pipeline::pipeline_metrics Class Reference

Centralized metrics collection for the entire pipeline. More...

#include <pipeline_metrics.h>

Collaboration diagram for kcenon::pacs::network::pipeline::pipeline_metrics:
Collaboration graph

Public Member Functions

 pipeline_metrics ()=default
 Default constructor.
 
 pipeline_metrics (const pipeline_metrics &)=delete
 
pipeline_metricsoperator= (const pipeline_metrics &)=delete
 
 pipeline_metrics (pipeline_metrics &&)=delete
 
pipeline_metricsoperator= (pipeline_metrics &&)=delete
 
auto get_stage_metrics (pipeline_stage stage) noexcept -> stage_metrics &
 Get metrics for a specific stage.
 
auto get_stage_metrics (pipeline_stage stage) const noexcept -> const stage_metrics &
 Get metrics for a specific stage (const)
 
void record_stage_completion (pipeline_stage stage, uint64_t processing_time_ns, bool success) noexcept
 Record a stage job completion.
 
void increment_stage_queue (pipeline_stage stage) noexcept
 Increment queued job count for a stage.
 
void decrement_stage_queue (pipeline_stage stage) noexcept
 Decrement queued job count for a stage.
 
auto get_category_metrics (job_category category) noexcept -> category_metrics &
 Get metrics for a specific category.
 
auto get_category_metrics (job_category category) const noexcept -> const category_metrics &
 Get metrics for a specific category (const)
 
void record_operation_completion (job_category category, uint64_t latency_ns, bool success) noexcept
 Record an operation completion.
 
auto get_total_operations () const noexcept -> uint64_t
 Get total operations processed.
 
auto get_active_associations () const noexcept -> uint32_t
 Get current number of active associations.
 
void increment_active_associations () noexcept
 Increment active association count.
 
void decrement_active_associations () noexcept
 Decrement active association count.
 
auto get_peak_associations () const noexcept -> uint32_t
 Get peak concurrent associations.
 
void reset () noexcept
 Reset all metrics.
 
void mark_start_time () noexcept
 Mark the start time for throughput calculation.
 
auto get_throughput_per_second (job_category category) const noexcept -> double
 Calculate throughput for a category (operations per second)
 

Static Public Attributes

static constexpr size_t stage_count
 Number of pipeline stages.
 
static constexpr size_t category_count = 8
 Number of job categories.
 

Private Attributes

std::array< stage_metrics, stage_countstage_metrics_
 
std::array< category_metrics, category_countcategory_metrics_
 
std::atomic< uint64_t > total_operations_ {0}
 
std::atomic< uint32_t > active_associations_ {0}
 
std::atomic< uint32_t > peak_associations_ {0}
 
std::chrono::steady_clock::time_point start_time_ {std::chrono::steady_clock::now()}
 

Detailed Description

Centralized metrics collection for the entire pipeline.

Provides thread-safe metrics collection with minimal overhead using atomic operations and relaxed memory ordering where safe.

Definition at line 204 of file pipeline_metrics.h.

Constructor & Destructor Documentation

◆ pipeline_metrics() [1/3]

kcenon::pacs::network::pipeline::pipeline_metrics::pipeline_metrics ( )
default

◆ pipeline_metrics() [2/3]

kcenon::pacs::network::pipeline::pipeline_metrics::pipeline_metrics ( const pipeline_metrics & )
delete

◆ pipeline_metrics() [3/3]

kcenon::pacs::network::pipeline::pipeline_metrics::pipeline_metrics ( pipeline_metrics && )
delete

Member Function Documentation

◆ decrement_active_associations()

void kcenon::pacs::network::pipeline::pipeline_metrics::decrement_active_associations ( )
inlinenoexcept

Decrement active association count.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 344 of file pipeline_metrics.h.

344 {
345 active_associations_.fetch_sub(1, std::memory_order_relaxed);
346 }

References active_associations_.

◆ decrement_stage_queue()

void kcenon::pacs::network::pipeline::pipeline_metrics::decrement_stage_queue ( pipeline_stage stage)
inlinenoexcept

Decrement queued job count for a stage.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 269 of file pipeline_metrics.h.

269 {
270 stage_metrics_[static_cast<size_t>(stage)].jobs_queued.fetch_sub(
271 1, std::memory_order_relaxed);
272 }
std::array< stage_metrics, stage_count > stage_metrics_

References stage_metrics_.

◆ get_active_associations()

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_active_associations ( ) const -> uint32_t
inlinenodiscardnoexcept

Get current number of active associations.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 323 of file pipeline_metrics.h.

323 {
324 return active_associations_.load(std::memory_order_relaxed);
325 }

References active_associations_.

◆ get_category_metrics() [1/2]

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_category_metrics ( job_category category) const -> const category_metrics&
inlinenodiscardnoexcept

Get metrics for a specific category (const)

Definition at line 291 of file pipeline_metrics.h.

292 {
293 return category_metrics_[static_cast<size_t>(category)];
294 }
std::array< category_metrics, category_count > category_metrics_

References category_metrics_.

◆ get_category_metrics() [2/2]

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_category_metrics ( job_category category) -> category_metrics&
inlinenodiscardnoexcept

Get metrics for a specific category.

Parameters
categoryThe job category
Returns
Reference to the category metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 283 of file pipeline_metrics.h.

284 {
285 return category_metrics_[static_cast<size_t>(category)];
286 }

References category_metrics_.

◆ get_peak_associations()

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_peak_associations ( ) const -> uint32_t
inlinenodiscardnoexcept

Get peak concurrent associations.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 351 of file pipeline_metrics.h.

351 {
352 return peak_associations_.load(std::memory_order_relaxed);
353 }

References peak_associations_.

◆ get_stage_metrics() [1/2]

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_stage_metrics ( pipeline_stage stage) const -> const stage_metrics&
inlinenodiscardnoexcept

Get metrics for a specific stage (const)

Definition at line 241 of file pipeline_metrics.h.

242 {
243 return stage_metrics_[static_cast<size_t>(stage)];
244 }

References stage_metrics_.

◆ get_stage_metrics() [2/2]

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_stage_metrics ( pipeline_stage stage) -> stage_metrics&
inlinenodiscardnoexcept

Get metrics for a specific stage.

Parameters
stageThe pipeline stage
Returns
Reference to the stage metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 233 of file pipeline_metrics.h.

234 {
235 return stage_metrics_[static_cast<size_t>(stage)];
236 }

References stage_metrics_.

◆ get_throughput_per_second()

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_throughput_per_second ( job_category category) const -> double
inlinenodiscardnoexcept

Calculate throughput for a category (operations per second)

Parameters
categoryThe job category
Returns
Operations per second since start_time
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 385 of file pipeline_metrics.h.

386 {
387 auto elapsed = std::chrono::steady_clock::now() - start_time_;
388 auto seconds = std::chrono::duration<double>(elapsed).count();
389 if (seconds <= 0.0) {
390 return 0.0;
391 }
392 return static_cast<double>(
393 category_metrics_[static_cast<size_t>(category)]
394 .total_operations.load(std::memory_order_relaxed)) / seconds;
395 }
std::chrono::steady_clock::time_point start_time_

References category_metrics_, and start_time_.

◆ get_total_operations()

auto kcenon::pacs::network::pipeline::pipeline_metrics::get_total_operations ( ) const -> uint64_t
inlinenodiscardnoexcept

Get total operations processed.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 316 of file pipeline_metrics.h.

316 {
317 return total_operations_.load(std::memory_order_relaxed);
318 }

References total_operations_.

◆ increment_active_associations()

void kcenon::pacs::network::pipeline::pipeline_metrics::increment_active_associations ( )
inlinenoexcept

Increment active association count.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 330 of file pipeline_metrics.h.

330 {
331 uint32_t current = active_associations_.fetch_add(1, std::memory_order_relaxed);
332 // Update peak if necessary
333 uint32_t peak = peak_associations_.load(std::memory_order_relaxed);
334 while (current + 1 > peak &&
335 !peak_associations_.compare_exchange_weak(
336 peak, current + 1,
337 std::memory_order_relaxed, std::memory_order_relaxed)) {
338 }
339 }

References active_associations_, and peak_associations_.

◆ increment_stage_queue()

void kcenon::pacs::network::pipeline::pipeline_metrics::increment_stage_queue ( pipeline_stage stage)
inlinenoexcept

Increment queued job count for a stage.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 261 of file pipeline_metrics.h.

261 {
262 stage_metrics_[static_cast<size_t>(stage)].jobs_queued.fetch_add(
263 1, std::memory_order_relaxed);
264 }

References stage_metrics_.

◆ mark_start_time()

void kcenon::pacs::network::pipeline::pipeline_metrics::mark_start_time ( )
inlinenoexcept

Mark the start time for throughput calculation.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 376 of file pipeline_metrics.h.

376 {
377 start_time_ = std::chrono::steady_clock::now();
378 }

References start_time_.

Referenced by kcenon::pacs::network::pipeline::pipeline_coordinator::reset_metrics().

Here is the caller graph for this function:

◆ operator=() [1/2]

pipeline_metrics & kcenon::pacs::network::pipeline::pipeline_metrics::operator= ( const pipeline_metrics & )
delete

◆ operator=() [2/2]

pipeline_metrics & kcenon::pacs::network::pipeline::pipeline_metrics::operator= ( pipeline_metrics && )
delete

◆ record_operation_completion()

void kcenon::pacs::network::pipeline::pipeline_metrics::record_operation_completion ( job_category category,
uint64_t latency_ns,
bool success )
inlinenoexcept

Record an operation completion.

Parameters
categoryThe job category
latency_nsEnd-to-end latency in nanoseconds
successWhether the operation succeeded
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 302 of file pipeline_metrics.h.

303 {
304 category_metrics_[static_cast<size_t>(category)]
305 .record_operation(latency_ns, success);
306 total_operations_.fetch_add(1, std::memory_order_relaxed);
307 }

References category_metrics_, kcenon::pacs::network::pipeline::success, and total_operations_.

◆ record_stage_completion()

void kcenon::pacs::network::pipeline::pipeline_metrics::record_stage_completion ( pipeline_stage stage,
uint64_t processing_time_ns,
bool success )
inlinenoexcept

Record a stage job completion.

Parameters
stageThe pipeline stage
processing_time_nsProcessing time in nanoseconds
successWhether the job succeeded
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 252 of file pipeline_metrics.h.

253 {
254 stage_metrics_[static_cast<size_t>(stage)]
255 .record_job_completion(processing_time_ns, success);
256 }

References stage_metrics_, and kcenon::pacs::network::pipeline::success.

◆ reset()

void kcenon::pacs::network::pipeline::pipeline_metrics::reset ( )
inlinenoexcept

Reset all metrics.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 362 of file pipeline_metrics.h.

362 {
363 for (auto& stage : stage_metrics_) {
364 stage.reset();
365 }
366 for (auto& category : category_metrics_) {
367 category.reset();
368 }
369 total_operations_.store(0, std::memory_order_relaxed);
370 peak_associations_.store(0, std::memory_order_relaxed);
371 }

References category_metrics_, peak_associations_, stage_metrics_, and total_operations_.

Referenced by kcenon::pacs::network::pipeline::pipeline_coordinator::reset_metrics().

Here is the caller graph for this function:

Member Data Documentation

◆ active_associations_

std::atomic<uint32_t> kcenon::pacs::network::pipeline::pipeline_metrics::active_associations_ {0}
private

◆ category_count

size_t kcenon::pacs::network::pipeline::pipeline_metrics::category_count = 8
staticconstexpr

◆ category_metrics_

◆ peak_associations_

std::atomic<uint32_t> kcenon::pacs::network::pipeline::pipeline_metrics::peak_associations_ {0}
private

◆ stage_count

size_t kcenon::pacs::network::pipeline::pipeline_metrics::stage_count
staticconstexpr
Initial value:
=
static_cast<size_t>(pipeline_stage::stage_count)

Number of pipeline stages.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/network/pipeline/metrics/pipeline_metrics.h.

Definition at line 207 of file pipeline_metrics.h.

◆ stage_metrics_

◆ start_time_

std::chrono::steady_clock::time_point kcenon::pacs::network::pipeline::pipeline_metrics::start_time_ {std::chrono::steady_clock::now()}
private

◆ total_operations_

std::atomic<uint64_t> kcenon::pacs::network::pipeline::pipeline_metrics::total_operations_ {0}
private

The documentation for this class was generated from the following file: