Skip to content

Commit

Permalink
Fix doc issues
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavsingh committed Aug 11, 2024
1 parent 975b6b6 commit f16a528
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes --output-file=docs/requirements.txt --strip-extras docs/requirements.in
Expand Down
16 changes: 4 additions & 12 deletions proxy/http/server/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
import os
import glob
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Generator
from typing import Any, Dict, List, Tuple, Generator, cast
from pathlib import Path
from urllib.parse import parse_qs, urlparse
from multiprocessing.synchronize import Lock
Expand All @@ -27,10 +27,6 @@
)


if TYPE_CHECKING:
from prometheus_client.registry import Collector


flags.add_argument(
'--enable-metrics',
action='store_true',
Expand Down Expand Up @@ -92,12 +88,7 @@ def _set_gauge(self, name: str, value: float) -> None:
g.write(str(value))

Check warning on line 88 in proxy/http/server/metrics.py

View check run for this annotation

Codecov / codecov/patch

proxy/http/server/metrics.py#L88

Added line #L88 was not covered by tests


def get_collector(metrics_lock: Lock) -> 'Collector':
"""
Returns an instance of the `Collector` class.
:rtype: prometheus_client.core.Collector
"""
def get_collector(metrics_lock: Lock) -> Any:
# pylint: disable=import-outside-toplevel
from prometheus_client.core import Metric
from prometheus_client.registry import Collector

Check warning on line 94 in proxy/http/server/metrics.py

View check run for this annotation

Codecov / codecov/patch

proxy/http/server/metrics.py#L93-L94

Added lines #L93 - L94 were not covered by tests
Expand Down Expand Up @@ -195,10 +186,11 @@ class MetricsWebServerPlugin(HttpWebServerBasePlugin):
def __init__(self, *args: Any, **kwargs: Any) -> None:
# pylint: disable=import-outside-toplevel
from prometheus_client.core import CollectorRegistry
from prometheus_client.registry import Collector

Check warning on line 189 in proxy/http/server/metrics.py

View check run for this annotation

Codecov / codecov/patch

proxy/http/server/metrics.py#L188-L189

Added lines #L188 - L189 were not covered by tests

super().__init__(*args, **kwargs)
self.registry = CollectorRegistry()
self.registry.register(get_collector(self.flags.metrics_lock))
self.registry.register(cast(Collector, get_collector(self.flags.metrics_lock)))

Check warning on line 193 in proxy/http/server/metrics.py

View check run for this annotation

Codecov / codecov/patch

proxy/http/server/metrics.py#L191-L193

Added lines #L191 - L193 were not covered by tests

def routes(self) -> List[Tuple[int, str]]:
if self.flags.metrics_path:
Expand Down

0 comments on commit f16a528

Please sign in to comment.