odoo/odoo#200458

Created by fw-bot
Merged at de181e586dfeb0e47945f323f0cf15397d09d921

Statuses:

label
odoo-dev:saas-18.1-18.0-netsvc-log-metadata-xdo-420707-fw
head
97ccbe40e012c12a453441caef86acffefa2a7be
merged
7 months ago by Framework (ORM), Xavier Dollé (xdo)
odoo/odoo
16.0 #199964
17.0 #200408
saas-17.4 #200418
18.0 #200429
saas-18.1 #200458
saas-18.2 #200476
saas-18.3
saas-18.4
19.0
master #200769

[FW][IMP] runbot: add metadata to log_db

When handling errors on runbot, it can be difficult to know where a message comes from. It can be problematic to identify automatically the source of an error.

This branch give the possibility to add metadata to log_db.

The current only metadata is the canonical tag.

Some other information, like the stack, or the subtest could be added in the future. This is not the case for now to make the review easier.

     def get_log_metadata(self):
+        stack = traceback.format_stack()
+        start = next((index for index, frame in enumerate(stack) if self._testMethodName in frame), 0)
         metadata = {
             'canonical_tag': self.canonical_tag,
+            'stack': '\n'.join(traceback.format_stack()[start:-7]),
+            'subtest': str(self._subtest),
         }
         return metadata

Forward-Port-Of: #199964