PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::monitoring::dicom_metrics_collector Class Reference

CRTP-based unified DICOM metrics collector. More...

#include <dicom_metrics_collector.h>

Inheritance diagram for kcenon::pacs::monitoring::dicom_metrics_collector:
Inheritance graph
Collaboration diagram for kcenon::pacs::monitoring::dicom_metrics_collector:
Collaboration graph

Public Member Functions

 dicom_metrics_collector ()=default
 Default constructor.
 
 dicom_metrics_collector (std::string ae_title)
 Constructor with AE title.
 
 ~dicom_metrics_collector () override=default
 Destructor.
 
 dicom_metrics_collector (const dicom_metrics_collector &)=delete
 
dicom_metrics_collectoroperator= (const dicom_metrics_collector &)=delete
 
 dicom_metrics_collector (dicom_metrics_collector &&)=delete
 
dicom_metrics_collectoroperator= (dicom_metrics_collector &&)=delete
 
bool do_initialize (const config_map &config)
 Collector-specific initialization.
 
std::vector< dicom_metricdo_collect ()
 Collect all DICOM metrics.
 
bool is_available () const
 Check if DICOM metrics collection is available.
 
std::vector< std::string > do_get_metric_types () const
 Get supported metric types.
 
void do_add_statistics (stats_map &stats) const
 Add collector-specific statistics.
 
dicom_metrics_snapshot get_snapshot () const
 Get a snapshot of current metrics.
 
dicom_metrics_snapshot get_last_snapshot () const
 Get last collected snapshot.
 
void set_collect_associations (bool enabled)
 Enable or disable association metrics collection.
 
void set_collect_transfers (bool enabled)
 Enable or disable transfer metrics collection.
 
void set_collect_storage (bool enabled)
 Enable or disable storage metrics collection.
 
void set_collect_queries (bool enabled)
 Enable or disable query metrics collection.
 
void set_collect_pools (bool enabled)
 Enable or disable pool metrics collection.
 
- Public Member Functions inherited from kcenon::pacs::monitoring::dicom_collector_base< dicom_metrics_collector >
 dicom_collector_base ()=default
 
 dicom_collector_base (const dicom_collector_base &)=delete
 
 dicom_collector_base (dicom_collector_base &&)=delete
 
virtual ~dicom_collector_base ()=default
 
dicom_collector_baseoperator= (const dicom_collector_base &)=delete
 
dicom_collector_baseoperator= (dicom_collector_base &&)=delete
 
bool initialize (const config_map &config)
 Initialize the collector with configuration.
 
std::vector< dicom_metriccollect ()
 Collect metrics from the data source.
 
std::string get_name () const
 Get the name of this collector.
 
std::vector< std::string > get_metric_types () const
 Get supported metric types.
 
bool is_healthy () const
 Check if the collector is healthy.
 
stats_map get_statistics () const
 Get collector statistics.
 
bool is_enabled () const
 Check if collector is enabled.
 
std::size_t get_collection_count () const
 Get collection count.
 
std::size_t get_collection_errors () const
 Get error count.
 
std::string get_ae_title () const
 Get the AE title.
 
void set_ae_title (std::string ae_title)
 Set the AE title.
 

Static Public Attributes

static constexpr const char * collector_name = "dicom_metrics_collector"
 Collector name for CRTP base class.
 

Private Member Functions

void collect_association_metrics (std::vector< dicom_metric > &metrics)
 
void collect_transfer_metrics (std::vector< dicom_metric > &metrics)
 
void collect_storage_metrics (std::vector< dicom_metric > &metrics)
 
void collect_query_metrics (std::vector< dicom_metric > &metrics)
 
void collect_pool_metrics (std::vector< dicom_metric > &metrics)
 
void collect_dimse_operation_metrics (std::vector< dicom_metric > &metrics, const std::string &op_name, const operation_counter &counter)
 

Private Attributes

bool collect_associations_ {true}
 
bool collect_transfers_ {true}
 
bool collect_storage_ {true}
 
bool collect_queries_ {true}
 
bool collect_pools_ {true}
 
std::mutex snapshot_mutex_
 
dicom_metrics_snapshot last_snapshot_
 

Additional Inherited Members

