Skip to content

Commit

Permalink
ota_proxy: use get_burst_suppressed_logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Dec 25, 2024
1 parent fd8c79b commit e376f36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
14 changes: 2 additions & 12 deletions src/ota_proxy/lru_cache_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,17 @@
from __future__ import annotations

import bisect
import logging
import sqlite3
import time
from pathlib import Path

from simple_sqlite3_orm import utils

from otaclient_common.logging import BurstSuppressFilter
from otaclient_common.logging import get_burst_suppressed_logger

from .db import AsyncCacheMetaORM, CacheMeta

burst_suppressed_logger = logging.getLogger(f"{__name__}.db_error")
# NOTE: for request_error, only allow max 6 lines of logging per 30 seconds
burst_suppressed_logger.addFilter(
BurstSuppressFilter(
f"{__name__}.db_error",
upper_logger_name=__name__,
burst_round_length=30,
burst_max=6,
)
)
burst_suppressed_logger = get_burst_suppressed_logger(f"{__name__}.db_error")


class LRUCacheHelper:
Expand Down
12 changes: 2 additions & 10 deletions src/ota_proxy/server_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import aiohttp
from multidict import CIMultiDict, CIMultiDictProxy

from otaclient_common.logging import BurstSuppressFilter
from otaclient_common.logging import get_burst_suppressed_logger

from ._consts import (
BHEADER_AUTHORIZATION,
Expand All @@ -46,16 +46,8 @@
from .ota_cache import OTACache

logger = logging.getLogger(__name__)
burst_suppressed_logger = logging.getLogger(f"{__name__}.request_error")
# NOTE: for request_error, only allow max 6 lines of logging per 30 seconds
burst_suppressed_logger.addFilter(
BurstSuppressFilter(
f"{__name__}.request_error",
upper_logger_name=__name__,
burst_round_length=30,
burst_max=6,
)
)
burst_suppressed_logger = get_burst_suppressed_logger(f"{__name__}.request_error")

# only expose app
__all__ = ("App",)
Expand Down

0 comments on commit e376f36

Please sign in to comment.