devxy/build-cran-binaries
Watch
1
0
Fork
You've already forked build-cran-binaries
0

feat(stats): collect CDN access logs and publish download statistics

Add an hourly download-stats pipeline that reads the cran-rpkgs Bunny
access logs into a download_stats schema in the build metadata database
and publishes aggregated counts to /stats/downloads.json for the
rpkgs.com /stats page.

- Classify each request (download, index, redirect reason, probe, noise)
  mirroring the edge router, and split cloud/CI networks from the rest.
- De-duplicate downloads per client, package version and day, and key
  clients on a salted HMAC so no IP is stored or published.
- Exclude our own CI runners and record run windows to show gaps.
- Declare the zone's logging settings and allow CORS for JSON.
This commit is contained in:
Patrick Schratz 2026-11-14 13:02:53 +01:00
commit 2614d40bd9

View file

@ -39,14 +39,14 @@ files <- s3fs::s3_dir_ls(sprintf(
"devxy-r-package-binaries-hel1/arm64/alpine320/latest/src/contrib"
))
files_b = basename(files)
files_b_split = sapply(strsplit(basename(files_b), "_"), function(x) x[1])
files_b_split = setdiff(
files_b <- basename(files)
files_b_split <- sapply(strsplit(basename(files_b), "_"), function(x) x[1])
files_b_split <- setdiff(
files_b_split,
c("PACKAGES", "PACKAGES.gz", "PACKAGES.rds", "PACKAGES.db", "Archive")
)
# windows-only
files_b_split = setdiff(
files_b_split <- setdiff(
files_b_split,
c(
"PACKAGES",
@ -67,12 +67,12 @@ files_b_split = setdiff(
"R2wd"
)
)
pkgs_index = available.packages(
pkgs_index <- available.packages(
"https://cran.devxy.io/amd64/jammy/latest/src/contrib"
)[, "Package"]
pkgs_index_b = basename(pkgs_index)
pkgs_index_b <- basename(pkgs_index)
if (length(files_b_split) != length(pkgs_index_b)) {
pkgs_missing = setdiff(files_b_split, pkgs_index_b)
pkgs_missing <- setdiff(files_b_split, pkgs_index_b)
message("Packages missing in index but present in S3:")
pkgs_missing
formatted_pkgs <- gsub(