- Protected Member Functions inherited from kcenon::pacs::monitoring::dicom_collector_base< dicom_metrics_collector >
dicom_metric create_base_metric (const std::string &name, double value, const std::string &type, const std::unordered_map< std::string, std::string > &extra_tags={}) const
 Create a metric with common tags.
 
- Protected Attributes inherited from kcenon::pacs::monitoring::dicom_collector_base< dicom_metrics_collector >
bool enabled_
 
std::string ae_title_
 
std::mutex stats_mutex_
 
std::atomic< std::size_t > collection_count_
 
std::atomic< std::size_t > collection_errors_
 
std::chrono::steady_clock::time_point init_time_
 
std::chrono::system_clock::time_point last_collection_time_
 

Detailed Description

CRTP-based unified DICOM metrics collector.

This collector gathers all DICOM-related metrics in a single, efficient collection pass, following the monitoring_system's CRTP collector pattern.

Collected metrics include:

  • Association metrics (opened, closed, duration)
  • Transfer metrics (images, bytes, rate)
  • Storage metrics (operations, latency)
  • Query metrics (C-FIND, C-MOVE)
  • Pool metrics (element, dataset, PDU buffer)

Performance targets (based on monitoring_system benchmarks):

  • Metric collection: < 100ns per operation
  • Memory overhead: < 1MB for counters
  • CPU overhead: < 1% at 1000 ops/sec

Thread Safety: All public methods are thread-safe.

Definition at line 108 of file dicom_metrics_collector.h.

Constructor & Destructor Documentation

◆ dicom_metrics_collector() [1/4]

kcenon::pacs::monitoring::dicom_metrics_collector::dicom_metrics_collector ( )
default

◆ dicom_metrics_collector() [2/4]

kcenon::pacs::monitoring::dicom_metrics_collector::dicom_metrics_collector ( std::string ae_title)
inlineexplicit

Constructor with AE title.

Parameters
ae_titleApplication Entity title for metric labels

Definition at line 258 of file dicom_metrics_collector.h.

References kcenon::pacs::monitoring::dicom_collector_base< dicom_metrics_collector >::ae_title_.

◆ ~dicom_metrics_collector()

kcenon::pacs::monitoring::dicom_metrics_collector::~dicom_metrics_collector ( )
overridedefault

◆ dicom_metrics_collector() [3/4]

kcenon::pacs::monitoring::dicom_metrics_collector::dicom_metrics_collector ( const dicom_metrics_collector & )
delete

◆ dicom_metrics_collector() [4/4]

kcenon::pacs::monitoring::dicom_metrics_collector::dicom_metrics_collector ( dicom_metrics_collector && )
delete

Member Function Documentation

◆ collect_association_metrics()

void kcenon::pacs::monitoring::dicom_metrics_collector::collect_association_metrics ( std::vector< dicom_metric > & metrics)
inlineprivate
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 435 of file dicom_metrics_collector.h.

436 {
437
438 const auto& assoc = pacs_metrics::global_metrics().associations();
439
440 // Active associations (gauge)
441 metrics.push_back(create_base_metric(
442 "dicom_associations_active",
443 static_cast<double>(assoc.current_active.load(std::memory_order_relaxed)),
444 "gauge"));
445
446 // Peak active associations (gauge)
447 metrics.push_back(create_base_metric(
448 "dicom_associations_peak",
449 static_cast<double>(assoc.peak_active.load(std::memory_order_relaxed)),
450 "gauge"));
451
452 // Total established (counter)
453 metrics.push_back(create_base_metric(
454 "dicom_associations_total",
455 static_cast<double>(assoc.total_established.load(std::memory_order_relaxed)),
456 "counter"));
457
458 // Rejected (counter)
459 metrics.push_back(create_base_metric(
460 "dicom_associations_rejected_total",
461 static_cast<double>(assoc.total_rejected.load(std::memory_order_relaxed)),
462 "counter"));
463
464 // Aborted (counter)
465 metrics.push_back(create_base_metric(
466 "dicom_associations_aborted_total",
467 static_cast<double>(assoc.total_aborted.load(std::memory_order_relaxed)),
468 "counter"));
469
470 // Success rate (gauge)
471 const auto total = assoc.total_established.load(std::memory_order_relaxed);
472 const auto rejected = assoc.total_rejected.load(std::memory_order_relaxed);
473 const auto attempted = total + rejected;
474 const double success_rate = (attempted > 0)
475 ? static_cast<double>(total) / static_cast<double>(attempted)
476 : 1.0;
477
478 metrics.push_back(create_base_metric(
479 "dicom_associations_success_rate",
480 success_rate,
481 "gauge"));
482}
dicom_metric create_base_metric(const std::string &name, double value, const std::string &type, const std::unordered_map< std::string, std::string > &extra_tags={}) const
static pacs_metrics & global_metrics() noexcept
Get the global singleton instance.
const association_counters & associations() const noexcept
Get association counters.

