Skip to content

Commit

Permalink
add metric for overall report size (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-codecov authored Aug 2, 2024
1 parent f236938 commit 8d8882d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@ background_app/.report.json
*.swo

# Pycharm/Intellij
.idea/
.idea/

.sl
.git
15 changes: 15 additions & 0 deletions services/report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
)
from services.report.parser import get_proper_parser
from services.report.parser.types import ParsedRawReport
from services.report.parser.version_one import VersionOneReportParser
from services.report.prometheus_metrics import (
RAW_UPLOAD_RAW_REPORT_COUNT,
RAW_UPLOAD_SIZE,
)
from services.report.raw_upload_processor import process_raw_upload
from services.repository import get_repo_provider_service
from services.yaml.reader import get_paths_from_flags, read_yaml_field
Expand Down Expand Up @@ -914,7 +919,17 @@ def parse_raw_report_from_storage(

parser = get_proper_parser(upload)

upload_version = (
"v1" if isinstance(parser, VersionOneReportParser) else "legacy"
)
RAW_UPLOAD_SIZE.labels(version=upload_version).observe(len(archive_file))

raw_uploaded_report = parser.parse_raw_report_from_bytes(archive_file)

RAW_UPLOAD_RAW_REPORT_COUNT.labels(version=upload_version).observe(
len(raw_uploaded_report.get_uploaded_files())
)

return raw_uploaded_report

@sentry_sdk.trace
Expand Down
27 changes: 27 additions & 0 deletions services/report/prometheus_metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from shared.metrics import Histogram

KiB = 1024
MiB = KiB * KiB
RAW_UPLOAD_SIZE = Histogram(
"worker_services_report_raw_upload_size",
"Size (in bytes) of a raw upload (which may contain several raw reports)",
["version"],
buckets=[
100 * KiB,
500 * KiB,
1 * MiB,
5 * MiB,
10 * MiB,
50 * MiB,
100 * MiB,
200 * MiB,
500 * MiB,
],
)

RAW_UPLOAD_RAW_REPORT_COUNT = Histogram(
"worker_services_report_raw_upload_raw_report_count",
"Number of raw coverage files contained in a raw upload",
["version"],
buckets=[1, 5, 10, 20, 50],
)

0 comments on commit 8d8882d

Please sign in to comment.