Skip to content

Commit

Permalink
bundle analysis: metrics ref (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySentry authored Oct 23, 2024
1 parent ecfe031 commit 02c2e2b
Showing 1 changed file with 25 additions and 45 deletions.
70 changes: 25 additions & 45 deletions services/bundle_analysis/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 02c2e2b

Please sign in to comment.