References kcenon::pacs::monitoring::pacs_metrics::associations(), kcenon::pacs::monitoring::dicom_collector_base< dicom_metrics_collector >::create_base_metric(), and kcenon::pacs::monitoring::pacs_metrics::global_metrics().

Referenced by do_collect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_dimse_operation_metrics()

void kcenon::pacs::monitoring::dicom_metrics_collector::collect_dimse_operation_metrics ( std::vector< dicom_metric > & metrics,
const std::string & op_name,
const operation_counter & counter )
inlineprivate
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 629 of file dicom_metrics_collector.h.

632 {
633
634 std::unordered_map<std::string, std::string> op_tags{{"operation", op_name}};
635
636 // Total requests (counter)
637 metrics.push_back(create_base_metric(
638 "dicom_" + op_name + "_total",
639 static_cast<double>(counter.total_count()),
640 "counter",
641 op_tags));
642
643 // Successful requests (counter)
644 metrics.push_back(create_base_metric(
645 "dicom_" + op_name + "_success_total",
646 static_cast<double>(counter.success_count.load(std::memory_order_relaxed)),
647 "counter",
648 op_tags));
649
650 // Failed requests (counter)
651 metrics.push_back(create_base_metric(
652 "dicom_" + op_name + "_failure_total",
653 static_cast<double>(counter.failure_count.load(std::memory_order_relaxed)),
654 "counter",
655 op_tags));
656
657 // Duration metrics (only if there have been requests)
658 if (counter.total_count() > 0) {
659 // Average duration in seconds (gauge)
660 metrics.push_back(create_base_metric(
661 "dicom_" + op_name + "_duration_seconds_avg",
662 static_cast<double>(counter.average_duration_us()) / 1'000'000.0,
663 "gauge",
664 op_tags));
665
666 // Total duration in seconds (counter) - for rate calculations
667 metrics.push_back(create_base_metric(
668 "dicom_" + op_name + "_duration_seconds_sum",
669 static_cast<double>(counter.total_duration_us.load(std::memory_order_relaxed)) / 1'000'000.0,
670 "counter",
671 op_tags));
672
673 // Min duration (gauge)
674 const auto min_us = counter.min_duration_us.load(std::memory_order_relaxed);
675 if (min_us != UINT64_MAX) {
676 metrics.push_back(create_base_metric(
677 "dicom_" + op_name + "_duration_seconds_min",
678 static_cast<double>(min_us) / 1'000'000.0,
679 "gauge",
680 op_tags));
681 }
682
683 // Max duration (gauge)
684 const auto max_us = counter.max_duration_us.load(std::memory_order_relaxed);
685 if (max_us > 0) {
686 metrics.push_back(create_base_metric(
687 "dicom_" + op_name + "_duration_seconds_max",
688 static_cast<double>(max_us) / 1'000'000.0,
689 "gauge",
690 op_tags));
691 }
692 }
693}
@ counter
Monotonic increasing value.

References kcenon::pacs::monitoring::counter.

Referenced by collect_query_metrics(), and collect_storage_metrics().

Here is the caller graph for this function:

◆ collect_pool_metrics()

void kcenon::pacs::monitoring::dicom_metrics_collector::collect_pool_metrics ( std::vector< dicom_metric > & metrics)
inlineprivate
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 554 of file dicom_metrics_collector.h.

