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

Central metrics collection for PACS DICOM operations. More...

#include <pacs_metrics.h>

Collaboration diagram for kcenon::pacs::monitoring::pacs_metrics:
Collaboration graph

Public Member Functions

 pacs_metrics ()=default
 Default constructor.
 
 pacs_metrics (const pacs_metrics &)=delete
 Non-copyable.
 
pacs_metricsoperator= (const pacs_metrics &)=delete
 
 pacs_metrics (pacs_metrics &&)=delete
 Non-movable (singleton)
 
pacs_metricsoperator= (pacs_metrics &&)=delete
 
void record_store (bool success, std::chrono::microseconds duration, std::uint64_t bytes_stored=0) noexcept
 Record a C-STORE operation.
 
void record_query (bool success, std::chrono::microseconds duration, std::uint32_t matches=0) noexcept
 Record a C-FIND (query) operation.
 
void record_echo (bool success, std::chrono::microseconds duration) noexcept
 Record a C-ECHO (verification) operation.
 
void record_move (bool success, std::chrono::microseconds duration, std::uint32_t images_moved=0) noexcept
 Record a C-MOVE operation.
 
void record_get (bool success, std::chrono::microseconds duration, std::uint32_t images_retrieved=0, std::uint64_t bytes_retrieved=0) noexcept
 Record a C-GET operation.
 
void record_operation (dimse_operation op, bool success, std::chrono::microseconds duration) noexcept
 Record a generic DIMSE operation.
 
void record_bytes_sent (std::uint64_t bytes) noexcept
 Record bytes sent over the network.
 
void record_bytes_received (std::uint64_t bytes) noexcept
 Record bytes received from the network.
 
void record_association_established () noexcept
 Record an association being established.
 
void record_association_released () noexcept
 Record an association being released.
 
void record_association_rejected () noexcept
 Record an association being rejected.
 
void record_association_aborted () noexcept
 Record an association being aborted.
 
const operation_counterget_counter (dimse_operation op) const noexcept
 Get operation counter for a specific DIMSE operation.
 
operation_counterget_counter (dimse_operation op) noexcept
 Get mutable operation counter for a specific DIMSE operation.
 
const data_transfer_metricstransfer () const noexcept
 Get data transfer metrics.
 
const association_countersassociations () const noexcept
 Get association counters.
 
const pool_counterselement_pool () const noexcept
 Get element pool counters.
 
pool_counterselement_pool () noexcept
 Get mutable element pool counters.
 
const pool_countersdataset_pool () const noexcept
 Get dataset pool counters.
 
pool_countersdataset_pool () noexcept
 Get mutable dataset pool counters.
 
const pool_counterspdu_buffer_pool () const noexcept
 Get PDU buffer pool counters.
 
pool_counterspdu_buffer_pool () noexcept
 Get mutable PDU buffer pool counters.
 
std::string to_json () const
 Export metrics as JSON string.
 
std::string to_prometheus (std::string_view prefix="pacs") const
 Export metrics in Prometheus text format.
 
void reset () noexcept
 Reset all metrics to zero.
 

Static Public Member Functions

static pacs_metricsglobal_metrics () noexcept
 Get the global singleton instance.
 

Private Attributes

operation_counter c_echo_
 
operation_counter c_store_
 
operation_counter c_find_
 
operation_counter c_move_
 
operation_counter c_get_
 
operation_counter n_create_
 
operation_counter n_set_
 
operation_counter n_get_
 
operation_counter n_action_
 
operation_counter n_event_
 
operation_counter n_delete_
 
data_transfer_metrics transfer_
 
association_counters associations_
 
pool_counters element_pool_
 
pool_counters dataset_pool_
 
pool_counters pdu_buffer_pool_
 

Detailed Description

Central metrics collection for PACS DICOM operations.

The pacs_metrics class provides a thread-safe, low-overhead mechanism for tracking DICOM operation metrics including:

  • DIMSE operation counts and timing (C-ECHO, C-STORE, C-FIND, C-MOVE, C-GET)
  • Data transfer volumes (bytes sent/received, images stored/retrieved)
  • Association lifecycle events (established, rejected, aborted)

Thread Safety: All public methods are thread-safe using atomic operations.

Definition at line 354 of file pacs_metrics.h.

Constructor & Destructor Documentation

◆ pacs_metrics() [1/3]

kcenon::pacs::monitoring::pacs_metrics::pacs_metrics ( )
default

