Skip to content
Snippets Groups Projects
Commit 5573b1b9 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

base_checker: Set statsd constant tags in base checker classes

parent d8c04aaa
No related branches found
No related tags found
3 merge requests!69cli: Add support for scrubbbing an object storage,!66objstorage_checker: Use check method from object storage interface,!65objstorage_checker: Add support for consuming content ids from journal
...@@ -29,10 +29,14 @@ class BaseChecker(ABC): ...@@ -29,10 +29,14 @@ class BaseChecker(ABC):
): ):
self.db = db self.db = db
self.config_id = config_id self.config_id = config_id
self.statsd_constant_tags: Dict[str, Any] = {}
self._config: Optional[ConfigEntry] = None self._config: Optional[ConfigEntry] = None
self._statsd: Optional[Statsd] = None self._statsd: Optional[Statsd] = None
self.statsd_constant_tags: Dict[str, Any] = {
"object_type": self.object_type.name.lower(),
"datastore_package": self.datastore.package,
"datastore_cls": self.datastore.cls,
"datastore_instance": self.datastore.instance,
}
@property @property
def config(self) -> ConfigEntry: def config(self) -> ConfigEntry:
...@@ -59,6 +63,11 @@ class BaseChecker(ABC): ...@@ -59,6 +63,11 @@ class BaseChecker(ABC):
) )
return self._statsd return self._statsd
@property
def object_type(self) -> swhids.ObjectType:
"""Returns the type of object being checked."""
return self.config.object_type
@property @property
def check_hashes(self) -> bool: def check_hashes(self) -> bool:
return self.config.check_hashes return self.config.check_hashes
...@@ -84,17 +93,7 @@ class BasePartitionChecker(BaseChecker): ...@@ -84,17 +93,7 @@ class BasePartitionChecker(BaseChecker):
): ):
super().__init__(db=db, config_id=config_id) super().__init__(db=db, config_id=config_id)
self.limit = limit self.limit = limit
self.statsd_constant_tags = { self.statsd_constant_tags["nb_partitions"] = self.nb_partitions
"object_type": self.object_type,
"nb_partitions": self.nb_partitions,
"datastore_package": self.datastore.package,
"datastore_cls": self.datastore.cls,
}
@property
def object_type(self) -> swhids.ObjectType:
"""Returns the type of object being checked."""
return self.config.object_type
@property @property
def nb_partitions(self) -> int: def nb_partitions(self) -> int:
......
...@@ -49,10 +49,6 @@ class JournalChecker(BaseChecker): ...@@ -49,10 +49,6 @@ class JournalChecker(BaseChecker):
self, db: ScrubberDb, config_id: int, journal_client_config: Dict[str, Any] self, db: ScrubberDb, config_id: int, journal_client_config: Dict[str, Any]
): ):
super().__init__(db=db, config_id=config_id) super().__init__(db=db, config_id=config_id)
self.statsd_constant_tags = {
"datastore_package": self.datastore.package,
"datastore_cls": self.datastore.cls,
}
if self.config.check_references: if self.config.check_references:
raise ValueError( raise ValueError(
...@@ -66,9 +62,7 @@ class JournalChecker(BaseChecker): ...@@ -66,9 +62,7 @@ class JournalChecker(BaseChecker):
"The journal_client configuration entry should not define the " "The journal_client configuration entry should not define the "
"object_types field; this is handled by the scrubber configuration entry" "object_types field; this is handled by the scrubber configuration entry"
) )
self.journal_client_config["object_types"] = [ self.journal_client_config["object_types"] = [self.object_type.name.lower()]
self.config.object_type.name.lower()
]
self.journal_client = get_journal_client( self.journal_client = get_journal_client(
**self.journal_client_config, **self.journal_client_config,
# Remove default deserializer; so process_kafka_values() gets the message # Remove default deserializer; so process_kafka_values() gets the message
......
...@@ -49,7 +49,6 @@ class ObjectStorageChecker(BasePartitionChecker): ...@@ -49,7 +49,6 @@ class ObjectStorageChecker(BasePartitionChecker):
self.objstorage = ( self.objstorage = (
objstorage if objstorage is not None else getattr(storage, "objstorage") objstorage if objstorage is not None else getattr(storage, "objstorage")
) )
self.statsd_constant_tags["datastore_instance"] = self.datastore.instance
def check_partition(self, object_type: ObjectType, partition_id: int) -> None: def check_partition(self, object_type: ObjectType, partition_id: int) -> None:
if object_type != ObjectType.CONTENT: if object_type != ObjectType.CONTENT:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment