Skip to content

Commit 0c5d6b1

Browse files
committed
reset duration metrics on protocol change
1 parent 8fdccee commit 0c5d6b1

2 files changed

Lines changed: 733 additions & 0 deletions

File tree

src/lib/mongoBackend/mongoUpdateSubscription.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ void setNotificationInfo(const Subscription& sub, orion::BSONObjBuilder* setB, o
173173
}
174174

175175

176+
/* ****************************************************************************
177+
*
178+
* unsetHttpNotificationDurationMetrics -
179+
*
180+
*/
181+
static void unsetHttpNotificationDurationMetrics(orion::BSONObjBuilder* unsetB)
182+
{
183+
unsetB->append(CSUB_LASTNOTIFICATIONDURATION, 1);
184+
unsetB->append(CSUB_ACCUMULATEDNOTIFICATIONDURATION, 1);
185+
}
186+
176187

177188
/* ****************************************************************************
178189
*
@@ -317,6 +328,14 @@ static void updateInCache
317328
statusLastChange = -1;
318329
}
319330

331+
// HTTP duration metrics don't apply to MQTT or Kafka notifications
332+
if (subUp.notificationProvided &&
333+
subUp.notification.type != ngsiv2::HttpNotification)
334+
{
335+
lastNotificationDuration = -1;
336+
notificationDurationDelta = 0;
337+
}
338+
320339
// different for other fields grabbed from the cache, status could be included in the sub update
321340
// thus, effective status is the newest one in cache or in DB
322341
double statusLastChangeAtDb = doc.hasField(CSUB_STATUS_LAST_CHANGE)? getNumberFieldF(doc, CSUB_STATUS_LAST_CHANGE) : -1;
@@ -442,6 +461,14 @@ std::string mongoUpdateSubscription
442461
}
443462
}
444463

464+
if (subUp.notificationProvided)
465+
{
466+
if (subUp.notification.type != ngsiv2::HttpNotification)
467+
{
468+
unsetHttpNotificationDurationMetrics(&unsetB);
469+
}
470+
}
471+
445472
orion::BSONObjBuilder update;
446473
if (setB.nFields() > 0)
447474
{

0 commit comments

Comments
 (0)