45#include <StormByte/safe/atomic.hxx>
46#include <StormByte/safe/pointers.hxx>
47#include <StormByte/safe/string.hxx>
48#include <StormByte/telemetry.hxx>
160 void Complete(
bool success, std::uint64_t rows_returned = 0) noexcept;
171 std::uint64_t m_rows_returned;
262 void RecordOperation(Operation operation,
bool success, std::chrono::nanoseconds elapsed, std::uint64_t rows_returned)
noexcept;
264 std::array<Counter, static_cast<std::size_t>(Operation::Count)> m_operations;
265 std::array<StormByte::Safe::Atomic<std::uint64_t>,
static_cast<std::size_t
>(BackendEvent::Count)> m_events;
266 StormByte::Safe::Atomic<std::uint64_t> m_rows_returned;
Records one operation and its elapsed time on destruction.
Definition telemetry.hxx:136
OperationScope(StormByte::Safe::Shared< Telemetry > telemetry, Operation operation) noexcept
OperationScope(OperationScope &&)=delete
Move constructor is deleted.
OperationScope(const OperationScope &)=delete
Copy constructor is deleted.
void Complete(bool success, std::uint64_t rows_returned=0) noexcept
Record the result and optional returned row count.
friend class OperationScope
Definition telemetry.hxx:242
virtual void RecordEvent(BackendEvent event) noexcept
Telemetry & operator=(const Telemetry &)=delete
Copy assignment is disabled.
virtual operator StormByte::Safe::String() const override
Telemetry(Telemetry &&)=delete
Moving counters is disabled.
Telemetry(const Telemetry &)=delete
Copying counters is disabled.
Telemetry & operator=(Telemetry &&)=delete
Move assignment is disabled.
friend class PreparedSTMT
Definition telemetry.hxx:241
friend class Database
Definition telemetry.hxx:240
std::uint64_t RowsReturned() const noexcept
Total rows successfully returned by Query and prepared statements.
OperationMetrics Metrics(Operation operation) const noexcept
Obtain a thread-safe metrics snapshot for an operation.
void RecordEvents(BackendEvent event, std::uint64_t count) noexcept
Add a known number of occurrences for one backend event.
Telemetry()
Construct zeroed counters.
std::uint64_t Events(BackendEvent event) const noexcept
Number of backend events in a shared category.
class Clock & Clock(std::string_view name)
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Logger::Exception)
Database module of the StormByte suite.
BackendEvent
Shared error and warning categories for backend-specific telemetry.
Definition telemetry.hxx:88
@ Warning
Non-fatal warning reported by a backend.
Definition telemetry.hxx:89
@ Serialization
Transaction serialization conflict.
Definition telemetry.hxx:94
@ LockTimeout
Lock wait timed out.
Definition telemetry.hxx:96
@ Io
Storage or transport I/O failure.
Definition telemetry.hxx:92
@ Constraint
Constraint violation.
Definition telemetry.hxx:91
@ Other
Backend failure without a narrower category.
Definition telemetry.hxx:97
@ Deadlock
Deadlock victim or equivalent conflict.
Definition telemetry.hxx:95
@ Connection
Connection or protocol failure.
Definition telemetry.hxx:93
@ Busy
Busy, locked, or lock-timeout condition.
Definition telemetry.hxx:90
Operation
Database operation categories measured by telemetry.
Definition telemetry.hxx:71
@ RollbackTransaction
Explicit and automatic rollback attempts.
Definition telemetry.hxx:80
@ CommitTransaction
Transaction commit attempts.
Definition telemetry.hxx:79
@ Disconnect
Disconnect calls.
Definition telemetry.hxx:73
@ Connect
Connection attempts.
Definition telemetry.hxx:72
@ PreparedStatement
Prepared-statement execution attempts.
Definition telemetry.hxx:77
@ Query
Queries that return rows.
Definition telemetry.hxx:74
@ SilentQuery
Queries that return only success or failure.
Definition telemetry.hxx:75
@ BeginTransaction
Transaction begin attempts.
Definition telemetry.hxx:78
@ PrepareStatement
Prepared-statement registration attempts.
Definition telemetry.hxx:76
@ Count
Number of operation categories.
Definition telemetry.hxx:81
Root namespace of the StormByte C++ suite.
Immutable view of cumulative metrics for one operation category.
Definition telemetry.hxx:105
std::uint64_t Attempts
Number of recorded attempts.
Definition telemetry.hxx:106
std::uint64_t Failures
Number of failed attempts.
Definition telemetry.hxx:108
std::uint64_t MeanNanoseconds() const noexcept
Mean duration across attempts.
Definition telemetry.hxx:117
std::uint64_t MaximumNanoseconds
Maximum measured duration.
Definition telemetry.hxx:111
std::uint64_t Successes
Number of successful attempts.
Definition telemetry.hxx:107
std::uint64_t TotalNanoseconds
Sum of measured durations.
Definition telemetry.hxx:109
std::uint64_t MinimumNanoseconds
Minimum measured duration, or zero when empty.
Definition telemetry.hxx:110
#define STORMBYTE_DATABASE_PRIVATE
Definition visibility.h:57
#define STORMBYTE_DATABASE_PUBLIC
Definition visibility.h:54