67 jobs_failed.fetch_add(1, std::memory_order_relaxed);
72 while (processing_time_ns > current_max &&
74 current_max, processing_time_ns,
75 std::memory_order_relaxed, std::memory_order_relaxed)) {
85 uint64_t processed =
jobs_processed.load(std::memory_order_relaxed);
143 uint64_t current_max =
max_latency_ns.load(std::memory_order_relaxed);
144 while (latency_ns > current_max &&
146 current_max, latency_ns,
147 std::memory_order_relaxed, std::memory_order_relaxed)) {
151 uint64_t current_min =
min_latency_ns.load(std::memory_order_relaxed);
152 while (latency_ns < current_min &&
154 current_min, latency_ns,
155 std::memory_order_relaxed, std::memory_order_relaxed)) {
255 .record_job_completion(processing_time_ns,
success);
263 1, std::memory_order_relaxed);
271 1, std::memory_order_relaxed);
305 .record_operation(latency_ns,
success);
334 while (current + 1 > peak &&
337 std::memory_order_relaxed, std::memory_order_relaxed)) {
387 auto elapsed = std::chrono::steady_clock::now() -
start_time_;
388 auto seconds = std::chrono::duration<double>(elapsed).count();
389 if (seconds <= 0.0) {
392 return static_cast<double>(
394 .total_operations.load(std::memory_order_relaxed)) / seconds;
403 std::chrono::steady_clock::time_point
start_time_{std::chrono::steady_clock::now()};
Centralized metrics collection for the entire pipeline.
void increment_stage_queue(pipeline_stage stage) noexcept
Increment queued job count for a stage.
auto get_active_associations() const noexcept -> uint32_t
Get current number of active associations.
void decrement_stage_queue(pipeline_stage stage) noexcept
Decrement queued job count for a stage.
pipeline_metrics & operator=(const pipeline_metrics &)=delete
std::chrono::steady_clock::time_point start_time_
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)
void increment_active_associations() noexcept
Increment active association count.
pipeline_metrics()=default
Default constructor.
auto get_total_operations() const noexcept -> uint64_t
Get total operations processed.
auto get_stage_metrics(pipeline_stage stage) noexcept -> stage_metrics &
Get metrics for a specific stage.
void record_stage_completion(pipeline_stage stage, uint64_t processing_time_ns, bool success) noexcept
Record a stage job completion.
std::array< stage_metrics, stage_count > stage_metrics_
pipeline_metrics(pipeline_metrics &&)=delete
auto get_category_metrics(job_category category) const noexcept -> const category_metrics &
Get metrics for a specific category (const)
auto get_category_metrics(job_category category) noexcept -> category_metrics &
Get metrics for a specific category.
std::atomic< uint64_t > total_operations_
std::atomic< uint32_t > peak_associations_
pipeline_metrics(const pipeline_metrics &)=delete
static constexpr size_t category_count
Number of job categories.
auto get_stage_metrics(pipeline_stage stage) const noexcept -> const stage_metrics &
Get metrics for a specific stage (const)
static constexpr size_t stage_count
Number of pipeline stages.
void decrement_active_associations() noexcept
Decrement active association count.
void reset() noexcept
Reset all metrics.
auto get_peak_associations() const noexcept -> uint32_t
Get peak concurrent associations.
std::array< category_metrics, category_count > category_metrics_
std::atomic< uint32_t > active_associations_
void record_operation_completion(job_category category, uint64_t latency_ns, bool success) noexcept
Record an operation completion.
pipeline_metrics & operator=(pipeline_metrics &&)=delete
job_category
Categories for pipeline jobs used in metrics and monitoring.
pipeline_stage
Identifies the 6 stages of the DICOM I/O pipeline.
@ stage_count
Total number of stages.
Job type definitions for the 6-stage DICOM I/O pipeline.
Metrics for a job category (e.g., C-STORE, C-FIND)
std::atomic< uint64_t > min_latency_ns
Minimum end-to-end latency observed (initialized to max)
std::atomic< uint64_t > max_latency_ns
Maximum end-to-end latency observed.
auto get_avg_latency_ns() const noexcept -> uint64_t
Get average latency in nanoseconds.
std::atomic< uint64_t > total_operations
Total operations of this category.
void reset() noexcept
Reset all metrics.
void record_operation(uint64_t latency_ns, bool success) noexcept
Record an operation completion.
std::atomic< uint64_t > successful_operations
Successful operations.
std::atomic< uint64_t > failed_operations
Failed operations.
std::atomic< uint64_t > total_latency_ns
Total end-to-end latency in nanoseconds.
Metrics for a single pipeline stage.
std::atomic< uint64_t > jobs_processed
Total jobs processed by this stage.
void reset() noexcept
Reset all metrics to zero.
std::atomic< uint64_t > jobs_queued
Total jobs currently in queue for this stage.
std::atomic< uint32_t > active_workers
Number of active workers in this stage.
std::atomic< uint64_t > total_processing_time_ns
Cumulative processing time in nanoseconds.
void record_job_completion(uint64_t processing_time_ns, bool success) noexcept
Record a job completion.
std::atomic< uint64_t > max_processing_time_ns
Maximum processing time observed (nanoseconds)
std::atomic< uint32_t > idle_workers
Number of idle workers in this stage.
std::atomic< uint64_t > jobs_failed
Jobs that failed in this stage.
auto get_avg_processing_time_ns() const noexcept -> uint64_t
Get average processing time in nanoseconds.