def setUp(self): super(ProfileSinkTest, self).setUp() self.sink_db = self.client[self.__class__.SINK_TEST_DB] self._setup_test_collection() self._real_push = mongodrums.instrument.push self._msgs = [] mongodrums.instrument.push = self._push update({ 'instrument': {'sample_frequency': 1}, 'index_profile_sink': { 'mongo_uri': 'mongodb://127.0.0.1:27017/%s' % (self.__class__.SINK_TEST_DB) }, 'query_profile_sink': { 'mongo_uri': 'mongodb://127.0.0.1:27017/%s' % (self.__class__.SINK_TEST_DB) } }) self._index_profile_sink = IndexProfileSink() self._query_profile_sink = QueryProfileSink()
def run(self): logging.info('running collector...') update({'collector': { 'session': self.args.session, 'mongo_uri': self.args.uri, 'addr': self.args.addr, 'port': self.args.port }, 'index_profile_sink': { 'mongo_uri': self.args.uri }, 'query_profile_uri': { 'mongo_uri': self.args.uri }}) collector = CollectorRunner([IndexProfileSink(), QueryProfileSink()]) collector.start() while not should_exit: time.sleep(.1) collector.stop() collector.join() logging.info('collector stopped...')