def _traverse(metric, stats, ts, tags):
 if isinstance(stats, dict):
  if ('timestamp' in stats):
   ts = (stats['timestamp'] / 1000)
  for key in stats.keys():
   if (key != 'timestamp'):
    _traverse(((metric + '.') + key), stats[key], ts, tags)
 if isinstance(stats, (list, set, tuple)):
  count = 0
  for value in stats:
   _traverse(((metric + '.') + str(count)), value, ts, tags)
   count += 1
 if (utils.is_numeric(stats) and (not isinstance(stats, bool))):
  if isinstance(stats, int):
   stats = int(stats)
  printmetric(metric, ts, stats, tags)
 return

def _traverse ( metric , stats , ts , tags ) : if isinstance ( stats , dict ) : if ( 'timestamp' in stats ) : ts = ( stats [ 'timestamp' ] / 1000 ) for key in stats . keys ( ) : if ( key != 'timestamp' ) : _traverse ( ( ( metric + '.' ) + key ) , stats [ key ] , ts , tags ) if isinstance ( stats , ( list , set , tuple ) ) : count = 0 for value in stats : _traverse ( ( ( metric + '.' ) + str ( count ) ) , value , ts , tags ) count += 1 if ( utils . is_numeric ( stats ) and ( not isinstance ( stats , bool ) ) ) : if isinstance ( stats , int ) : stats = int ( stats ) printmetric ( metric , ts , stats , tags ) return
recursively traverse the json tree and print out leaf numeric values please make sure you call this inside a lock and dont add locking inside this function .