-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for multiple sink types
- Loading branch information
1 parent
5c6d105
commit 7c641d4
Showing
17 changed files
with
565 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from pandas import Timestamp | ||
from prometheus_client import Gauge | ||
|
||
|
||
class MetricWriter(object): | ||
""" | ||
Singleton class for writing metrics to Prometheus. | ||
""" | ||
|
||
_instance = None | ||
|
||
def __init__(self): | ||
if not self._initialized: | ||
self.model_id = None | ||
self.model_version = "" | ||
self.last_processed_timestamp_gauge = Gauge( | ||
"last_processed_timestamp", | ||
"The timestamp of the last prediction log processed by the publisher", | ||
["model_id", "model_version"], | ||
) | ||
self._initialized = True | ||
|
||
def __new__(cls): | ||
if not cls._instance: | ||
cls._instance = super(MetricWriter, cls).__new__(cls) | ||
cls._instance._initialized = False | ||
return cls._instance | ||
|
||
def setup(self, model_id: str, model_version: str): | ||
""" | ||
Needs to be run before sending metrics, so that the singleton instance has the correct properties value. | ||
:param model_id: | ||
:param model_version: | ||
:return: | ||
""" | ||
self.model_id = model_id | ||
self.model_version = model_version | ||
|
||
def update_last_processed_timestamp(self, last_processed_timestamp: Timestamp): | ||
""" | ||
Updates the last_processed_timestamp gauge with the given value. | ||
:param last_processed_timestamp: | ||
:return: | ||
""" | ||
self.last_processed_timestamp_gauge.labels( | ||
model_id=self.model_id, model_version=self.model_version | ||
).set(last_processed_timestamp.timestamp()) |
113 changes: 0 additions & 113 deletions
113
python/observation-publisher/publisher/observability_backend.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.