Skip to content

Commit

Permalink
Add metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
javitonino committed Jul 26, 2024
1 parent 21fa647 commit d78fb16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nucliadb/src/nucliadb/ingest/orm/processor/pgcatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions nucliadb/src/nucliadb/search/search/pgcatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
SortField,
SortOrder,
)
from nucliadb_telemetry import metrics
from nucliadb_utils import const
from nucliadb_utils.utilities import has_feature

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d78fb16

Please sign in to comment.