Skip to content

Commit

Permalink
Expose karton metrics via the backend API (#109)
Browse files Browse the repository at this point in the history
* Expose karton metrics via the backend API

* Update the docs

Co-authored-by: msm <msm@cert.pl>
  • Loading branch information
msm-code and msm-code authored Mar 17, 2021
1 parent d94ce4e commit ab6b99d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions karton/core/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ def increment_metrics(self, metric: KartonMetrics, identity: str) -> None:
"""
self.redis.hincrby(metric.value, identity, 1)

def get_metrics(self, metric: KartonMetrics) -> Dict[str, int]:
"""
Get a {karton-identity: current-number-of-tasks} mapping for a given metric.
:param metric: Operation metric type
"""
return {k: int(v) for k, v in self.redis.hgetall(metric.value).items()}

def upload_object(
self,
bucket: str,
Expand Down

0 comments on commit ab6b99d

Please sign in to comment.