diff --git a/karapace/config.py b/karapace/config.py index 9212f6348..894164586 100644 --- a/karapace/config.py +++ b/karapace/config.py @@ -78,6 +78,8 @@ class Config(TypedDict): name_strategy_validation: bool master_election_strategy: str protobuf_runtime_directory: str + statsd_host: str + statsd_port: int sentry: NotRequired[Mapping[str, object]] tags: NotRequired[Mapping[str, object]] @@ -150,6 +152,8 @@ class ConfigDefaults(Config, total=False): "name_strategy_validation": True, "master_election_strategy": "lowest", "protobuf_runtime_directory": "runtime", + "statsd_host": "127.0.0.1", + "statsd_port": 8125, } SECRET_CONFIG_OPTIONS = [SASL_PLAIN_PASSWORD] diff --git a/karapace/statsd.py b/karapace/statsd.py index be37d92ef..3c32e09d8 100644 --- a/karapace/statsd.py +++ b/karapace/statsd.py @@ -20,19 +20,12 @@ import socket import time -STATSD_HOST: Final = "127.0.0.1" -STATSD_PORT: Final = 8125 LOG = logging.getLogger(__name__) class StatsClient: - def __init__( - self, - config: Config, - host: str = STATSD_HOST, - port: int = STATSD_PORT, - ) -> None: - self._dest_addr: Final = (host, port) + def __init__(self, config: Config) -> None: + self._dest_addr: Final = (config["statsd_host"], config["statsd_port"]) self._socket: Final = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self._tags: Final = config.get("tags", {}) self.sentry_client: Final = get_sentry_client(sentry_config=config.get("sentry", None))