◆ pacs_metrics() [2/3]

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

Non-copyable.

◆ pacs_metrics() [3/3]

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

Non-movable (singleton)

Member Function Documentation

◆ associations()

◆ dataset_pool() [1/2]

const pool_counters & kcenon::pacs::monitoring::pacs_metrics::dataset_pool ( ) const
inlinenodiscardnoexcept

Get dataset pool counters.

Returns
Const reference to dataset pool counters
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 637 of file pacs_metrics.h.

637 {
638 return dataset_pool_;
639 }

References dataset_pool_.

◆ dataset_pool() [2/2]

pool_counters & kcenon::pacs::monitoring::pacs_metrics::dataset_pool ( )
inlinenodiscardnoexcept

Get mutable dataset pool counters.

Returns
Reference to dataset pool counters

Definition at line 645 of file pacs_metrics.h.

645 {
646 return dataset_pool_;
647 }

References dataset_pool_.

◆ element_pool() [1/2]

const pool_counters & kcenon::pacs::monitoring::pacs_metrics::element_pool ( ) const
inlinenodiscardnoexcept

Get element pool counters.

Returns
Const reference to element pool counters
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 621 of file pacs_metrics.h.

621 {
622 return element_pool_;
623 }

References element_pool_.

◆ element_pool() [2/2]

pool_counters & kcenon::pacs::monitoring::pacs_metrics::element_pool ( )
inlinenodiscardnoexcept

Get mutable element pool counters.

Returns
Reference to element pool counters

Definition at line 629 of file pacs_metrics.h.

629 {
630 return element_pool_;
631 }

References element_pool_.

◆ get_counter() [1/2]

const operation_counter & kcenon::pacs::monitoring::pacs_metrics::get_counter ( dimse_operation op) const
inlinenodiscardnoexcept

Get operation counter for a specific DIMSE operation.

Parameters
opThe DIMSE operation type
Returns
Const reference to the operation counter
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 558 of file pacs_metrics.h.

558 {
559 switch (op) {
561 return c_echo_;
563 return c_store_;
565 return c_find_;
567 return c_move_;
569 return c_get_;
571 return n_create_;
573 return n_set_;
575 return n_get_;
577 return n_action_;
579 return n_event_;
581 return n_delete_;
582 default:
583 return c_echo_; // Should never happen
584 }
585 }
@ c_store
C-STORE (Storage Service)
@ c_move
C-MOVE (Retrieve Service)
@ c_echo
C-ECHO (Verification Service)

References kcenon::pacs::monitoring::c_echo, c_echo_, kcenon::pacs::monitoring::c_find, c_find_, kcenon::pacs::monitoring::c_get, c_get_, kcenon::pacs::monitoring::c_move, c_move_, kcenon::pacs::monitoring::c_store, c_store_, kcenon::pacs::monitoring::n_action, n_action_, kcenon::pacs::monitoring::n_create, n_create_, kcenon::pacs::monitoring::n_delete, n_delete_, kcenon::pacs::monitoring::n_event, n_event_, kcenon::pacs::monitoring::n_get, n_get_, kcenon::pacs::monitoring::n_set, and n_set_.

Referenced by get_counter(), and record_operation().

Here is the caller graph for this function:

◆ get_counter() [2/2]

operation_counter & kcenon::pacs::monitoring::pacs_metrics::get_counter ( dimse_operation op)
inlinenodiscardnoexcept

Get mutable operation counter for a specific DIMSE operation.

Parameters
opThe DIMSE operation type
Returns
Reference to the operation counter

Definition at line 592 of file pacs_metrics.h.

592 {
593 return const_cast<operation_counter&>(
594 static_cast<const pacs_metrics*>(this)->get_counter(op));
595 }

References get_counter().

Here is the call graph for this function:

◆ global_metrics()

static pacs_metrics & kcenon::pacs::monitoring::pacs_metrics::global_metrics ( )
inlinestaticnodiscardnoexcept

Get the global singleton instance.

Returns
Reference to the global metrics instance

Thread-safe lazy initialization using Meyer's singleton pattern.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_association_collector.h, /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_metrics_collector.h, /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_service_collector.h, /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/collectors/dicom_storage_collector.h, /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h, and /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_monitor.h.

Definition at line 371 of file pacs_metrics.h.

371 {
372 static pacs_metrics instance;
373 return instance;
374 }

