mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-24 00:29:53 -05:00
register_prom_metrics working in dev env
This commit is contained in:
parent
66827fbbcf
commit
80ce6c0ea6
@ -11,6 +11,24 @@ try:
|
|||||||
from http_sd_registry.config import ClientConfig
|
from http_sd_registry.config import ClientConfig
|
||||||
except ImportError:
|
except ImportError:
|
||||||
http_sd_registry = None
|
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 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
|
from prometheus_client import Counter, Gauge, Histogram, start_http_server
|
||||||
|
|
||||||
@ -29,10 +47,10 @@ brozzler_ydl_download_attempts = Counter("brozzler_ydl_download_attempts", "coun
|
|||||||
brozzler_ydl_download_successes = Counter("brozzler_ydl_download_successes", "count of downloads completed by brozzler yt-dlp", labelnames=["host"])
|
brozzler_ydl_download_successes = Counter("brozzler_ydl_download_successes", "count of downloads completed by brozzler yt-dlp", labelnames=["host"])
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
if http_sd_registry:
|
|
||||||
def register_prom_metrics(
|
def register_prom_metrics(
|
||||||
registry_url: Optional[str] = None, metrics_port: int = 8888, env: Env = Env.qa
|
registry_url: Optional[str] = None, metrics_port: int = 8888, env: Env = Env.qa
|
||||||
):
|
):
|
||||||
# Start metrics endpoint for scraping
|
# Start metrics endpoint for scraping
|
||||||
start_http_server(metrics_port)
|
start_http_server(metrics_port)
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import json
|
|||||||
import PIL.Image
|
import PIL.Image
|
||||||
import io
|
import io
|
||||||
import socket
|
import socket
|
||||||
|
import platform
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
import doublethink
|
import doublethink
|
||||||
@ -41,6 +42,18 @@ from . import ydl
|
|||||||
r = rdb.RethinkDB()
|
r = rdb.RethinkDB()
|
||||||
|
|
||||||
|
|
||||||
|
# Setup metrics
|
||||||
|
registry_url = None
|
||||||
|
metrics_port = 8090
|
||||||
|
env = metrics.Env.dev
|
||||||
|
hostname = platform.node()
|
||||||
|
if hostname.endswith("archive.org"):
|
||||||
|
registry_url = "http://wbgrp-svc283.us.archive.org:8888"
|
||||||
|
metrics_port = settings.metrics_port
|
||||||
|
env = metrics.Env.qa
|
||||||
|
metrics.register_prom_metrics(registry_url, metrics_port, env)
|
||||||
|
|
||||||
|
|
||||||
class BrozzlerWorker:
|
class BrozzlerWorker:
|
||||||
logger = logging.getLogger(__module__ + "." + __qualname__)
|
logger = logging.getLogger(__module__ + "." + __qualname__)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user