Skip to content

Commit

Permalink
tidy params for register_prom_metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Barbara Miller committed Sep 13, 2024
1 parent 7b6c306 commit 776840c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 57 deletions.
50 changes: 11 additions & 39 deletions brozzler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,6 @@ def _get_help_string(self, action):
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
Expand Down Expand Up @@ -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,
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"
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -552,23 +531,17 @@ 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,
default=8888,
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)

Expand Down Expand Up @@ -626,9 +599,8 @@ def get_skip_av_seeds():
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)
Expand Down
19 changes: 1 addition & 18 deletions brozzler/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,7 @@
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

Expand All @@ -49,7 +32,7 @@ class Env(str, enum.Enum):


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)
Expand Down

0 comments on commit 776840c

Please sign in to comment.