Referenced by kcenon::pacs::monitoring::dicom_association_collector::collect(), kcenon::pacs::monitoring::dicom_service_collector::collect(), kcenon::pacs::monitoring::dicom_metrics_collector::collect_association_metrics(), kcenon::pacs::monitoring::dicom_metrics_collector::collect_pool_metrics(), kcenon::pacs::monitoring::dicom_storage_collector::collect_pool_metrics(), kcenon::pacs::monitoring::dicom_metrics_collector::collect_query_metrics(), kcenon::pacs::monitoring::dicom_metrics_collector::collect_storage_metrics(), kcenon::pacs::monitoring::dicom_metrics_collector::collect_transfer_metrics(), kcenon::pacs::monitoring::dicom_storage_collector::collect_transfer_metrics(), kcenon::pacs::monitoring::dicom_metrics_collector::get_snapshot(), kcenon::pacs::monitoring::pacs_monitor::reset(), kcenon::pacs::monitoring::pacs_monitor::to_json(), and kcenon::pacs::monitoring::pacs_monitor::to_prometheus().

Here is the caller graph for this function:

◆ operator=() [1/2]

pacs_metrics & kcenon::pacs::monitoring::pacs_metrics::operator= ( const pacs_metrics & )
delete

◆ operator=() [2/2]

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

◆ pdu_buffer_pool() [1/2]

const pool_counters & kcenon::pacs::monitoring::pacs_metrics::pdu_buffer_pool ( ) const
inlinenodiscardnoexcept

Get PDU buffer pool counters.

Returns
Const reference to PDU buffer pool counters
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 653 of file pacs_metrics.h.

653 {
654 return pdu_buffer_pool_;
655 }

References pdu_buffer_pool_.

◆ pdu_buffer_pool() [2/2]

pool_counters & kcenon::pacs::monitoring::pacs_metrics::pdu_buffer_pool ( )
inlinenodiscardnoexcept

Get mutable PDU buffer pool counters.

Returns
Reference to PDU buffer pool counters

Definition at line 661 of file pacs_metrics.h.

661 {
662 return pdu_buffer_pool_;
663 }

References pdu_buffer_pool_.

◆ record_association_aborted()

void kcenon::pacs::monitoring::pacs_metrics::record_association_aborted ( )
inlinenoexcept

Record an association being aborted.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 545 of file pacs_metrics.h.

545 {
547 }
void record_aborted() noexcept
Record an association being aborted.

References associations_, and kcenon::pacs::monitoring::association_counters::record_aborted().

Here is the call graph for this function:

◆ record_association_established()

void kcenon::pacs::monitoring::pacs_metrics::record_association_established ( )
inlinenoexcept

Record an association being established.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 524 of file pacs_metrics.h.

524 {
526 }
void record_established() noexcept
Record an association being established.

References associations_, and kcenon::pacs::monitoring::association_counters::record_established().

Here is the call graph for this function:

◆ record_association_rejected()

void kcenon::pacs::monitoring::pacs_metrics::record_association_rejected ( )
inlinenoexcept

Record an association being rejected.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 538 of file pacs_metrics.h.

538 {
540 }
void record_rejected() noexcept
Record an association being rejected.

References associations_, and kcenon::pacs::monitoring::association_counters::record_rejected().

Here is the call graph for this function:

◆ record_association_released()

void kcenon::pacs::monitoring::pacs_metrics::record_association_released ( )
inlinenoexcept

Record an association being released.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 531 of file pacs_metrics.h.

531 {
533 }
void record_released() noexcept
Record an association being released normally.

References associations_, and kcenon::pacs::monitoring::association_counters::record_released().

Here is the call graph for this function:

◆ record_bytes_received()

void kcenon::pacs::monitoring::pacs_metrics::record_bytes_received ( std::uint64_t bytes)
inlinenoexcept

Record bytes received from the network.

Parameters
bytesNumber of bytes received
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 513 of file pacs_metrics.h.

513 {
515 }
void add_bytes_received(std::uint64_t bytes) noexcept
Record bytes received.

References kcenon::pacs::monitoring::data_transfer_metrics::add_bytes_received(), and transfer_.

Here is the call graph for this function:

◆ record_bytes_sent()

void kcenon::pacs::monitoring::pacs_metrics::record_bytes_sent ( std::uint64_t bytes)
inlinenoexcept

Record bytes sent over the network.

