Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus client metrics support #710

Closed
wants to merge 34 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e3cb524
Karapace metrics
libretto Jun 9, 2023
32ce060
Merge branch 'master' into karapace-metrics
libretto Jun 9, 2023
8dab84d
fixup issues
libretto Jun 10, 2023
2898e31
fixup issues
libretto Jun 10, 2023
c974579
fixup annotations issue
libretto Jun 12, 2023
7256f5d
fixup exception message
libretto Jun 12, 2023
ab6ae96
get rid of multiple instances of class
libretto Jun 12, 2023
733d1f2
fixup issue
libretto Jun 12, 2023
8751eea
change code to send raw data only
libretto Jun 16, 2023
53d3e4b
merge with master
libretto Jun 16, 2023
fedff8f
fixup
libretto Jun 22, 2023
31d16d4
Merge branch 'master' into karapace-metrics
libretto Jun 22, 2023
b70ae03
fixup code
libretto Jun 22, 2023
a0387a3
fixup
libretto Jun 22, 2023
358facc
fixup
libretto Jun 22, 2023
a064624
merge
libretto Jul 3, 2023
8533959
improve code by request
libretto Aug 8, 2023
ac48829
merge with main
libretto Aug 8, 2023
90e221c
add psutil typing support
libretto Aug 8, 2023
4c48576
fixup
libretto Aug 8, 2023
f9cb6d8
fixup
libretto Aug 8, 2023
765864b
Merge branch 'main' into karapace-metrics
libretto Aug 30, 2023
9cdcba7
add prometheus support
libretto Sep 2, 2023
073aa16
merge with master
libretto Sep 2, 2023
75b2913
Merge branch 'karapace-metrics' into prometheus
libretto Sep 2, 2023
30a30ad
refactoring
libretto Sep 2, 2023
0c73a1a
refactor
libretto Sep 2, 2023
c495c50
fixup
libretto Sep 2, 2023
61e659d
fixup
libretto Sep 2, 2023
33f6ceb
fixup issues
libretto Sep 5, 2023
34fa7dc
fixup
libretto Sep 5, 2023
46605f4
fixup
libretto Sep 5, 2023
f670782
fixup
libretto Sep 5, 2023
ff8bf58
fixup
libretto Sep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion karapace/base_stats.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ def __init__(
self,
config: Config,
) -> None:
self._tags: Final = config.get("tags", {})
self.sentry_client: Final = get_sentry_client(sentry_config=config.get("sentry", None))

@contextmanager
8 changes: 4 additions & 4 deletions karapace/metrics.py
Original file line number Diff line number Diff line change
@@ -39,22 +39,22 @@ def __call__(cls, *args: str, **kwargs: int) -> Singleton:
class Metrics(metaclass=Singleton):
def __init__(self) -> None:
self.active = False
self.stats_client: StatsClient | None
self.stats_client: StatsClient
self.is_ready = False
self.stop_event = threading.Event()
self.worker_thread = threading.Thread(target=self.worker)
self.lock = threading.Lock()

def setup(self, stats_client: StatsClient, config: Config) -> None:
def setup(self, config: Config) -> None:
stats_service = config.get("stats_service")
if stats_service == "statsd":
self.stats_client = StatsdClient(config=config)
elif stats_service == "prometheus":
self.stats_client = PrometheusClient(config=config)
else:
raise MetricsException('Config variable "stats_service" is not defined')

self.active = config.get("metrics_extended")
if config.get("metrics_extended"): # for mypy check pass
self.active = True
if not self.active:
return
with self.lock:
3 changes: 3 additions & 0 deletions karapace/statsd.py
Original file line number Diff line number Diff line change
@@ -30,6 +30,9 @@ def __init__(
host: str = STATSD_HOST,
port: int = STATSD_PORT,
) -> None:

super().__init__(config)
self._tags: Final[dict] = config.get("tags", {})
_host = config.get("statsd_host") if "statsd_host" in config else host
_port = config.get("statsd_port") if "statsd_port" in config else port
self._dest_addr: Final = (_host, _port)