555 {
556
557 const auto& pacs = pacs_metrics::global_metrics();
558
559 // Element pool
560 const auto& elem_pool = pacs.element_pool();
561 metrics.push_back(create_base_metric(
562 "dicom_element_pool_acquisitions_total",
563 static_cast<double>(elem_pool.total_acquisitions.load(std::memory_order_relaxed)),
564 "counter",
565 {{"pool", "element"}}));
566 metrics.push_back(create_base_metric(
567 "dicom_element_pool_hits_total",
568 static_cast<double>(elem_pool.pool_hits.load(std::memory_order_relaxed)),
569 "counter",
570 {{"pool", "element"}}));
571 metrics.push_back(create_base_metric(
572 "dicom_element_pool_misses_total",
573 static_cast<double>(elem_pool.pool_misses.load(std::memory_order_relaxed)),
574 "counter",
575 {{"pool", "element"}}));
576 metrics.push_back(create_base_metric(
577 "dicom_element_pool_hit_ratio",
578 elem_pool.hit_ratio(),
579 "gauge",
580 {{"pool", "element"}}));
581
582 // Dataset pool
583 const auto& ds_pool = pacs.dataset_pool();
584 metrics.push_back(create_base_metric(
585 "dicom_dataset_pool_acquisitions_total",
586 static_cast<double>(ds_pool.total_acquisitions.load(std::memory_order_relaxed)),
587 "counter",
588 {{"pool", "dataset"}}));
589 metrics.push_back(create_base_metric(
590 "dicom_dataset_pool_hits_total",
591 static_cast<double>(ds_pool.pool_hits.load(std::memory_order_relaxed)),
592 "counter",
593 {{"pool", "dataset"}}));
594 metrics.push_back(create_base_metric(
595 "dicom_dataset_pool_misses_total",
596 static_cast<double>(ds_pool.pool_misses.load(std::memory_order_relaxed)),
597 "counter",
598 {{"pool", "dataset"}}));
599 metrics.push_back(create_base_metric(
600 "dicom_dataset_pool_hit_ratio",
601 ds_pool.hit_ratio(),
602 "gauge",
603 {{"pool", "dataset"}}));
604
605 // PDU buffer pool
606 const auto& pdu_pool = pacs.pdu_buffer_pool();
607 metrics.push_back(create_base_metric(
608 "dicom_pdu_buffer_pool_acquisitions_total",
609 static_cast<double>(pdu_pool.total_acquisitions.load(std::memory_order_relaxed)),
610 "counter",
611 {{"pool", "pdu_buffer"}}));
612 metrics.push_back(create_base_metric(
613 "dicom_pdu_buffer_pool_hits_total",
614 static_cast<double>(pdu_pool.pool_hits.load(std::memory_order_relaxed)),
615 "counter",
616 {{"pool", "pdu_buffer"}}));
617 metrics.push_back(create_base_metric(
618 "dicom_pdu_buffer_pool_misses_total",
619 static_cast<double>(pdu_pool.pool_misses.load(std::memory_order_relaxed)),
620 "counter",
621 {{"pool", "pdu_buffer"}}));
622 metrics.push_back(create_base_metric(
623 "dicom_pdu_buffer_pool_hit_ratio",
624 pdu_pool.hit_ratio(),
625 "gauge",
626 {{"pool", "pdu_buffer"}}));
627}

References kcenon::pacs::monitoring::dicom_collector_base< dicom_metrics_collector >::create_base_metric(), and kcenon::pacs::monitoring::pacs_metrics::global_metrics().

Referenced by do_collect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_query_metrics()

void kcenon::pacs::monitoring::dicom_metrics_collector::collect_query_metrics ( std::vector< dicom_metric > & metrics)
inlineprivate
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 524 of file dicom_metrics_collector.h.

525 {
526
527 const auto& pacs = pacs_metrics::global_metrics();
528
529 // All query-related DIMSE operations
531 metrics, "c_echo", pacs.get_counter(dimse_operation::c_echo));
533 metrics, "c_find", pacs.get_counter(dimse_operation::c_find));
535 metrics, "c_move", pacs.get_counter(dimse_operation::c_move));
537 metrics, "c_get", pacs.get_counter(dimse_operation::c_get));
538
539 // N-services
541 metrics, "n_create", pacs.get_counter(dimse_operation::n_create));
543 metrics, "n_set", pacs.get_counter(dimse_operation::n_set));
545 metrics, "n_get", pacs.get_counter(dimse_operation::n_get));
547 metrics, "n_action", pacs.get_counter(dimse_operation::n_action));
549 metrics, "n_event", pacs.get_counter(dimse_operation::n_event));
551 metrics, "n_delete", pacs.get_counter(dimse_operation::n_delete));
552}
void collect_dimse_operation_metrics(std::vector< dicom_metric > &metrics, const std::string &op_name, const operation_counter &counter)
@ c_move
C-MOVE (Retrieve Service)
@ c_echo
C-ECHO (Verification Service)