Parameters
bytesNumber of bytes sent
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 505 of file pacs_metrics.h.

505 {
507 }
void add_bytes_sent(std::uint64_t bytes) noexcept
Record bytes sent.

References kcenon::pacs::monitoring::data_transfer_metrics::add_bytes_sent(), and transfer_.

Here is the call graph for this function:

◆ record_echo()

void kcenon::pacs::monitoring::pacs_metrics::record_echo ( bool success,
std::chrono::microseconds duration )
inlinenoexcept

Record a C-ECHO (verification) operation.

Parameters
successWhether the operation succeeded
durationOperation duration
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 429 of file pacs_metrics.h.

429 {
430 if (success) {
431 c_echo_.record_success(duration);
432 } else {
433 c_echo_.record_failure(duration);
434 }
435 }
void record_failure(std::chrono::microseconds duration) noexcept
Record a failed operation with duration.
void record_success(std::chrono::microseconds duration) noexcept
Record a successful operation with duration.

References c_echo_, kcenon::pacs::monitoring::operation_counter::record_failure(), and kcenon::pacs::monitoring::operation_counter::record_success().

Here is the call graph for this function:

◆ record_get()

void kcenon::pacs::monitoring::pacs_metrics::record_get ( bool success,
std::chrono::microseconds duration,
std::uint32_t images_retrieved = 0,
std::uint64_t bytes_retrieved = 0 )
inlinenoexcept

Record a C-GET operation.

Parameters
successWhether the operation succeeded
durationOperation duration
images_retrievedNumber of images retrieved
bytes_retrievedNumber of bytes retrieved
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 463 of file pacs_metrics.h.

466 {
467 if (success) {
468 c_get_.record_success(duration);
469 for (std::uint32_t i = 0; i < images_retrieved; ++i) {
471 }
472 if (bytes_retrieved > 0) {
473 transfer_.add_bytes_sent(bytes_retrieved);
474 }
475 } else {
476 c_get_.record_failure(duration);
477 }
478 }
void increment_images_retrieved() noexcept
Record an image retrieved.

References kcenon::pacs::monitoring::data_transfer_metrics::add_bytes_sent(), c_get_, kcenon::pacs::monitoring::data_transfer_metrics::increment_images_retrieved(), kcenon::pacs::monitoring::operation_counter::record_failure(), kcenon::pacs::monitoring::operation_counter::record_success(), and transfer_.

Here is the call graph for this function:

◆ record_move()

void kcenon::pacs::monitoring::pacs_metrics::record_move ( bool success,
std::chrono::microseconds duration,
std::uint32_t images_moved = 0 )
inlinenoexcept

Record a C-MOVE operation.

Parameters
successWhether the operation succeeded
durationOperation duration
images_movedNumber of images moved
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 443 of file pacs_metrics.h.

445 {
446 if (success) {
447 c_move_.record_success(duration);
448 for (std::uint32_t i = 0; i < images_moved; ++i) {
450 }
451 } else {
452 c_move_.record_failure(duration);
453 }
454 }

References c_move_, kcenon::pacs::monitoring::data_transfer_metrics::increment_images_retrieved(), kcenon::pacs::monitoring::operation_counter::record_failure(), kcenon::pacs::monitoring::operation_counter::record_success(), and transfer_.

Here is the call graph for this function:

◆ record_operation()

void kcenon::pacs::monitoring::pacs_metrics::record_operation ( dimse_operation op,
bool success,
std::chrono::microseconds duration )
inlinenoexcept

Record a generic DIMSE operation.

Parameters
opOperation type
successWhether the operation succeeded
durationOperation duration
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 486 of file pacs_metrics.h.

488 {
489 auto& counter = get_counter(op);
490 if (success) {
491 counter.record_success(duration);
492 } else {
493 counter.record_failure(duration);
494 }
495 }
const operation_counter & get_counter(dimse_operation op) const noexcept
Get operation counter for a specific DIMSE operation.
@ counter
Monotonic increasing value.

References kcenon::pacs::monitoring::counter, and get_counter().

Here is the call graph for this function:

◆ record_query()

void kcenon::pacs::monitoring::pacs_metrics::record_query ( bool success,
std::chrono::microseconds duration,
std::uint32_t matches = 0 )
inlinenoexcept

Record a C-FIND (query) operation.

Parameters
successWhether the operation succeeded
durationOperation duration
matchesNumber of matching results
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 414 of file pacs_metrics.h.

