File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/common-library/src/common_library Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,19 @@ def _create_timestamp() -> int:
5151 ts = datetime .now (UTC ).timestamp () * _SECS_TO_MILISECS
5252 return int (ts )
5353
54+ _LEN = 12 # chars (~48 bits)
55+
56+
57+ def _generate_error_fingerprint (exc : BaseException ) -> str :
58+ """
59+ Unique error fingerprint for deduplication purposes
60+ """
61+ tb = traceback .extract_tb (exc .__traceback__ )
62+ frame_sigs = [f"{ frame .name } :{ frame .lineno } " for frame in tb ]
63+ fingerprint = f"{ type (exc ).__name__ } |" + "|" .join (frame_sigs )
64+ # E.g. ZeroDivisionError|foo:23|main:10
65+ return hashlib .sha256 (fingerprint .encode ()).hexdigest ()[:_LEN ]
66+
5467
5568def create_error_code (exception : BaseException ) -> ErrorCodeStr :
5669 """
You can’t perform that action at this time.
0 commit comments