def emit(
        self,
        feature_key,
        feature_val,
        feature_type=None,
    ):

        # Add metadata as first feature

        if self.num_features == 0:
            try:
                metadata = copy.deepcopy(self.emitter_args)

                # Update timestamp to the actual emit time

                metadata['timestamp'] = \
                    time.strftime('%Y-%m-%dT%H:%M:%S%z')
                if 'extra' in metadata:
                    del metadata['extra']
                    if self.emitter_args['extra']:
                        metadata.update(json.loads(self.emitter_args['extra'
                                                                     ]))
                if 'extra_all_features' in metadata:
                    del metadata['extra_all_features']
                if self.format == 'csv':
                    self.csv_writer.writerow(
                        ['metadata',
                         json.dumps('metadata'),
                         json.dumps(metadata,
                                    separators=(',', ':'))])
                    self.num_features += 1
            except Exception as e:
                logger.exception(e)
                raise

        feature_type = feature_type or self._get_feature_type(feature_val)
        if isinstance(feature_val, dict):
            feature_val_as_dict = feature_val
        else:
            feature_val_as_dict = feature_val._asdict()
        if 'extra' in self.emitter_args and self.emitter_args['extra'] \
                and 'extra_all_features' in self.emitter_args \
                and self.emitter_args['extra_all_features'] == True:
            feature_val_as_dict.update(json.loads(self.emitter_args['extra'
                                                                    ]))
        try:
            if self.format == 'csv':
                self.csv_writer.writerow(
                    [feature_type,
                     json.dumps(feature_key),
                     json.dumps(feature_val_as_dict,
                                separators=(',', ':'))])
            elif self.format == 'graphite':
                if 'namespace' in self.emitter_args:
                    namespace = self.emitter_args['namespace']
                else:
                    namespace = 'undefined'
                self.emit_dict_as_graphite(
                    namespace,
                    feature_type,
                    feature_key,
                    feature_val_as_dict)
            else:
                raise Exception('Unsupported emitter format.')
            self.num_features += 1
        except Exception as e:
            logger.exception(e)
            raise
dataset/ETHPy150Open cloudviz/agentless-system-crawler/crawler/emitter.py/Emitter.emit/original