(self, prev_keys, key, data, publishfn=None)
Recursively publish keys
Recursively publish keys
Recursively publish keys
def _publish_metrics(self, prev_keys, key, data, publishfn=None):
        """Recursively publish keys"""
        if key not in data:
            return
        value = data[key]
        keys = prev_keys + [key]
        keys = [x.replace(" ", "_") for x in keys]
        if str_to_bool(self.config['replace_dashes_in_metric_keys']):
            keys = [x.replace("-", ".") for x in keys]
        if not publishfn:
            publishfn = self.publish
        if isinstance(value, dict):
            for new_key in value:
                self._publish_metrics(keys, new_key, value)
        elif isinstance(value, int) or isinstance(value, float):
            publishfn('.'.join(keys), value)
        elif isinstance(value, long):
            publishfn('.'.join(keys), float(value))
        elif isinstance(value, datetime.datetime):
            publishfn('.'.join(keys), long(value.strftime('%s')))
def _publish_metrics ( self , prev_keys , key , data , publishfn = None ) : if key not in data : return value = data [ key ] keys = prev_keys + [ key ] keys = [ x . replace ( " " , "_" ) for x in keys ] if str_to_bool ( self . config [ 'replace_dashes_in_metric_keys' ] ) : keys = [ x . replace ( "-" , "." ) for x in keys ] if not publishfn : publishfn = self . publish if isinstance ( value , dict ) : for new_key in value : self . _publish_metrics ( keys , new_key , value ) elif isinstance ( value , int ) or isinstance ( value , float ) : publishfn ( '.' . join ( keys ) , value ) elif isinstance ( value , long ) : publishfn ( '.' . join ( keys ) , float ( value ) ) elif isinstance ( value , datetime . datetime ) : publishfn ( '.' . join ( keys ) , long ( value . strftime ( '%s' ) ) )