diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..c8cfe39 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 diff --git a/ecommerce_exporter/cli.py b/ecommerce_exporter/cli.py index 17b4d76..adb2a9a 100644 --- a/ecommerce_exporter/cli.py +++ b/ecommerce_exporter/cli.py @@ -4,7 +4,6 @@ import time import yaml -from httpx import RequestError from prometheus_client import start_http_server, Gauge, Counter from ecommerce_exporter.scrape_target import ScrapeError, ScrapeTarget @@ -43,7 +42,7 @@ def main(): '--user-agent', help='The user-agent to spoof. (default: %(default)s)', type=str, - default='Mozilla/5.0 (X11; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0', + default='Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0', ) parser.add_argument( '-p', '--listen-port', @@ -69,6 +68,7 @@ def main(): } # start the http server to server the prometheus metrics + print("serving metrics on http://%s:%s/metrics" % (args.listen_address, args.listen_port)) start_http_server(args.listen_port, args.listen_address) # start the main loop @@ -85,7 +85,9 @@ def main(): product_name=scrape_target.product_name, target_name=scrape_target.target_name, ).inc() - except (RequestError, ScrapeError) as e: + except KeyboardInterrupt: + return + except Exception as e: print("Failed to scrape! product: '%s', target: '%s', message: '%s'" % (scrape_target.product_name, scrape_target.target_name, e)) ECOMMERCE_SCRAPE_TARGET_FAILURE.labels( product_name=scrape_target.product_name,