chore: add monitoring on blockstructure_size (#36424)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
This commit is contained in:
committed by
GitHub
parent
9775ceff2b
commit
ae6b9c1b4a
@@ -16,6 +16,8 @@ from .factory import BlockStructureFactory
|
||||
from .models import BlockStructureModel
|
||||
from .transformer_registry import TransformerRegistry
|
||||
|
||||
from edx_django_utils import monitoring
|
||||
|
||||
logger = getLogger(__name__) # pylint: disable=C0103
|
||||
|
||||
|
||||
@@ -135,10 +137,15 @@ class BlockStructureStore:
|
||||
"""
|
||||
cache_key = self._encode_root_cache_key(bs_model)
|
||||
total_bytes_in_one_mb = 1024 * 1024
|
||||
if len(serialized_data) < total_bytes_in_one_mb * 2:
|
||||
data_size_in_mbs = round(len(serialized_data) / total_bytes_in_one_mb, 2)
|
||||
if data_size_in_mbs < total_bytes_in_one_mb * 2:
|
||||
self._cache.set(cache_key, serialized_data, timeout=config.cache_timeout_in_seconds())
|
||||
data_size_in_mbs = round(len(serialized_data) / total_bytes_in_one_mb, 2)
|
||||
logger.info("BlockStructure: Added to cache; %s, size: %dMB", bs_model, data_size_in_mbs)
|
||||
logger.info("BlockStructure: Added to cache; %s, size: %.2fMB", bs_model, data_size_in_mbs)
|
||||
else:
|
||||
# .. custom_attribute_name: blockstorestructure_size_in_mbs
|
||||
# .. custom_attribute_description: contains the data chunk size in MBs. The size on which
|
||||
# the memcached client failed to store value in cache.
|
||||
monitoring.set_custom_attribute('blockstorestructure_size_in_mbs', data_size_in_mbs)
|
||||
|
||||
def _get_from_cache(self, bs_model):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user