References kcenon::pacs::monitoring::c_echo, kcenon::pacs::monitoring::c_find, kcenon::pacs::monitoring::c_get, kcenon::pacs::monitoring::c_move, collect_dimse_operation_metrics(), kcenon::pacs::monitoring::pacs_metrics::global_metrics(), kcenon::pacs::monitoring::n_action, kcenon::pacs::monitoring::n_create, kcenon::pacs::monitoring::n_delete, kcenon::pacs::monitoring::n_event, kcenon::pacs::monitoring::n_get, and kcenon::pacs::monitoring::n_set.

Referenced by do_collect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_storage_metrics()

void kcenon::pacs::monitoring::dicom_metrics_collector::collect_storage_metrics ( std::vector< dicom_metric > & metrics)
inlineprivate
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 514 of file dicom_metrics_collector.h.

515 {
516
517 const auto& pacs = pacs_metrics::global_metrics();
518
519 // C-STORE operation metrics
521 metrics, "c_store", pacs.get_counter(dimse_operation::c_store));
522}
@ c_store
C-STORE (Storage Service)

References kcenon::pacs::monitoring::c_store, collect_dimse_operation_metrics(), and kcenon::pacs::monitoring::pacs_metrics::global_metrics().

Referenced by do_collect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_transfer_metrics()

void kcenon::pacs::monitoring::dicom_metrics_collector::collect_transfer_metrics ( std::vector< dicom_metric > & metrics)
inlineprivate
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 484 of file dicom_metrics_collector.h.

485 {
486
487 const auto& transfer = pacs_metrics::global_metrics().transfer();
488
489 // Images stored (counter)
490 metrics.push_back(create_base_metric(
491 "dicom_images_stored_total",
492 static_cast<double>(transfer.images_stored.load(std::memory_order_relaxed)),
493 "counter"));
494
495 // Images retrieved (counter)
496 metrics.push_back(create_base_metric(
497 "dicom_images_retrieved_total",
498 static_cast<double>(transfer.images_retrieved.load(std::memory_order_relaxed)),
499 "counter"));
500
501 // Bytes sent (counter)
502 metrics.push_back(create_base_metric(
503 "dicom_bytes_sent_total",
504 static_cast<double>(transfer.bytes_sent.load(std::memory_order_relaxed)),
505 "counter"));
506
507 // Bytes received (counter)
508 metrics.push_back(create_base_metric(
509 "dicom_bytes_received_total",
510 static_cast<double>(transfer.bytes_received.load(std::memory_order_relaxed)),
511 "counter"));
512}
const data_transfer_metrics & transfer() const noexcept
Get data transfer metrics.

References kcenon::pacs::monitoring::dicom_collector_base< dicom_metrics_collector >::create_base_metric(), kcenon::pacs::monitoring::pacs_metrics::global_metrics(), and kcenon::pacs::monitoring::pacs_metrics::transfer().

Referenced by do_collect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_add_statistics()

void kcenon::pacs::monitoring::dicom_metrics_collector::do_add_statistics ( stats_map & stats) const
inline

Add collector-specific statistics.

Parameters
statsMap to add statistics to
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 348 of file dicom_metrics_collector.h.

348 {
349 std::lock_guard<std::mutex> lock(snapshot_mutex_);
350
351 stats["active_associations"] =
352 static_cast<double>(last_snapshot_.active_associations);
353 stats["total_images_processed"] =
355 stats["total_bytes_transferred"] =
357}

References kcenon::pacs::monitoring::dicom_metrics_snapshot::active_associations, kcenon::pacs::monitoring::dicom_metrics_snapshot::bytes_received, kcenon::pacs::monitoring::dicom_metrics_snapshot::bytes_sent, kcenon::pacs::monitoring::dicom_metrics_snapshot::images_received, kcenon::pacs::monitoring::dicom_metrics_snapshot::images_sent, last_snapshot_, and snapshot_mutex_.

