diff --git a/nucliadb/src/nucliadb/ingest/orm/processor/pgcatalog.py b/nucliadb/src/nucliadb/ingest/orm/processor/pgcatalog.py index 8f9682184d..00da41eab2 100644 --- a/nucliadb/src/nucliadb/ingest/orm/processor/pgcatalog.py +++ b/nucliadb/src/nucliadb/ingest/orm/processor/pgcatalog.py @@ -23,11 +23,14 @@ from nucliadb.common.maindb.driver import Transaction from nucliadb.common.maindb.pg import PGDriver, PGTransaction from nucliadb.common.maindb.utils import get_driver +from nucliadb_telemetry import metrics from nucliadb_utils import const from nucliadb_utils.utilities import has_feature from ..resource import Resource +observer = metrics.Observer("pg_catalog_write", labels={"type": ""}) + def _pg_transaction(txn: Transaction) -> PGTransaction: return cast(PGTransaction, txn) @@ -39,6 +42,7 @@ def pgcatalog_enabled(kbid): ) +@observer.wrap({"type": "update"}) async def pgcatalog_update(txn: Transaction, kbid: str, resource: Resource): if not pgcatalog_enabled(kbid): return @@ -69,6 +73,7 @@ async def pgcatalog_update(txn: Transaction, kbid: str, resource: Resource): ) +@observer.wrap({"type": "delete"}) async def pgcatalog_delete(txn: Transaction, kbid: str, rid: str): if not pgcatalog_enabled(kbid): return diff --git a/nucliadb/src/nucliadb/search/search/pgcatalog.py b/nucliadb/src/nucliadb/search/search/pgcatalog.py index e794cdbc8b..1ec3d632e3 100644 --- a/nucliadb/src/nucliadb/search/search/pgcatalog.py +++ b/nucliadb/src/nucliadb/search/search/pgcatalog.py @@ -32,6 +32,7 @@ SortField, SortOrder, ) +from nucliadb_telemetry import metrics from nucliadb_utils import const from nucliadb_utils.utilities import has_feature @@ -149,6 +150,7 @@ def pgcatalog_enabled(kbid): ) +@metrics.Observer("pg_catalog_search").wrap() async def pgcatalog_search(query_parser: QueryParser) -> Resources: # Prepare SQL query query, query_params = _prepare_query(query_parser)