diff options
author | 2015-10-15 10:48:58 -0400 | |
---|---|---|
committer | 2015-10-15 19:08:24 +0000 | |
commit | e708f56598414929091524ce68a56da602d082e7 (patch) | |
tree | 26867be9b46ce0e47af1dd236d9ba186e3e29291 /storperf/carbon/converter.py | |
parent | b0f94dcb1f28161d4ab2fb186e4867b2ba473a32 (diff) |
Logging and timestamp
Added logging and fixed issue if fio does not produce the current timestamp
in its output
JIRA: STORPERF-4
Change-Id: Ifd0dbc4e17d984907e63089ebfae1d0e9e749dcc
Signed-off-by: mbeierl <mark.beierl@emc.com>
Diffstat (limited to 'storperf/carbon/converter.py')
-rw-r--r-- | storperf/carbon/converter.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/storperf/carbon/converter.py b/storperf/carbon/converter.py index 4ad5be2..42dbeef 100644 --- a/storperf/carbon/converter.py +++ b/storperf/carbon/converter.py @@ -6,13 +6,22 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import calendar +import logging +import time class JSONToCarbon(object): def __init__(self): - pass - + self.logger = logging.getLogger(__name__) + def convert_to_dictionary(self, json_object, prefix=None): - self.timestamp = str(json_object['timestamp']) + # Use the timestamp reported by fio, or current time if + # not present. + if 'timestamp' in json_object: + self.timestamp = str(json_object['timestamp']) + else: + self.timestamp = str(calendar.timegm(time.gmtime())) + self.flat_dictionary = {} self.resurse_to_flat_dictionary(json_object, prefix) return self.flat_dictionary |