From ca3620e684c7bd5b37aeccc91b08a139f60b1dfa Mon Sep 17 00:00:00 2001 From: Nar Saynorath Date: Fri, 17 Feb 2023 10:00:44 -0500 Subject: [PATCH 1/2] chore(view-hierarchy): Add proguard file size Tracking the file size so we can understand its impact on timing --- src/sentry/lang/java/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sentry/lang/java/utils.py b/src/sentry/lang/java/utils.py index 20dda87e8b7b64..7d374af137ecfa 100644 --- a/src/sentry/lang/java/utils.py +++ b/src/sentry/lang/java/utils.py @@ -1,3 +1,5 @@ +import os + import sentry_sdk from symbolic import ProguardMapper @@ -32,12 +34,14 @@ def get_proguard_images(event: Event): def get_proguard_mapper(uuid: str, project: Project): - with sentry_sdk.start_span(op="proguard.get_proguard_mapper"): + with sentry_sdk.start_span(op="proguard.get_proguard_mapper") as span: dif_paths = ProjectDebugFile.difcache.fetch_difs(project, [uuid], features=["mapping"]) debug_file_path = dif_paths.get(uuid) if debug_file_path is None: return + proguard_file_size_in_mb = os.path.getsize(debug_file_path) / (1024 * 1024.0) + span.set_tag("proguard_file_size_in_mb", proguard_file_size_in_mb) mapper = ProguardMapper.open(debug_file_path) if not mapper.has_line_info: return From 58397eacb8a4e0c15f95b49b6bd529efc08cbd40 Mon Sep 17 00:00:00 2001 From: Nar Saynorath Date: Fri, 17 Feb 2023 15:07:18 -0500 Subject: [PATCH 2/2] Wrap getsize in try/except --- src/sentry/lang/java/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sentry/lang/java/utils.py b/src/sentry/lang/java/utils.py index 7d374af137ecfa..25f6a9bf7a895a 100644 --- a/src/sentry/lang/java/utils.py +++ b/src/sentry/lang/java/utils.py @@ -40,8 +40,13 @@ def get_proguard_mapper(uuid: str, project: Project): if debug_file_path is None: return - proguard_file_size_in_mb = os.path.getsize(debug_file_path) / (1024 * 1024.0) - span.set_tag("proguard_file_size_in_mb", proguard_file_size_in_mb) + try: + proguard_file_size_in_mb = os.path.getsize(debug_file_path) / (1024 * 1024.0) + span.set_tag("proguard_file_size_in_mb", proguard_file_size_in_mb) + except OSError as exc: + sentry_sdk.capture_exception(exc) + return + mapper = ProguardMapper.open(debug_file_path) if not mapper.has_line_info: return