mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-04-20 23:56:34 -04:00
tidy params for register_prom_metrics
This commit is contained in:
parent
7b6c306d14
commit
66096453d1
@ -165,20 +165,6 @@ class BetterArgumentDefaultsHelpFormatter(argparse.ArgumentDefaultsHelpFormatter
|
||||
return super()._get_help_string(action)
|
||||
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
class Env(str, enum.Enum):
|
||||
"""Values of the Prometheus ``env`` label applied to a
|
||||
:py:class:`.Registration` indicating the deployment environment in which
|
||||
the service being advertised is operating.
|
||||
"""
|
||||
|
||||
qa = "qa"
|
||||
prod = "prod"
|
||||
dev = "dev"
|
||||
|
||||
|
||||
def brozzle_page(argv=None):
|
||||
"""
|
||||
Command line utility entry point for brozzling a single page. Opens url in
|
||||
@ -248,23 +234,17 @@ def brozzle_page(argv=None):
|
||||
action="store_true",
|
||||
help="Try to avoid web bot detection",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--registry_url",
|
||||
dest="registry_url",
|
||||
default=None,
|
||||
help="Prometheus registry url",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--metrics_port",
|
||||
dest=metrics_port,
|
||||
default=8889,
|
||||
dest="metrics_port",
|
||||
default=8888,
|
||||
help="Prometheus metrics port",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--env",
|
||||
dest=env,
|
||||
default=Env.dev,
|
||||
help="Prometheus env value",
|
||||
"--registry_url",
|
||||
dest="registry_url",
|
||||
default=None,
|
||||
help="registry url",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--screenshot-full-page", dest="screenshot_full_page", action="store_true"
|
||||
@ -311,9 +291,8 @@ def brozzle_page(argv=None):
|
||||
window_height=args.window_height,
|
||||
window_width=args.window_width,
|
||||
stealth=args.stealth,
|
||||
registry_url=args.registry_url,
|
||||
metrics_port=args.metrics_port,
|
||||
env=args.env,
|
||||
registry_url=args.registry_url,
|
||||
)
|
||||
|
||||
def on_screenshot(screenshot_jpeg):
|
||||
@ -552,12 +531,6 @@ def brozzler_worker(argv=None):
|
||||
action="store_true",
|
||||
help="Try to avoid web bot detection",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--registry_url",
|
||||
dest="registry_url",
|
||||
default=None,
|
||||
help="Prometheus registry url",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--metrics_port",
|
||||
dest=metrics_port,
|
||||
@ -565,10 +538,10 @@ def brozzler_worker(argv=None):
|
||||
help="Prometheus metrics port",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--env",
|
||||
dest=env,
|
||||
default=Env.qa,
|
||||
help="Prometheus env value",
|
||||
"--registry_url",
|
||||
dest="registry_url",
|
||||
default=None,
|
||||
help="registry url",
|
||||
)
|
||||
add_common_options(arg_parser, argv)
|
||||
|
||||
@ -626,9 +599,8 @@ def brozzler_worker(argv=None):
|
||||
skip_visit_hashtags=args.skip_visit_hashtags,
|
||||
skip_youtube_dl=args.skip_youtube_dl,
|
||||
stealth=args.stealth,
|
||||
registry_url=args.registry_url,
|
||||
metrics_port=args.metrics_port,
|
||||
env=args.env,
|
||||
registry_url=args.registry_url,
|
||||
)
|
||||
|
||||
signal.signal(signal.SIGQUIT, dump_state)
|
||||
|
@ -11,24 +11,7 @@ try:
|
||||
from http_sd_registry.config import ClientConfig
|
||||
except ImportError:
|
||||
http_sd_registry = None
|
||||
Client = None
|
||||
|
||||
import enum # type: ignore
|
||||
|
||||
class Env(str, enum.Enum):
|
||||
"""Values of the Prometheus ``env`` label applied to a
|
||||
:py:class:`.Registration` indicating the deployment environment in which
|
||||
the service being advertised is operating.
|
||||
"""
|
||||
|
||||
qa = "qa"
|
||||
prod = "prod"
|
||||
dev = "dev"
|
||||
|
||||
Registration = None
|
||||
Scheme = None
|
||||
format_self_target = None
|
||||
ClientConfig = None
|
||||
|
||||
from prometheus_client import Counter, Gauge, Histogram, start_http_server
|
||||
|
||||
@ -49,7 +32,9 @@ brozzler_ydl_download_successes = Counter("brozzler_ydl_download_successes", "co
|
||||
|
||||
|
||||
def register_prom_metrics(
|
||||
registry_url: Optional[str] = None, metrics_port: int = 8888, env: Env = Env.qa
|
||||
metrics_port: int = 8888,
|
||||
registry_url: Optional[str] = None,
|
||||
env: Optional[str] = None,
|
||||
):
|
||||
# Start metrics endpoint for scraping
|
||||
start_http_server(metrics_port)
|
||||
|
@ -112,10 +112,7 @@ class BrozzlerWorker:
|
||||
self._shutdown = threading.Event()
|
||||
|
||||
# Setup metrics
|
||||
registry_url = self._registry_url
|
||||
metrics_port = self._metrics_port
|
||||
env = self._env
|
||||
metrics.register_prom_metrics(registry_url, metrics_port, env)
|
||||
metrics.register_prom_metrics(self._metrics_port, self._registry_url)
|
||||
|
||||
def _choose_warcprox(self):
|
||||
warcproxes = self._service_registry.available_services("warcprox")
|
||||
|
Loading…
x
Reference in New Issue
Block a user