416 {
417 if (success) {
418 c_find_.record_success(duration);
419 } else {
420 c_find_.record_failure(duration);
421 }
422 }

References c_find_, kcenon::pacs::monitoring::operation_counter::record_failure(), and kcenon::pacs::monitoring::operation_counter::record_success().

Here is the call graph for this function:

◆ record_store()

void kcenon::pacs::monitoring::pacs_metrics::record_store ( bool success,
std::chrono::microseconds duration,
std::uint64_t bytes_stored = 0 )
inlinenoexcept

Record a C-STORE operation.

Parameters
successWhether the operation succeeded
durationOperation duration
bytes_storedNumber of bytes stored (0 if failed)
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h.

Definition at line 394 of file pacs_metrics.h.

396 {
397 if (success) {
398 c_store_.record_success(duration);
399 if (bytes_stored > 0) {
400 transfer_.add_bytes_received(bytes_stored);
402 }
403 } else {
404 c_store_.record_failure(duration);
405 }
406 }
void increment_images_stored() noexcept
Record an image stored.

References kcenon::pacs::monitoring::data_transfer_metrics::add_bytes_received(), c_store_, kcenon::pacs::monitoring::data_transfer_metrics::increment_images_stored(), kcenon::pacs::monitoring::operation_counter::record_failure(), kcenon::pacs::monitoring::operation_counter::record_success(), and transfer_.

Here is the call graph for this function:

◆ reset()

void kcenon::pacs::monitoring::pacs_metrics::reset ( )
inlinenoexcept

Reset all metrics to zero.

Thread-safe reset of all counters. Useful for testing or periodic metric collection windows.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h, and /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_monitor.h.

Definition at line 698 of file pacs_metrics.h.

698 {
699 c_echo_.reset();
700 c_store_.reset();
701 c_find_.reset();
702 c_move_.reset();
703 c_get_.reset();
705 n_set_.reset();
706 n_get_.reset();
708 n_event_.reset();
715 }
void reset() noexcept
Reset all counters to zero.
void reset() noexcept
Reset all counters to zero.
void reset() noexcept
Reset all counters to zero.
void reset() noexcept
Reset all counters to zero.

References associations_, c_echo_, c_find_, c_get_, c_move_, c_store_, dataset_pool_, element_pool_, n_action_, n_create_, n_delete_, n_event_, n_get_, n_set_, pdu_buffer_pool_, kcenon::pacs::monitoring::association_counters::reset(), kcenon::pacs::monitoring::data_transfer_metrics::reset(), kcenon::pacs::monitoring::operation_counter::reset(), kcenon::pacs::monitoring::pool_counters::reset(), and transfer_.

Referenced by kcenon::pacs::monitoring::pacs_monitor::reset().

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

◆ to_json()

std::string kcenon::pacs::monitoring::pacs_metrics::to_json ( ) const
nodiscard

Export metrics as JSON string.

Returns
JSON representation of all metrics

The JSON format is suitable for REST API responses and integration with monitoring systems like Grafana.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h, and /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_monitor.h.

Definition at line 110 of file pacs_metrics.cpp.

110 {
111 std::ostringstream oss;
112 oss << "{";
113
114 // DIMSE operations section
115 oss << R"("dimse_operations":{)"
116 << R"("c_echo":)" << counter_to_json(c_echo_)
117 << R"(,"c_store":)" << counter_to_json(c_store_)
118 << R"(,"c_find":)" << counter_to_json(c_find_)
119 << R"(,"c_move":)" << counter_to_json(c_move_)
120 << R"(,"c_get":)" << counter_to_json(c_get_)
121 << R"(,"n_create":)" << counter_to_json(n_create_)
122 << R"(,"n_set":)" << counter_to_json(n_set_)
123 << R"(,"n_get":)" << counter_to_json(n_get_)
124 << R"(,"n_action":)" << counter_to_json(n_action_)
125 << R"(,"n_event":)" << counter_to_json(n_event_)
126 << R"(,"n_delete":)" << counter_to_json(n_delete_)
127 << "}";
128
129 // Data transfer section
130 oss << R"(,"data_transfer":{)"
131 << R"("bytes_sent":)" << transfer_.bytes_sent.load(std::memory_order_relaxed)
132 << R"(,"bytes_received":)" << transfer_.bytes_received.load(std::memory_order_relaxed)
133 << R"(,"images_stored":)" << transfer_.images_stored.load(std::memory_order_relaxed)
134 << R"(,"images_retrieved":)" << transfer_.images_retrieved.load(std::memory_order_relaxed)
135 << "}";
136
137 // Associations section
138 oss << R"(,"associations":{)"
139 << R"("total_established":)" << associations_.total_established.load(std::memory_order_relaxed)
140 << R"(,"total_rejected":)" << associations_.total_rejected.load(std::memory_order_relaxed)
141 << R"(,"total_aborted":)" << associations_.total_aborted.load(std::memory_order_relaxed)
142 << R"(,"current_active":)" << associations_.current_active.load(std::memory_order_relaxed)
143 << R"(,"peak_active":)" << associations_.peak_active.load(std::memory_order_relaxed)
144 << "}";
145
146 oss << "}";
147 return oss.str();
148}
std::atomic< std::uint64_t > total_rejected
std::atomic< std::uint64_t > total_aborted
std::atomic< std::uint32_t > current_active
std::atomic< std::uint64_t > total_established
std::atomic< std::uint64_t > images_retrieved
std::atomic< std::uint64_t > bytes_received

