Lightweight 0.20260921.0
Loading...
Searching...
No Matches
Lightweight::SqlPoolStatistics Struct Reference

#include <SqlStatistics.hpp>

Public Member Functions

LIGHTWEIGHT_API double ReuseRate () const noexcept
 

Public Attributes

std::uint64_t acquired {}
 Number of connections handed out (from idle, freshly created, or handed off to a waiter).
 
std::uint64_t reused {}
 Of acquired, how many reused an already-open connection rather than creating one.
 
std::uint64_t waited {}
 Of acquired, how many had to block or park because the pool was exhausted.
 
std::uint64_t released {}
 Number of connections returned to the pool.
 
std::uint64_t discarded {}
 
std::uint64_t idle {}
 Connections currently sitting idle in the pool.
 
std::uint64_t checkedOut {}
 
SqlLatencyHistogram waitLatency {}
 

Detailed Description

Aggregated connection-pool counters.

Because Pool is a class template keyed on a compile-time configuration, a process typically holds several distinct pool types. They all record into the process-wide SqlStatistics::Instance — a pool cannot be pointed at a collector of its own — so these counters give a combined view across every pool in the process. The monotonic counters (acquired, reused, waited, released, discarded) aggregate cleanly; idle and checkedOut are last-writer-wins and read as "the most recent pool transition" once more than one pool is in play.

Definition at line 167 of file SqlStatistics.hpp.

Member Function Documentation

◆ ReuseRate()

LIGHTWEIGHT_API double Lightweight::SqlPoolStatistics::ReuseRate ( ) const
noexcept

Retrieves the fraction of acquisitions served by an already-open connection.

Returns
The reuse rate in [0.0, 1.0]; 0.0 when nothing was acquired yet.

Member Data Documentation

◆ acquired

std::uint64_t Lightweight::SqlPoolStatistics::acquired {}

Number of connections handed out (from idle, freshly created, or handed off to a waiter).

Definition at line 170 of file SqlStatistics.hpp.

◆ reused

std::uint64_t Lightweight::SqlPoolStatistics::reused {}

Of acquired, how many reused an already-open connection rather than creating one.

Definition at line 173 of file SqlStatistics.hpp.

◆ waited

std::uint64_t Lightweight::SqlPoolStatistics::waited {}

Of acquired, how many had to block or park because the pool was exhausted.

Definition at line 176 of file SqlStatistics.hpp.

◆ released

std::uint64_t Lightweight::SqlPoolStatistics::released {}

Number of connections returned to the pool.

Definition at line 179 of file SqlStatistics.hpp.

◆ discarded

std::uint64_t Lightweight::SqlPoolStatistics::discarded {}

Number of returned connections destroyed rather than idled, because the pool was over capacity (GrowthStrategy::BoundedOverflow).

Definition at line 183 of file SqlStatistics.hpp.

◆ idle

std::uint64_t Lightweight::SqlPoolStatistics::idle {}

Connections currently sitting idle in the pool.

Definition at line 186 of file SqlStatistics.hpp.

◆ checkedOut

std::uint64_t Lightweight::SqlPoolStatistics::checkedOut {}

Connections currently checked out of the pool.

Note
Only GrowthStrategy::BoundedWait tracks a checked-out count — it is what bounds the pool. The non-blocking strategies (UnboundedGrow, BoundedOverflow) never maintain one, so this reads 0 for them; use acquired minus released there instead.

Definition at line 193 of file SqlStatistics.hpp.

◆ waitLatency

SqlLatencyHistogram Lightweight::SqlPoolStatistics::waitLatency {}

Distribution of the time spent waiting for a connection to become available. Only acquisitions that actually waited contribute a sample.

Definition at line 197 of file SqlStatistics.hpp.


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