◆ do_collect()

std::vector< dicom_metric > kcenon::pacs::monitoring::dicom_metrics_collector::do_collect ( )
inline

Collect all DICOM metrics.

Returns
Vector of collected metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 283 of file dicom_metrics_collector.h.

283 {
284 std::vector<dicom_metric> metrics;
285 metrics.reserve(64); // Pre-allocate for typical metric count
286
289 }
290 if (collect_transfers_) {
292 }
293 if (collect_storage_) {
295 }
296 if (collect_queries_) {
297 collect_query_metrics(metrics);
298 }
299 if (collect_pools_) {
300 collect_pool_metrics(metrics);
301 }
302
303 return metrics;
304}
void collect_query_metrics(std::vector< dicom_metric > &metrics)
void collect_transfer_metrics(std::vector< dicom_metric > &metrics)
void collect_storage_metrics(std::vector< dicom_metric > &metrics)
void collect_association_metrics(std::vector< dicom_metric > &metrics)
void collect_pool_metrics(std::vector< dicom_metric > &metrics)

References collect_association_metrics(), collect_associations_, collect_pool_metrics(), collect_pools_, collect_queries_, collect_query_metrics(), collect_storage_, collect_storage_metrics(), collect_transfer_metrics(), and collect_transfers_.

Here is the call graph for this function:

◆ do_get_metric_types()

std::vector< std::string > kcenon::pacs::monitoring::dicom_metrics_collector::do_get_metric_types ( ) const
inlinenodiscard

Get supported metric types.

Returns
Vector of supported metric type names
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 310 of file dicom_metrics_collector.h.

310 {
311 std::vector<std::string> types;
312
313 // Association metrics
314 types.push_back("dicom_associations_active");
315 types.push_back("dicom_associations_peak");
316 types.push_back("dicom_associations_total");
317 types.push_back("dicom_associations_rejected_total");
318 types.push_back("dicom_associations_aborted_total");
319
320 // Transfer metrics
321 types.push_back("dicom_images_sent_total");
322 types.push_back("dicom_images_received_total");
323 types.push_back("dicom_bytes_sent_total");
324 types.push_back("dicom_bytes_received_total");
325 types.push_back("dicom_transfer_rate_mbps");
326
327 // DIMSE operation metrics
328 static constexpr std::array<const char*, 11> ops = {
329 "c_echo", "c_store", "c_find", "c_move", "c_get",
330 "n_create", "n_set", "n_get", "n_action", "n_event", "n_delete"
331 };
332 for (const auto* op : ops) {
333 types.push_back(std::string("dicom_") + op + "_total");
334 types.push_back(std::string("dicom_") + op + "_success_total");
335 types.push_back(std::string("dicom_") + op + "_failure_total");
336 types.push_back(std::string("dicom_") + op + "_duration_seconds");
337 }
338
339 // Pool metrics
340 types.push_back("dicom_element_pool_hits");
341 types.push_back("dicom_element_pool_misses");
342 types.push_back("dicom_dataset_pool_hits");
343 types.push_back("dicom_dataset_pool_misses");
344
345 return types;
346}

◆ do_initialize()

bool kcenon::pacs::monitoring::dicom_metrics_collector::do_initialize ( const config_map & config)
inline

Collector-specific initialization.

Parameters
configConfiguration options:
  • "collect_associations": "true"/"false" (default: true)
  • "collect_transfers": "true"/"false" (default: true)
  • "collect_storage": "true"/"false" (default: true)
  • "collect_queries": "true"/"false" (default: true)
  • "collect_pools": "true"/"false" (default: true)
Returns
true if initialization successful
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 262 of file dicom_metrics_collector.h.

262 {
263 // Parse collection configuration
264 if (auto it = config.find("collect_associations"); it != config.end()) {
265 collect_associations_ = (it->second == "true" || it->second == "1");
266 }
267 if (auto it = config.find("collect_transfers"); it != config.end()) {
268 collect_transfers_ = (it->second == "true" || it->second == "1");
269 }
270 if (auto it = config.find("collect_storage"); it != config.end()) {
271 collect_storage_ = (it->second == "true" || it->second == "1");
272 }
273 if (auto it = config.find("collect_queries"); it != config.end()) {
274 collect_queries_ = (it->second == "true" || it->second == "1");
275 }
276 if (auto it = config.find("collect_pools"); it != config.end()) {
277 collect_pools_ = (it->second == "true" || it->second == "1");
278 }
279
280 return true;
281}