References associations_, kcenon::pacs::monitoring::data_transfer_metrics::bytes_received, kcenon::pacs::monitoring::data_transfer_metrics::bytes_sent, c_echo_, c_find_, c_get_, c_move_, c_store_, kcenon::pacs::monitoring::association_counters::current_active, kcenon::pacs::monitoring::data_transfer_metrics::images_retrieved, kcenon::pacs::monitoring::data_transfer_metrics::images_stored, n_action_, n_create_, n_delete_, n_event_, n_get_, n_set_, kcenon::pacs::monitoring::association_counters::peak_active, kcenon::pacs::monitoring::association_counters::total_aborted, kcenon::pacs::monitoring::association_counters::total_established, kcenon::pacs::monitoring::association_counters::total_rejected, and transfer_.

Referenced by kcenon::pacs::monitoring::pacs_monitor::to_json().

Here is the caller graph for this function:

◆ to_prometheus()

std::string kcenon::pacs::monitoring::pacs_metrics::to_prometheus ( std::string_view prefix = "pacs") const
nodiscard

Export metrics in Prometheus text format.

Parameters
prefixMetric name prefix (default: "pacs")
Returns
Prometheus exposition format text

The output follows the Prometheus text-based format specification suitable for scraping by Prometheus servers.

Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_metrics.h, and /home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/monitoring/pacs_monitor.h.

Definition at line 150 of file pacs_metrics.cpp.

