def put_object(objstorage, obj_id, obj): try: with statsd.timed(CONTENT_DURATION_METRIC, tags={"request": "put"}): obj = objstorage.add(obj, obj_id, check_presence=False) logger.debug("stored %(obj_id)s", {"obj_id": hash_to_hex(obj_id)}) except Exception as exc: raise ReplayError(obj_id=obj_id, exc=exc) from None
def process_replay_objects(all_objects: Dict[str, List[BaseModel]], *, storage: StorageInterface) -> None: for (object_type, objects) in all_objects.items(): logger.debug("Inserting %s %s objects", len(objects), object_type) with statsd.timed(GRAPH_DURATION_METRIC, tags={"object_type": object_type}): _insert_objects(object_type, objects, storage) statsd.increment(GRAPH_OPERATIONS_METRIC, len(objects), tags={"object_type": object_type}) if notify: notify("WATCHDOG=1")
def get_object(objstorage, obj_id): try: with statsd.timed(CONTENT_DURATION_METRIC, tags={"request": "get"}): obj = objstorage.get(obj_id) logger.debug("retrieved %(obj_id)s", {"obj_id": hash_to_hex(obj_id)}) return obj except ObjNotFoundError: logger.error( "Failed to retrieve %(obj_id)s: object not found", {"obj_id": hash_to_hex(obj_id)}, ) raise except Exception as exc: raise ReplayError(obj_id=obj_id, exc=exc) from None
def test_timed_elapsed(statsd): with statsd.timed("test_timer") as t: pass assert t.elapsed >= 0 assert statsd.socket.recv() == "test_timer:%s|ms" % t.elapsed
def d(*a, **kw): with statsd.timed(DURATION_METRIC, tags={"endpoint": f.__name__}): return f(*a, **kw)
def timed_context(f_name): with statsd.timed("swh_objstorage_request_duration_seconds", tags={"endpoint": f_name}): yield
def w(*a, **kw): with statsd.timed("swh_objstorage_request_duration_seconds", tags={"endpoint": f.__name__}): return f(*a, **kw)