Skip to content

Commit

Permalink
Tidyup riemann code to lose some lines
Browse files Browse the repository at this point in the history
  • Loading branch information
devcurmudgeon committed Feb 27, 2016
1 parent 1f66db5 commit 2d7f4c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 33 deletions.
31 changes: 16 additions & 15 deletions ybd/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,22 @@ def timer(this, message=''):
yield
except:
raise
else:
text = '' if message == '' else ' for ' + message
time_elapsed = elapsed(starttime)
log(this, 'Elapsed time' + text, time_elapsed)
if riemann_available and 'riemann-server' in config:
host_name = config['riemann-server']
port = config['riemann-port']
time_split = time_elapsed.split(':')
time_sec = int(time_split[0]) * 3600 \
+ int(time_split[1]) * 60 + int(time_split[2])
with QueuedClient(TCPTransport(host_name, port,
timeout=30)) as client:
client.event(service="Timer",
description=text, metric_f=time_sec)
client.flush()
text = '' if message == '' else ' for ' + message
time_elapsed = elapsed(starttime)
log(this, 'Elapsed time' + text, time_elapsed)
log_riemann(this, 'Timer', text, time_elapsed)


def log_riemann(this, service, text, time_elapsed):
if riemann_available and 'riemann-server' in config:
time_split = time_elapsed.split(':')
time_sec = int(time_split[0]) * 3600 \
+ int(time_split[1]) * 60 + int(time_split[2])
with QueuedClient(TCPTransport(config['riemann-server'],
config['riemann-port'],
timeout=30)) as client:
client.event(service=service, description=text, metric_f=time_sec)
client.flush()


def elapsed(starttime):
Expand Down
19 changes: 1 addition & 18 deletions ybd/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
import time
import datetime
import splitting
try:
from riemann_client.transport import TCPTransport
from riemann_client.client import QueuedClient
riemann_available = True
except ImportError:
riemann_available = False


class RetryException(Exception):
Expand Down Expand Up @@ -158,18 +152,7 @@ def run_build(defs, this):
with open(this['log'], "a") as logfile:
time_elapsed = app.elapsed(this['start-time'])
logfile.write('Elapsed_time: %s\n' % time_elapsed)
if riemann_available and 'riemann-server' in app.config:
host_name = app.config['riemann-server']
port = app.config['riemann-port']
time_split = time_elapsed.split(':')
time_sec = int(time_split[0]) * 3600 \
+ int(time_split[1]) * 60 + int(time_split[2])
with QueuedClient(TCPTransport(host_name, port,
timeout=30)) as client:
client.event(service="Artifact_Timer",
description=this['name'],
metric_f=time_sec)
client.flush()
app.log_riemann(this, 'Artifact_Timer', this['name'], time_elapsed)


def shuffle(contents):
Expand Down

0 comments on commit 2d7f4c9

Please sign in to comment.