SIENTIAPDE-1174
Add write_metrics activity to Gates for database metric logging and import metrics module
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from temporalio import workflow, activity
|
||||
|
||||
from scouter import metrics
|
||||
|
||||
with workflow.unsafe.imports_passed_through():
|
||||
from sientia_do.notifications.models import NotificationLevel
|
||||
from sientia_do.temporal.activities.base import BaseActivity
|
||||
@@ -74,7 +76,7 @@ class Gates(BaseActivity):
|
||||
Args:
|
||||
input_data (dict[str, Any]): The data to aggregate. Contains:
|
||||
data (dict[str, Any]): The time series data.
|
||||
model_tags (dict[str, Any]): The tags configuration
|
||||
model_tags (dict[str, Any]): The tags configuration
|
||||
containing aggregation functions.
|
||||
|
||||
Returns:
|
||||
@@ -253,3 +255,18 @@ class Gates(BaseActivity):
|
||||
)
|
||||
|
||||
return data.to_dict()
|
||||
|
||||
@activity.defn(name="write_metrics")
|
||||
async def write_metrics(self, input_data: dict[str, Any]) -> dict[str, Any]:
|
||||
"""
|
||||
Write metrics to the database.
|
||||
input_data:
|
||||
metadata: dict[str, Any]
|
||||
"""
|
||||
metadata = input_data['metadata']
|
||||
|
||||
metrics.LABORIOUS_DATA_WRITTEN_COUNT(
|
||||
pod_id=metadata['pod_id'],
|
||||
model_name=metadata['model_name'],
|
||||
pipeline_name=metadata['pipeline_name']
|
||||
).inc()
|
||||
|
||||
Reference in New Issue
Block a user