Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in default metrics bus handling #486

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions neon_utils/metrics_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def __enter__(self):

def __exit__(self, typ, val, traceback):
self.stop()
self.report()
try:
self.report()
except Exception as e:
LOG.exception(e)

def start(self):
self.start_time = time()
Expand All @@ -69,7 +72,9 @@ def stop(self):

def report(self):
if self._metric and self._report:
self._bus = self._bus or MessageBusClient()
if not self._bus:
self._bus = MessageBusClient()
self._bus.run_in_thread()
message = dig_for_message() or Message("")
message.context['timestamp'] = time()
self._bus.emit(message.forward("neon.metric",
Expand Down
Loading