mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-28 21:49:40 +02:00
feat(observability): add etl cache lookup and eviction metrics
This commit is contained in:
parent
d5e0280097
commit
9efe24879d
1 changed files with 40 additions and 0 deletions
|
|
@ -289,6 +289,22 @@ def _etl_extract_outcome():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=1)
|
||||||
|
def _etl_cache_lookups():
|
||||||
|
return _get_meter().create_counter(
|
||||||
|
"surfsense.etl.cache.lookups",
|
||||||
|
description="Count of ETL parse-cache lookups by outcome (hit/miss).",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=1)
|
||||||
|
def _etl_cache_evictions():
|
||||||
|
return _get_meter().create_counter(
|
||||||
|
"surfsense.etl.cache.evictions",
|
||||||
|
description="Count of ETL parse-cache entries evicted, by phase.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
def _celery_heartbeat_refreshes():
|
def _celery_heartbeat_refreshes():
|
||||||
return _get_meter().create_counter(
|
return _get_meter().create_counter(
|
||||||
|
|
@ -670,6 +686,28 @@ def record_etl_extract_outcome(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def record_etl_cache_lookup(
|
||||||
|
*, etl_service: str | None, mode: str | None, outcome: str
|
||||||
|
) -> None:
|
||||||
|
"""Record a parse-cache lookup. ``outcome`` is ``hit`` or ``miss``."""
|
||||||
|
_add(
|
||||||
|
_etl_cache_lookups(),
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
"etl.service": etl_service or "unknown",
|
||||||
|
"mode": mode or "unknown",
|
||||||
|
"outcome": outcome,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def record_etl_cache_eviction(count: int, *, phase: str) -> None:
|
||||||
|
"""Record evicted entries. ``phase`` is ``ttl`` or ``size``."""
|
||||||
|
if count <= 0:
|
||||||
|
return
|
||||||
|
_add(_etl_cache_evictions(), count, {"phase": phase})
|
||||||
|
|
||||||
|
|
||||||
def record_celery_heartbeat_refresh(*, heartbeat_type: str) -> None:
|
def record_celery_heartbeat_refresh(*, heartbeat_type: str) -> None:
|
||||||
_add(_celery_heartbeat_refreshes(), 1, {"heartbeat.type": heartbeat_type})
|
_add(_celery_heartbeat_refreshes(), 1, {"heartbeat.type": heartbeat_type})
|
||||||
|
|
||||||
|
|
@ -866,6 +904,8 @@ __all__ = [
|
||||||
"record_compaction_run",
|
"record_compaction_run",
|
||||||
"record_connector_sync_duration",
|
"record_connector_sync_duration",
|
||||||
"record_connector_sync_outcome",
|
"record_connector_sync_outcome",
|
||||||
|
"record_etl_cache_eviction",
|
||||||
|
"record_etl_cache_lookup",
|
||||||
"record_etl_extract_duration",
|
"record_etl_extract_duration",
|
||||||
"record_etl_extract_outcome",
|
"record_etl_extract_outcome",
|
||||||
"record_indexing_document_duration",
|
"record_indexing_document_duration",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue