1
0
Fork 0

rename project to ecommerce-exporter

This commit is contained in:
Massaki Archambault 2022-10-31 17:54:13 -04:00
parent b38df4b298
commit f7afcfe991
8 changed files with 16 additions and 16 deletions

2
.gitignore vendored
View File

@ -202,4 +202,4 @@ tags
[._]*.un~ [._]*.un~
### Project-specific ### Project-specific
webscraping-exporter.yml ecommerce-exporter.yml

View File

@ -2,4 +2,4 @@ FROM python:3.10
COPY . /tmp/package COPY . /tmp/package
RUN pip install --no-cache-dir /tmp/package && \ RUN pip install --no-cache-dir /tmp/package && \
rm -r /tmp/package rm -r /tmp/package
ENTRYPOINT ["webscraping-exporter"] ENTRYPOINT ["ecommerce-exporter"]

View File

@ -1,2 +1,2 @@
# webscraping-exporter # ecommerce-exporter

View File

@ -7,20 +7,20 @@ import yaml
from httpx import RequestError from httpx import RequestError
from prometheus_client import start_http_server, Gauge, Counter from prometheus_client import start_http_server, Gauge, Counter
from webscraping_exporter.scrape_target import ScrapeError, ScrapeTarget from ecommerce_exporter.scrape_target import ScrapeError, ScrapeTarget
WEBSCRAPING_SCRAPE_TARGET_VALUE = Gauge( ECOMMERCE_SCRAPE_TARGET_VALUE = Gauge(
'webscraping_scrape_target_value', 'ecommerce_scrape_target_value',
'The value scraped from a scrape target', 'The value scraped from a scrape target',
['product_name', 'target_name'], ['product_name', 'target_name'],
) )
WEBSCRAPING_SCRAPE_TARGET_SUCCESS = Counter( ECOMMERCE_SCRAPE_TARGET_SUCCESS = Counter(
'webscraping_scrape_target_success_total', 'ecommerce_scrape_target_success_total',
'The number of successful scrape and parse of a scrape target', 'The number of successful scrape and parse of a scrape target',
['product_name', 'target_name'], ['product_name', 'target_name'],
) )
WEBSCRAPING_SCRAPE_TARGET_FAILURE = Counter( ECOMMERCE_SCRAPE_TARGET_FAILURE = Counter(
'webscraping_scrape_target_failure_total', 'ecommerce_scrape_target_failure_total',
'The number of failed scrape and parse of a scrape target', 'The number of failed scrape and parse of a scrape target',
['product_name', 'target_name', 'exception'], ['product_name', 'target_name', 'exception'],
) )
@ -31,7 +31,7 @@ def main():
'-c', '--config', '-c', '--config',
help='The configuration file. (default: %(default)s)', help='The configuration file. (default: %(default)s)',
type=str, type=str,
default='webscraping-exporter.yml', default='ecommerce-exporter.yml',
) )
parser.add_argument( parser.add_argument(
'-i', '--interval', '-i', '--interval',
@ -77,17 +77,17 @@ def main():
try: try:
print("Starting scrape. product: '%s', target '%s'" % (scrape_target.product_name, scrape_target.target_name)) print("Starting scrape. product: '%s', target '%s'" % (scrape_target.product_name, scrape_target.target_name))
value = scrape_target.query_target() value = scrape_target.query_target()
WEBSCRAPING_SCRAPE_TARGET_VALUE.labels( ECOMMERCE_SCRAPE_TARGET_VALUE.labels(
product_name=scrape_target.product_name, product_name=scrape_target.product_name,
target_name=scrape_target.target_name target_name=scrape_target.target_name
).set(value) ).set(value)
WEBSCRAPING_SCRAPE_TARGET_SUCCESS.labels( ECOMMERCE_SCRAPE_TARGET_SUCCESS.labels(
product_name=scrape_target.product_name, product_name=scrape_target.product_name,
target_name=scrape_target.target_name, target_name=scrape_target.target_name,
).inc() ).inc()
except (RequestError, ScrapeError) as e: except (RequestError, ScrapeError) as e:
print("Failed to scrape! product: '%s', target: '%s', message: '%s'" % (scrape_target.product_name, scrape_target.target_name, e)) print("Failed to scrape! product: '%s', target: '%s', message: '%s'" % (scrape_target.product_name, scrape_target.target_name, e))
WEBSCRAPING_SCRAPE_TARGET_FAILURE.labels( ECOMMERCE_SCRAPE_TARGET_FAILURE.labels(
product_name=scrape_target.product_name, product_name=scrape_target.product_name,
target_name=scrape_target.target_name, target_name=scrape_target.target_name,
exception=e.__class__.__name__, exception=e.__class__.__name__,

View File

@ -1,5 +1,5 @@
[metadata] [metadata]
name = webscraping-exporter name = ecommerce-exporter
author = badjware author = badjware
author_email = marchambault.badjware.dev author_email = marchambault.badjware.dev
platform = any platform = any
@ -18,6 +18,6 @@ install_requires=
[options.entry_points] [options.entry_points]
console_scripts = console_scripts =
webscraping-exporter = webscraping_exporter.cli:main ecommerce-exporter = ecommerce_exporter.cli:main
[tool.setuptools_scm] [tool.setuptools_scm]