Move metric instrumentation inside the method call.
This way we avoid outliers when method returns early aka immediately.
@@ -97,10 +97,7 @@ class Notifier(consumers.MessageHandler):
self._post_notify_triggers(liveaction_db=liveaction_db,
execution_db=execution_db)
- if cfg.CONF.action_sensor.enable:
- with CounterWithTimer(key='notifier.generic_trigger.post'):
- self._post_generic_trigger(liveaction_db=liveaction_db,
- execution_db=execution_db)
+ self._post_generic_trigger(liveaction_db=liveaction_db, execution_db=execution_db)
def _get_execution_for_liveaction(self, liveaction):
execution = ActionExecution.get(liveaction__id=str(liveaction.id))
@@ -252,6 +249,7 @@ class Notifier(consumers.MessageHandler):
LOG.debug(msg % (execution_id, execution_db.status, target_statuses), extra=extra)
return
+ with CounterWithTimer(key='notifier.generic_trigger.post'):
payload = {'execution_id': execution_id,
'status': liveaction_db.status,
'start_timestamp': str(liveaction_db.start_timestamp),