150 {
151 std::ostringstream oss;
152
153 // DIMSE operation metrics
154 counter_to_prometheus(oss, prefix, "c_echo", c_echo_);
155 counter_to_prometheus(oss, prefix, "c_store", c_store_);
156 counter_to_prometheus(oss, prefix, "c_find", c_find_);
157 counter_to_prometheus(oss, prefix, "c_move", c_move_);
158 counter_to_prometheus(oss, prefix, "c_get", c_get_);
159 counter_to_prometheus(oss, prefix, "n_create", n_create_);
160 counter_to_prometheus(oss, prefix, "n_set", n_set_);
161 counter_to_prometheus(oss, prefix, "n_get", n_get_);
162 counter_to_prometheus(oss, prefix, "n_action", n_action_);
163 counter_to_prometheus(oss, prefix, "n_event", n_event_);
164 counter_to_prometheus(oss, prefix, "n_delete", n_delete_);
165
166 // Data transfer metrics
167 oss << "# HELP " << prefix << "_bytes_sent_total Total bytes sent over network\n"
168 << "# TYPE " << prefix << "_bytes_sent_total counter\n"
169 << prefix << "_bytes_sent_total " << transfer_.bytes_sent.load(std::memory_order_relaxed) << "\n";
170
171 oss << "# HELP " << prefix << "_bytes_received_total Total bytes received from network\n"
172 << "# TYPE " << prefix << "_bytes_received_total counter\n"
173 << prefix << "_bytes_received_total " << transfer_.bytes_received.load(std::memory_order_relaxed) << "\n";
174
175 oss << "# HELP " << prefix << "_images_stored_total Total DICOM images stored\n"
176 << "# TYPE " << prefix << "_images_stored_total counter\n"
177 << prefix << "_images_stored_total " << transfer_.images_stored.load(std::memory_order_relaxed) << "\n";
178
179 oss << "# HELP " << prefix << "_images_retrieved_total Total DICOM images retrieved\n"
180 << "# TYPE " << prefix << "_images_retrieved_total counter\n"
181 << prefix << "_images_retrieved_total " << transfer_.images_retrieved.load(std::memory_order_relaxed) << "\n";
182
183 // Association metrics
184 oss << "# HELP " << prefix << "_associations_established_total Total associations established\n"
185 << "# TYPE " << prefix << "_associations_established_total counter\n"
186 << prefix << "_associations_established_total " << associations_.total_established.load(std::memory_order_relaxed) << "\n";
187
188 oss << "# HELP " << prefix << "_associations_rejected_total Total associations rejected\n"
189 << "# TYPE " << prefix << "_associations_rejected_total counter\n"
190 << prefix << "_associations_rejected_total " << associations_.total_rejected.load(std::memory_order_relaxed) << "\n";
191
192 oss << "# HELP " << prefix << "_associations_aborted_total Total associations aborted\n"
193 << "# TYPE " << prefix << "_associations_aborted_total counter\n"
194 << prefix << "_associations_aborted_total " << associations_.total_aborted.load(std::memory_order_relaxed) << "\n";
195
196 oss << "# HELP " << prefix << "_associations_active Current active associations\n"
197 << "# TYPE " << prefix << "_associations_active gauge\n"
198 << prefix << "_associations_active " << associations_.current_active.load(std::memory_order_relaxed) << "\n";
199
200 oss << "# HELP " << prefix << "_associations_peak_active Peak concurrent associations\n"
201 << "# TYPE " << prefix << "_associations_peak_active gauge\n"
202 << prefix << "_associations_peak_active " << associations_.peak_active.load(std::memory_order_relaxed) << "\n";
203
204 return oss.str();
205}

References associations_, kcenon::pacs::monitoring::data_transfer_metrics::bytes_received, kcenon::pacs::monitoring::data_transfer_metrics::bytes_sent, c_echo_, c_find_, c_get_, c_move_, c_store_, kcenon::pacs::monitoring::association_counters::current_active, kcenon::pacs::monitoring::data_transfer_metrics::images_retrieved, kcenon::pacs::monitoring::data_transfer_metrics::images_stored, n_action_, n_create_, n_delete_, n_event_, n_get_, n_set_, kcenon::pacs::monitoring::association_counters::peak_active, kcenon::pacs::monitoring::association_counters::total_aborted, kcenon::pacs::monitoring::association_counters::total_established, kcenon::pacs::monitoring::association_counters::total_rejected, and transfer_.

Referenced by kcenon::pacs::monitoring::pacs_monitor::to_prometheus().

Here is the caller graph for this function:

◆ transfer()

Member Data Documentation

◆ associations_

◆ c_echo_

operation_counter kcenon::pacs::monitoring::pacs_metrics::c_echo_
private

◆ c_find_

operation_counter kcenon::pacs::monitoring::pacs_metrics::c_find_
private

◆ c_get_

operation_counter kcenon::pacs::monitoring::pacs_metrics::c_get_
private

◆ c_move_

operation_counter kcenon::pacs::monitoring::pacs_metrics::c_move_
private

◆ c_store_

operation_counter kcenon::pacs::monitoring::pacs_metrics::c_store_
private

◆ dataset_pool_

pool_counters kcenon::pacs::monitoring::pacs_metrics::dataset_pool_
private

◆ element_pool_

pool_counters kcenon::pacs::monitoring::pacs_metrics::element_pool_
private

◆ n_action_

operation_counter kcenon::pacs::monitoring::pacs_metrics::n_action_
private

◆ n_create_

operation_counter kcenon::pacs::monitoring::pacs_metrics::n_create_
private

◆ n_delete_

operation_counter kcenon::pacs::monitoring::pacs_metrics::n_delete_
private

◆ n_event_

operation_counter kcenon::pacs::monitoring::pacs_metrics::n_event_
private

◆ n_get_

operation_counter kcenon::pacs::monitoring::pacs_metrics::n_get_
private

◆ n_set_

operation_counter kcenon::pacs::monitoring::pacs_metrics::n_set_
private

◆ pdu_buffer_pool_

pool_counters kcenon::pacs::monitoring::pacs_metrics::pdu_buffer_pool_
private

◆ transfer_


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