References collect_associations_, collect_pools_, collect_queries_, collect_storage_, and collect_transfers_.

◆ get_last_snapshot()

dicom_metrics_snapshot kcenon::pacs::monitoring::dicom_metrics_collector::get_last_snapshot ( ) const
inlinenodiscard

Get last collected snapshot.

Returns
Last metrics snapshot (thread-safe copy)
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 410 of file dicom_metrics_collector.h.

410 {
411 std::lock_guard<std::mutex> lock(snapshot_mutex_);
412 return last_snapshot_;
413}

References last_snapshot_, and snapshot_mutex_.

◆ get_snapshot()

dicom_metrics_snapshot kcenon::pacs::monitoring::dicom_metrics_collector::get_snapshot ( ) const
inlinenodiscard

Get a snapshot of current metrics.

Returns
Metrics snapshot
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 359 of file dicom_metrics_collector.h.

359 {
360 dicom_metrics_snapshot snapshot;
361 snapshot.timestamp = std::chrono::system_clock::now();
362
363 const auto& pacs = pacs_metrics::global_metrics();
364 const auto& assoc = pacs.associations();
365 const auto& transfer = pacs.transfer();
366
367 // Association metrics
368 snapshot.total_associations =
369 assoc.total_established.load(std::memory_order_relaxed);
370 snapshot.active_associations =
371 assoc.current_active.load(std::memory_order_relaxed);
372 snapshot.failed_associations =
373 assoc.total_rejected.load(std::memory_order_relaxed) +
374 assoc.total_aborted.load(std::memory_order_relaxed);
375 snapshot.peak_active_associations =
376 assoc.peak_active.load(std::memory_order_relaxed);
377
378 // Transfer metrics
379 snapshot.images_sent = 0; // Not tracked separately
380 snapshot.images_received =
381 transfer.images_stored.load(std::memory_order_relaxed);
382 snapshot.bytes_sent =
383 transfer.bytes_sent.load(std::memory_order_relaxed);
384 snapshot.bytes_received =
385 transfer.bytes_received.load(std::memory_order_relaxed);
386
387 // Storage metrics (from C-STORE counter)
388 const auto& store = pacs.get_counter(dimse_operation::c_store);
389 snapshot.store_operations = store.total_count();
390 snapshot.successful_stores =
391 store.success_count.load(std::memory_order_relaxed);
392 snapshot.failed_stores =
393 store.failure_count.load(std::memory_order_relaxed);
394 snapshot.avg_store_latency_ms =
395 static_cast<double>(store.average_duration_us()) / 1000.0;
396
397 // Query metrics (from C-FIND counter)
398 const auto& query = pacs.get_counter(dimse_operation::c_find);
399 snapshot.query_operations = query.total_count();
400 snapshot.successful_queries =
401 query.success_count.load(std::memory_order_relaxed);
402 snapshot.failed_queries =
403 query.failure_count.load(std::memory_order_relaxed);
404 snapshot.avg_query_latency_ms =
405 static_cast<double>(query.average_duration_us()) / 1000.0;
406
407 return snapshot;
408}
@ store
C-STORE operation.
const atna_coded_value query
Query (110112)

References kcenon::pacs::monitoring::dicom_metrics_snapshot::active_associations, kcenon::pacs::monitoring::dicom_metrics_snapshot::avg_query_latency_ms, kcenon::pacs::monitoring::dicom_metrics_snapshot::avg_store_latency_ms, kcenon::pacs::monitoring::dicom_metrics_snapshot::bytes_received, kcenon::pacs::monitoring::dicom_metrics_snapshot::bytes_sent, kcenon::pacs::monitoring::c_find, kcenon::pacs::monitoring::c_store, kcenon::pacs::monitoring::dicom_metrics_snapshot::failed_associations, kcenon::pacs::monitoring::dicom_metrics_snapshot::failed_queries, kcenon::pacs::monitoring::dicom_metrics_snapshot::failed_stores, kcenon::pacs::monitoring::pacs_metrics::global_metrics(), kcenon::pacs::monitoring::dicom_metrics_snapshot::images_received, kcenon::pacs::monitoring::dicom_metrics_snapshot::images_sent, kcenon::pacs::monitoring::dicom_metrics_snapshot::peak_active_associations, kcenon::pacs::monitoring::dicom_metrics_snapshot::query_operations, kcenon::pacs::monitoring::dicom_metrics_snapshot::store_operations, kcenon::pacs::monitoring::dicom_metrics_snapshot::successful_queries, kcenon::pacs::monitoring::dicom_metrics_snapshot::successful_stores, kcenon::pacs::monitoring::dicom_metrics_snapshot::timestamp, and kcenon::pacs::monitoring::dicom_metrics_snapshot::total_associations.

