Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
performance_types.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
11#pragma once
12
13#include <cstdint>
14#include <string>
15
16namespace kcenon { namespace monitoring {
17
26 std::string operation_name;
27
28 // Call statistics
29 std::uint64_t total_calls{0};
30 std::uint64_t error_count{0};
31
32 // Duration statistics (in nanoseconds)
33 std::int64_t total_duration_ns{0};
34 std::int64_t min_duration_ns{INT64_MAX};
35 std::int64_t max_duration_ns{0};
36 std::int64_t avg_duration_ns{0};
37
42 double success_rate() const {
43 if (total_calls == 0) return 100.0;
44 return 100.0 * (total_calls - error_count) / total_calls;
45 }
46
51 double error_rate() const {
52 if (total_calls == 0) return 0.0;
53 return 100.0 * error_count / total_calls;
54 }
55};
56
57}} // namespace kcenon::monitoring
Lightweight performance profile for aggregated metrics.
double error_rate() const
Calculate error rate.
double success_rate() const
Calculate success rate.