10 m_stop(boost::posix_time::neg_infin),
15 m_stop = boost::posix_time::microsec_clock::universal_time();
16 m_status = commit_status;
20 m_connectionString( connectionString ),
22 m_stop(boost::posix_time::neg_infin),
23 m_currentTransaction(0),
29 for(std::map<std::string,TransactionMonitoringData*>::const_iterator iT = m_transactions.begin();
30 iT != m_transactions.end();iT++ ){
37 m_transactions.insert(std::make_pair(
guidFromTime(),m_currentTransaction));
38 m_ncur = m_transactions.size();
44 if(m_currentTransaction){
45 m_currentTransaction->stop( commit_status );
46 m_currentTransaction = 0;
54 m_stop = boost::posix_time::microsec_clock::universal_time();
55 m_currentTransaction = 0;
60 return m_transactions.size();
65 for(std::map<std::string,TransactionMonitoringData*>::const_iterator iT = m_transactions.begin();
66 iT != m_transactions.end();iT++ ){
68 boost::posix_time::time_duration duration;
69 if( !data.
m_stop.is_neg_infinity() ){
72 out <<
" -> Transaction #"<<i<<
" duration="<<boost::posix_time::to_simple_string(duration)<<
" status="<<(data.
m_status?
std::string(
"COMMIT"):
std::string(
"ROLLBACK"))<<std::endl;
85 if(! s_enabled.load(std::memory_order_acquire) ){
86 const char* envVar = ::getenv(
"ORA_MONITORING_LEVEL" );
87 if( envVar && ::strcmp(envVar,
"SESSION")==0 ) s_enabled.store(
true,std::memory_order_release);
89 return s_enabled.load(std::memory_order_acquire);
93 s_enabled.store(
true,std::memory_order_release);
97 const char* fileEnvVar = ::getenv(
"ORA_MONITORING_FILE" );
98 static const std::string s_outFileName( fileEnvVar?fileEnvVar:
"");
118 std::cout <<
"ORA_MONITORING Error: "<<e.what()<<std::endl;
122 for(std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
123 iS != m_sessions.end();iS++ ){
135 out <<
"### ---------------------------------------------------------------------- "<<std::endl;
136 out <<
"### ORA Monitoring Summary "<<std::endl;
137 out <<
"### "<<m_sessions.size()<<
" session(s) registered."<<std::endl;
139 for( std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
140 iS != m_sessions.end(); ++iS ){
142 boost::posix_time::time_duration duration;
143 if( !data.
m_stop.is_neg_infinity() ){
146 out <<
" -> Session #"<<j<<
": connection=\""<<data.
m_connectionString<<
"\" duration="<<boost::posix_time::to_simple_string(duration)<<
" transactions="<<(iS->second)->numberOfTransactions()<<std::endl;
147 (iS->second)->
report(out);
150 out <<
"### ---------------------------------------------------------------------- "<<std::endl;
tuple start
Check for commandline option errors.
TransactionMonitoringData(boost::posix_time::ptime start)
size_t stopTransaction(bool commit_status=true)
boost::posix_time::ptime m_stop
static Monitoring & get()
static const std::string & outFileName()
std::string m_connectionString
SessionMonitoringData * startSession(const std::string &connectionString)
void report(std::ostream &out) const
boost::posix_time::ptime m_stop
SessionMonitoringData(boost::posix_time::ptime start, const std::string &connectionString)
static std::atomic< bool > s_enabled
void report(std::ostream &out)
boost::posix_time::ptime m_start
void stop(bool commit_status=true)
size_t numberOfTransactions() const
volatile std::atomic< bool > shutdown_flag false
boost::posix_time::ptime m_start
std::string guidFromTime()