userver: utils::trx_tracker Namespace Reference
Loading...
Searching...
No Matches
utils::trx_tracker Namespace Reference

Detailed Description

Tracking for heavy operations while having active transactions.

Some operations, like http requests, are heavy and can take too long during an incident. If they are called during an active database transaction, connection will be held for longer and connection pool will be exhausted. Transaction tracker prevents this by holding counter of active transactions in TaskLocalVariable and checking for active transactions in heavy operaions.

Example usage:

EXPECT_THAT(GetLogCapture().Filter("Long call while having active transactions"), testing::SizeIs(1));

Classes

class  CheckDisabler
 Disable check for active transactions. More...
 
struct  TransactionTrackerStatistics
 Statistics for transaction tracker. More...
 

Functions

void StartTransaction ()
 Increment transaction counter.
 
void EndTransaction () noexcept
 Decrement transaction counter.
 
void CheckNoTransactions (utils::impl::SourceLocation location=utils::impl::SourceLocation::Current())
 Check for active transactions.
 
TransactionTrackerStatistics GetStatistics () noexcept
 Get statistics for transaction tracker.
 
void ResetStatistics ()
 Reset statistics for transaction tracker.
 

Function Documentation

◆ EndTransaction()

void utils::trx_tracker::EndTransaction ( )
noexcept

Decrement transaction counter.

If called before StartTransaction, the behavior is undefined.