Skip to content

Commit

Permalink
Refactor log aggregators init
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Nov 13, 2024
1 parent 1b04d04 commit 08bf932
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions neon_utils/log_aggregators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ def init_log_aggregators(config: dict = None):
from ovos_config.config import Configuration
config = config or Configuration()
for service_name, handler in _service_name_to_handler.items():
service_config = _get_log_aggregator_config(config=config, name=service_name)
if bool(service_config.pop('enabled', False)):
service_module = importlib.import_module(f'.{service_name}', __name__)
getattr(service_module, handler)(config=service_config)
try:
service_config = _get_log_aggregator_config(config=config, name=service_name)
if bool(service_config.pop('enabled', False)):
service_module = importlib.import_module(f'.{service_name}', __name__)
getattr(service_module, handler)(config=service_config)
except Exception as e:
pass


def _get_log_aggregator_config(config: dict, name: str):
Expand Down
3 changes: 2 additions & 1 deletion neon_utils/log_aggregators/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sentry_sdk

SENTRY_SDK_REQUIRED_KEYS = {'dsn'}


def init_sentry(config: dict):
import sentry_sdk

missing_required_keys = SENTRY_SDK_REQUIRED_KEYS.difference(config.keys())
if missing_required_keys:
raise KeyError(f'Sentry SDK configuration missing required keys: {missing_required_keys}')
Expand Down

0 comments on commit 08bf932

Please sign in to comment.