@@ -63,28 +63,6 @@ void Monitoring::enableProcessMonitoring(const unsigned int interval) {
6363 #endif
6464}
6565
66- void Monitoring::startTimer (std::string name) {
67- auto search = mTimers .find (name);
68- if (search == mTimers .end ()) {
69- auto now = std::chrono::steady_clock::now ();
70- mTimers .insert (std::make_pair (name, now));
71- } else {
72- MonLogger::Get () << " Monitoring timer : Timer for " << name << " already started" << MonLogger::End ();
73- }
74- }
75-
76- void Monitoring::stopAndSendTimer (std::string name) {
77- auto search = mTimers .find (name);
78- if (search != mTimers .end ()) {
79- auto now = std::chrono::duration_cast <std::chrono::milliseconds>(std::chrono::steady_clock::now ().time_since_epoch ()).count ();
80- auto start = std::chrono::duration_cast <std::chrono::milliseconds>(search->second .time_since_epoch ()).count ();
81- uint64_t duration = now - start;
82- send ({duration, name});
83- } else {
84- MonLogger::Get () << " Monitoring timer : Cannot stop " << name << " timer as it hasn't started" << MonLogger::End ();
85- }
86- }
87-
8866void Monitoring::addGlobalTag (std::string name, std::string value)
8967{
9068 for (auto & backend: mBackends ) {
@@ -124,7 +102,8 @@ void Monitoring::pushLoop()
124102
125103 if (mAutoPushInterval != 0 && (loopCount % (mAutoPushInterval *10 )) == 0 ) {
126104 std::vector<Metric> metrics;
127- for (auto & metric : mPushStore ) {
105+ for (auto metric : mPushStore ) {
106+ metric.resetTimestamp ();
128107 metrics.push_back (metric);
129108 }
130109 send (std::move (metrics));
@@ -134,10 +113,12 @@ void Monitoring::pushLoop()
134113 }
135114}
136115
137- Metric & Monitoring::getAutoPushMetric (std::string name)
116+ ComplexMetric & Monitoring::getAutoPushMetric (std::string name, unsigned int interval )
138117{
139- if (mAutoPushInterval == 0 ) {
140- MonLogger::Get () << " [WARN] AutoPush is not enabled" << MonLogger::End ();
118+ if (!mMonitorRunning ) {
119+ mMonitorRunning = true ;
120+ mMonitorThread = std::thread (&Monitoring::pushLoop, this );
121+ mAutoPushInterval = interval;
141122 }
142123 mPushStore .emplace_back (boost::variant< int , std::string, double , uint64_t > {}, name);
143124 return mPushStore .back ();
@@ -166,15 +147,6 @@ void Monitoring::debug(Metric&& metric)
166147 }
167148}
168149
169- void Monitoring::enableAutoPush (unsigned int interval)
170- {
171- if (!mMonitorRunning ) {
172- mMonitorRunning = true ;
173- mMonitorThread = std::thread (&Monitoring::pushLoop, this );
174- }
175- mAutoPushInterval = interval;
176- }
177-
178150void Monitoring::pushToBackends (Metric&& metric)
179151{
180152 if (mBuffering ) {
0 commit comments