-
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 sinks (#513)
<!-- Thanks for sending a pull request! Here are some tips for you: 1. Run unit tests and ensure that they are passing 2. If your change introduces any API changes, make sure to update the e2e tests 3. Make sure documentation is updated for your PR! --> # Description <!-- Briefly describe the motivation for the change. Please include illustrations where appropriate. --> Allow the observation publisher to publish to multiple sinks. Supported sinks are: Arize, BigQuery # Modifications <!-- Summarize the key code changes. --> - configuration format has been modified to support multiple sinks - update python requirement - fix mypy linter errors - Bigquery sink implementation # Tests <!-- Besides the existing / updated automated tests, what specific scenarios should be tested? Consider the backward compatibility of the changes, whether corner cases are covered, etc. Please describe the tests and check the ones that have been completed. Eg: - [x] Deploying new and existing standard models - [ ] Deploying PyFunc models --> # Checklist - [x] Added PR label - [x] Added unit test, integration, and/or e2e tests - [x] Tested locally - [ ] Updated documentation - [ ] Update Swagger spec if the PR introduce API changes - [ ] Regenerated Golang and Python client if the PR introduces API changes # Release Notes <!-- Does this PR introduce a user-facing change? If no, just write "NONE" in the release-note block below. If yes, a release note is required. Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". For more information about release notes, see kubernetes' guide here: http://git.k8s.io/community/contributors/guide/release-notes.md --> ```release-note ```
- Loading branch information
1 parent
10e5498
commit 7c835f5
Showing
15 changed files
with
581 additions
and
241 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from pandas import Timestamp | ||
from prometheus_client import Gauge, Counter | ||
|
||
|
||
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.total_prediction_logs_processed_counter = Counter( | ||
"total_prediction_logs_processed", | ||
"The total number of prediction logs processed by the publisher", | ||
) | ||
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()) | ||
|
||
def increment_total_prediction_logs_processed(self, value: int): | ||
""" | ||
Increments the total_prediction_logs_processed counter by value. | ||
:return: | ||
""" | ||
self.total_prediction_logs_processed_counter.labels( | ||
model_id=self.model_id, model_version=self.model_version | ||
).inc(value) |
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.