github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/examples/java-jfr/rideshare/load-generator.py (about) 1 import random 2 import requests 3 import time 4 import traceback 5 6 HOSTS = [ 7 'us-east', 8 'eu-north', 9 'ap-south', 10 ] 11 12 VEHICLES = [ 13 'bike', 14 'scooter', 15 'car', 16 ] 17 18 if __name__ == "__main__": 19 print(f"starting load generator") 20 time.sleep(3) 21 while True: 22 host = HOSTS[random.randint(0, len(HOSTS) - 1)] 23 vehicle = VEHICLES[random.randint(0, len(VEHICLES) - 1)] 24 print(f"requesting {vehicle} from {host}") 25 try: 26 resp = requests.get(f'http://{host}:5000/{vehicle}') 27 resp.raise_for_status() 28 print(f"received {resp}") 29 except BaseException as e: 30 print (f"http error {e}") 31 32 time.sleep(random.uniform(0.2, 0.4))