def test_create_stats_exporter_initialization(self, mock_transport): event = threading.Event() def _helper(request_iterator, context): for request in request_iterator: event.set() yield self._add_and_start_service(GenericRpcHandler(_helper)) exporter = ocagent.new_stats_exporter(SERVICE_NAME, endpoint='localhost:%s' % self._port, interval=0.1) self.assertEqual(mock_transport.call_args[0][0], stats_module.stats) self.assertEqual(mock_transport.call_args[0][1], exporter) self.assertEqual(mock_transport.call_args[0][2], 0.1) exporter.export_metrics([ _create_metric(points=[ point.Point(value.ValueLong(1), timestamp=datetime.now()) ]) ]) self.assertTrue(event.wait(timeout=1))
def register_all(service_name): view_manager = stats_module.stats.view_manager view_manager.register_exporter( stats_exporter.new_stats_exporter(service_name=service_name, endpoint='localhost:55678', interval=5)) registerAllViews(view_manager)
def test_create_stats_exporter_with_default_endpoint( self, mock_channel, _): ocagent.new_stats_exporter(SERVICE_NAME) self.assertEqual(mock_channel.call_args[0][0], 'localhost:55678')