def test_no_tracestate(self): traceparent = '00-1af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01' settings = {'opentelemetry_traceparent': traceparent} with self.created_client(settings=settings) as client: with capture_logging('clickhouse_driver.log', 'INFO') as buffer: settings = {'send_logs_level': 'trace'} query = 'SELECT 1' client.execute(query, settings=settings) value = buffer.getvalue() self.assertIn('OpenTelemetry', value) self.assertIn('1af7651916cd43dd8448eb211c80319c', value)
def test_logs_with_compression(self): compression = 'lz4' supported_compressions = (file_config.get('db', 'compression').split(',')) if compression not in supported_compressions: self.skipTest( 'Compression {} is not supported'.format(compression)) with self.created_client(compression='lz4') as client: with capture_logging('clickhouse_driver.log', 'INFO') as buffer: settings = {'send_logs_level': 'debug'} query = 'SELECT 1' client.execute(query, settings=settings) self.assertIn(query, buffer.getvalue())
def test_logs_insert(self): with capture_logging('clickhouse_driver.log', 'INFO') as buffer: with self.create_table('a Int32'): settings = {'send_logs_level': 'debug'} query = 'INSERT INTO test (a) VALUES' self.client.execute(query, [(1, )], settings=settings) logs = buffer.getvalue() self.assertIn(query, logs) if self.server_version > (19, ): self.assertIn('MemoryTracker', logs) # Test all packets of INSERT query are consumed. rv = self.client.execute('SELECT 1', settings=settings) self.assertEqual(rv, [(1, )])
def test_logs(self): with capture_logging('clickhouse_driver.log', 'INFO') as buffer: settings = {'send_logs_level': 'debug'} query = 'SELECT 1' self.client.execute(query, settings=settings) self.assertIn(query, buffer.getvalue())