25#include <unordered_map>
41 std::unordered_map<std::string, std::string>
labels;
46 std::unordered_map<std::string, std::string> l = {})
50 ,
timestamp(std::chrono::system_clock::now())
112 const std::unordered_map<std::string, std::string>& config);
118 [[nodiscard]] std::vector<association_metric>
collect();
124 [[nodiscard]] std::string
get_name()
const;
142 [[nodiscard]] std::unordered_map<std::string, double>
get_statistics()
const;
172 const std::string&
name,
174 const std::string& type)
const;
182 : ae_title_(std::move(ae_title)) {}
185 const std::unordered_map<std::string, std::string>& config) {
187 if (
auto it = config.find(
"ae_title"); it != config.end()) {
191 init_time_ = std::chrono::steady_clock::now();
197 std::vector<association_metric> metrics;
207 "dicom_associations_active",
208 static_cast<double>(counters.current_active.load(std::memory_order_relaxed)),
213 "dicom_associations_peak_active",
214 static_cast<double>(counters.peak_active.load(std::memory_order_relaxed)),
219 "dicom_associations_total",
220 static_cast<double>(counters.total_established.load(std::memory_order_relaxed)),
225 "dicom_associations_rejected_total",
226 static_cast<double>(counters.total_rejected.load(std::memory_order_relaxed)),
231 "dicom_associations_aborted_total",
232 static_cast<double>(counters.total_aborted.load(std::memory_order_relaxed)),
236 const auto total = counters.total_established.load(std::memory_order_relaxed);
237 const auto rejected = counters.total_rejected.load(std::memory_order_relaxed);
238 const auto attempted = total + rejected;
239 const double success_rate = (attempted > 0)
240 ?
static_cast<double>(total) /
static_cast<double>(attempted)
244 "dicom_associations_success_rate",
258 return "dicom_association_collector";
263 "dicom_associations_active",
264 "dicom_associations_peak_active",
265 "dicom_associations_total",
266 "dicom_associations_rejected_total",
267 "dicom_associations_aborted_total",
268 "dicom_associations_success_rate"
276inline std::unordered_map<std::string, double>
280 std::unordered_map<std::string, double> stats;
284 const auto uptime = std::chrono::duration_cast<std::chrono::seconds>(
285 std::chrono::steady_clock::now() -
init_time_);
286 stats[
"uptime_seconds"] =
static_cast<double>(uptime.count());
301 const std::string&
name,
303 const std::string& type)
const {
Collector for DICOM association lifecycle metrics.
dicom_association_collector(std::string ae_title="PACS_SCP")
Default constructor.
std::string get_ae_title() const
Get the current AE title.
~dicom_association_collector()=default
Destructor.
bool initialize(const std::unordered_map< std::string, std::string > &config)
Initialize the collector with configuration.
std::uint64_t collection_count_
std::chrono::steady_clock::time_point init_time_
std::vector< std::string > get_metric_types() const
Get supported metric types.
bool is_healthy() const
Check if the collector is healthy.
association_metric create_metric(const std::string &name, double value, const std::string &type) const
dicom_association_collector & operator=(dicom_association_collector &&)=delete
void set_ae_title(std::string ae_title)
Set the AE title for metric labels.
dicom_association_collector(dicom_association_collector &&)=delete
std::string get_name() const
Get the collector name.
std::vector< association_metric > collect()
Collect current association metrics.
std::unordered_map< std::string, double > get_statistics() const
Get collector statistics.
dicom_association_collector(const dicom_association_collector &)=delete
dicom_association_collector & operator=(const dicom_association_collector &)=delete
static pacs_metrics & global_metrics() noexcept
Get the global singleton instance.
const association_counters & associations() const noexcept
Get association counters.
Operation metrics collection for PACS DICOM services.
Standard metric structure for association data.
std::unordered_map< std::string, std::string > labels
std::chrono::system_clock::time_point timestamp
association_metric(std::string n, double v, std::string t, std::unordered_map< std::string, std::string > l={})