Skip to content

Commit

Permalink
Merge "Added per disk PUT timing monitoring support."
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Mar 6, 2013
2 parents 7fd4323 + 1d8a02f commit 28ac46d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/source/admin_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ Metric Name Description
`object-server.PUT.timeouts` Count of object PUTs which exceeded max_upload_time.
`object-server.PUT.timing` Timing data for each PUT request not resulting in an
error.
`object-server.PUT.<device>.timing` Timing data per kB transfered (ms/kB) for each
non-zero-byte PUT request on each device.
Monitoring problematic devices, higher is bad.
`object-server.GET.errors.timing` Timing data for GET request errors: bad request,
not mounted, header timestamps before the epoch,
precondition failed.
Expand Down
7 changes: 7 additions & 0 deletions swift/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ def timing_since(self, metric, orig_time, sample_rate=None):
return self.timing(metric, (time.time() - orig_time) * 1000,
sample_rate)

def transfer_rate(self, metric, elasped_time, byte_xfer, sample_rate=None):
if byte_xfer:
return self.timing(metric,
elasped_time * 1000 / byte_xfer * 1000,
sample_rate)


def timing_stats(**dec_kwargs):
"""
Expand Down Expand Up @@ -646,6 +652,7 @@ def wrapped(self, *a, **kw):
decrement = statsd_delegate('decrement')
timing = statsd_delegate('timing')
timing_since = statsd_delegate('timing_since')
transfer_rate = statsd_delegate('transfer_rate')


class SwiftLogFormatter(logging.Formatter):
Expand Down
7 changes: 7 additions & 0 deletions swift/obj/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,15 @@ def PUT(self, request):
etag = md5()
upload_size = 0
last_sync = 0
elasped_time = 0
with file.mkstemp() as fd:
try:
fallocate(fd, int(request.headers.get('content-length', 0)))
except OSError:
return HTTPInsufficientStorage(drive=device, request=request)
reader = request.environ['wsgi.input'].read
for chunk in iter(lambda: reader(self.network_chunk_size), ''):
start_time = time.time()
upload_size += len(chunk)
if time.time() > upload_expiration:
self.logger.increment('PUT.timeouts')
Expand All @@ -664,6 +666,11 @@ def PUT(self, request):
drop_buffer_cache(fd, last_sync, upload_size - last_sync)
last_sync = upload_size
sleep()
elasped_time += time.time() - start_time

if upload_size:
self.logger.transfer_rate(
'PUT.' + device + '.timing', elasped_time, upload_size)

if 'content-length' in request.headers and \
int(request.headers['content-length']) != upload_size:
Expand Down

0 comments on commit 28ac46d

Please sign in to comment.