diff --git a/services/bundle_analysis/report.py b/services/bundle_analysis/report.py index 49552a770..4f8c1a0dc 100644 --- a/services/bundle_analysis/report.py +++ b/services/bundle_analysis/report.py @@ -99,18 +99,11 @@ def update_upload(self, carriedforward: Optional[bool] = False) -> None: self.upload.upload_type = SessionType.carriedforward.value self.upload_type_id = UploadType.CARRIEDFORWARD.db_id - try: - BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( - result="upload_error" if self.error else "processed", - plugin_name="n/a", - repository=self.commit.repository.repoid, - ).inc() - except Exception: - log.warn( - "Failed to BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER", - exc_info=True, - ) - + BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( + result="upload_error" if self.error else "processed", + plugin_name="n/a", + repository=self.commit.repository.repoid, + ).inc() db_session.flush() @@ -283,6 +276,11 @@ def process_upload( # save the bundle report back to storage bundle_loader.save(bundle_report, commit_report.external_id) except FileNotInStorageError: + BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( + result="file_not_in_storage", + plugin_name="n/a", + repository=commit.repository.repoid, + ).inc() return ProcessingResult( upload=upload, commit=commit, @@ -294,17 +292,11 @@ def process_upload( ) except PutRequestRateLimitError as e: plugin_name = getattr(e, "bundle_analysis_plugin_name", "unknown") - try: - BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( - result="rate_limit_error", - plugin_name=plugin_name, - repository=commit.repository.repoid, - ).inc() - except Exception: - log.warn( - "Failed to BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER", - exc_info=True, - ) + BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( + result="rate_limit_error", + plugin_name=plugin_name, + repository=commit.repository.repoid, + ).inc() return ProcessingResult( upload=upload, commit=commit, @@ -317,17 +309,11 @@ def process_upload( except Exception as e: # Metrics to count number of parsing errors of bundle files by plugins plugin_name = getattr(e, "bundle_analysis_plugin_name", "unknown") - try: - BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( - result="parser_error", - plugin_name=plugin_name, - repository=commit.repository.repoid, - ).inc() - except Exception: - log.warn( - "Failed to BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER", - exc_info=True, - ) + BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( + result="parser_error", + plugin_name=plugin_name, + repository=commit.repository.repoid, + ).inc() log.error( "Unable to parse upload for bundle analysis", exc_info=True, @@ -463,17 +449,11 @@ def save_measurements( commit=commit, ) except Exception: - try: - BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( - result="parser_error", - plugin_name="n/a", - repository=commit.repository.repoid, - ).inc() - except Exception: - log.warn( - "Failed to BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER", - exc_info=True, - ) + BUNDLE_ANALYSIS_REPORT_PROCESSOR_COUNTER.labels( + result="parser_error", + plugin_name="n/a", + repository=commit.repository.repoid, + ).inc() return ProcessingResult( upload=upload, commit=commit,