From faabbf309da40325875b919aef23da0b33d7ceb6 Mon Sep 17 00:00:00 2001 From: noO0ob Date: Mon, 13 May 2024 16:34:32 +0800 Subject: [PATCH 1/2] add checker category PATCHER --- lyrebird/checker/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lyrebird/checker/__init__.py b/lyrebird/checker/__init__.py index a8542560..ab2725b5 100644 --- a/lyrebird/checker/__init__.py +++ b/lyrebird/checker/__init__.py @@ -45,6 +45,7 @@ class ExtensionCategory: MODIFIER = "Modifier" CHECKER = "Checker" + PATCHER = "Patcher" OTHER = "Other" # TODO: For old version compatibility, need to delete @@ -53,7 +54,7 @@ class ExtensionCategory: @classmethod def get_order(cls, category): - orders = [cls.MODIFIER, cls.EDITOR, cls.CHECKER, cls.OTHER, cls.DEFAULT] + orders = [cls.MODIFIER, cls.EDITOR, cls.CHECKER, cls.OTHER, cls.DEFAULT, cls.PATCHER] if category not in orders: return len(orders) + 1 return orders.index(category) @@ -63,6 +64,7 @@ def get_description(cls, category): descriptions = { cls.MODIFIER: 'Modify flow', cls.CHECKER: 'Check event and make notification', + cls.PATCHER: 'Dynamically add supplementary logic to Lyrebird', cls.DEFAULT: 'Testability support, Advanced usage, etc.', # TODO: For old version compatibility, need to delete From b6fc8119d0703890644049c20a69d98bce77ee16 Mon Sep 17 00:00:00 2001 From: noO0ob Date: Wed, 15 May 2024 14:37:38 +0800 Subject: [PATCH 2/2] limit lyrebir_metrics report --- lyrebird/event.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lyrebird/event.py b/lyrebird/event.py index 16fdf56a..29b62766 100644 --- a/lyrebird/event.py +++ b/lyrebird/event.py @@ -18,6 +18,8 @@ logger = get_logger() +# only report the checker which duration more the 5s +LYREBIRD_METRICS_REPORT_DURSTION = 5000 class InvalidMessage(Exception): @@ -87,11 +89,11 @@ def broadcast_handler(self, callback_fn, event, args, kwargs): return event_end_time = time.time() event_duration = (event_end_time - event_start_time) * 1000 - if event_duration > 1: + if event_duration > LYREBIRD_METRICS_REPORT_DURSTION: trace_info = { 'channel': event.channel, + 'event_id': str(event.id), 'callback_fn': callback_fn.__name__, - 'callback_args': str(callback_args), 'callback_kwargs': str(callback_kwargs) } self.publish('lyrebird_metrics', {