Skip to content

Commit

Permalink
[auto-discovery][jmx] fix-up exception handling logic + comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
truthbk committed Jul 10, 2017
1 parent 4d14435 commit 110f469
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,18 +440,20 @@ def _submit_jmx_service_discovery(self, jmx_sd_configs):
log.debug("Unable to automatically start jmxfetch on Windows via supervisor.")

buffer = ""
for name, yaml in jmx_sd_configs.iteritems():
try:
try:
for name, yaml in jmx_sd_configs.iteritems():
buffer += SD_CONFIG_SEP
buffer += "# {}\n".format(name)
buffer += yaml
except Exception as e:
log.exception("unable to submit YAML via RPC: %s", e)
else:
log.info("JMX SD Config via named pip %s successfully.", name)

if buffer:
os.write(self.sd_pipe, buffer)
if buffer:
# will block if len(buffer) > OS pipe buffer.
# JMX will unblock when it reads on the other end.
os.write(self.sd_pipe, buffer)
except Exception as e:
log.exception("unable to submit YAML via pipe: %s", e)
else:
log.info("JMX SD Config via named pipe %s successfully.", name)

def _should_restart(self):
if time.time() - self.agent_start > self.restart_interval:
Expand Down

0 comments on commit 110f469

Please sign in to comment.