Here is the call graph for this function:

◆ is_available()

bool kcenon::pacs::monitoring::dicom_metrics_collector::is_available ( ) const
inlinenodiscard

Check if DICOM metrics collection is available.

Returns
true (always available as pacs_metrics is always present)
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 306 of file dicom_metrics_collector.h.

306 {
307 return true; // pacs_metrics singleton is always available
308}

◆ operator=() [1/2]

◆ operator=() [2/2]

dicom_metrics_collector & kcenon::pacs::monitoring::dicom_metrics_collector::operator= ( dicom_metrics_collector && )
delete

◆ set_collect_associations()

void kcenon::pacs::monitoring::dicom_metrics_collector::set_collect_associations ( bool enabled)
inline

Enable or disable association metrics collection.

Parameters
enabledWhether to collect association metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 415 of file dicom_metrics_collector.h.

415 {
416 collect_associations_ = enabled;
417}

References collect_associations_.

◆ set_collect_pools()

void kcenon::pacs::monitoring::dicom_metrics_collector::set_collect_pools ( bool enabled)
inline

Enable or disable pool metrics collection.

Parameters
enabledWhether to collect pool metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 431 of file dicom_metrics_collector.h.

431 {
432 collect_pools_ = enabled;
433}

References collect_pools_.

◆ set_collect_queries()

void kcenon::pacs::monitoring::dicom_metrics_collector::set_collect_queries ( bool enabled)
inline

Enable or disable query metrics collection.

Parameters
enabledWhether to collect query metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 427 of file dicom_metrics_collector.h.

427 {
428 collect_queries_ = enabled;
429}

References collect_queries_.

◆ set_collect_storage()

void kcenon::pacs::monitoring::dicom_metrics_collector::set_collect_storage ( bool enabled)
inline

Enable or disable storage metrics collection.

Parameters
enabledWhether to collect storage metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 423 of file dicom_metrics_collector.h.

423 {
424 collect_storage_ = enabled;
425}

References collect_storage_.

◆ set_collect_transfers()

void kcenon::pacs::monitoring::dicom_metrics_collector::set_collect_transfers ( bool enabled)
inline

Enable or disable transfer metrics collection.

Parameters
enabledWhether to collect transfer metrics
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h.

Definition at line 419 of file dicom_metrics_collector.h.

419 {
420 collect_transfers_ = enabled;
421}

References collect_transfers_.

Member Data Documentation

◆ collect_associations_

bool kcenon::pacs::monitoring::dicom_metrics_collector::collect_associations_ {true}
private

◆ collect_pools_

bool kcenon::pacs::monitoring::dicom_metrics_collector::collect_pools_ {true}
private

◆ collect_queries_

bool kcenon::pacs::monitoring::dicom_metrics_collector::collect_queries_ {true}
private

◆ collect_storage_

bool kcenon::pacs::monitoring::dicom_metrics_collector::collect_storage_ {true}
private

◆ collect_transfers_

bool kcenon::pacs::monitoring::dicom_metrics_collector::collect_transfers_ {true}
private

◆ collector_name

const char* kcenon::pacs::monitoring::dicom_metrics_collector::collector_name = "dicom_metrics_collector"
staticconstexpr

◆ last_snapshot_

dicom_metrics_snapshot kcenon::pacs::monitoring::dicom_metrics_collector::last_snapshot_
private

◆ snapshot_mutex_

std::mutex kcenon::pacs::monitoring::dicom_metrics_collector::snapshot_mutex_
mutableprivate

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