[tor-bugs] #24218 [Metrics/Statistics]: Implement new metrics-web module for IPv6 relay statistics
Tor Bug Tracker & Wiki
blackhole at torproject.org
Sun Dec 17 18:37:16 UTC 2017
#24218: Implement new metrics-web module for IPv6 relay statistics
--------------------------------+------------------------------
Reporter: karsten | Owner: metrics-team
Type: enhancement | Status: needs_review
Priority: Medium | Milestone:
Component: Metrics/Statistics | Version:
Severity: Normal | Resolution:
Keywords: | Actual Points:
Parent ID: | Points:
Reviewer: iwakeh | Sponsor:
--------------------------------+------------------------------
Comment (by irl):
Is there any indentation or spacing we can do to make it clearer where the
`magrittr` pipelines begin/end? For the purpose of making formatting,
building up ggplot2 plots can be treated as the same as a `%>%` so no
distinction is needed there:
{{{
plot_relays_ipv6 <- function(start, end, path) {
all_relay_data <- read.csv(
"/srv/metrics.torproject.org/metrics/shared/stats/ipv6servers.csv",
colClasses = c("valid_after_date" = "Date")) %>%
filter(server == "relay")
start_date <- max(as.Date(start), min(all_relay_data$valid_after_date))
end_date <- min(as.Date(end), max(all_relay_data$valid_after_date),
Sys.Date() - 2)
date_breaks <- date_breaks(as.numeric(end_date - start_date))
all_relay_data %>%
filter(valid_after_date >= start_date, valid_after_date <= end_date)
%>%
group_by(valid_after_date) %>%
summarize(total = sum(server_count_sum_avg),
announced = sum(server_count_sum_avg[announced_ipv6 == 't']),
reachable = sum(server_count_sum_avg[reachable_ipv6_relay == 't']),
exiting = sum(server_count_sum_avg[exiting_ipv6_relay == 't'])) %>%
merge(data.frame(valid_after_date = seq(start_date, end_date,
by = "1 day")), all = TRUE) %>%
gather(total, announced, reachable, exiting, key = "category",
value = "count") %>%
ggplot(aes(x = valid_after_date, y = count, colour = category)) +
geom_line(size = 1) +
scale_x_date(name = paste("\nThe Tor Project - ",
"https://metrics.torproject.org/", sep = ""),
labels = date_format(date_breaks$format),
date_breaks = date_breaks$major,
date_minor_breaks = date_breaks$minor) +
scale_y_continuous(name = "") +
scale_colour_hue(name = "", h.start = 90,
breaks = c("total", "announced", "reachable", "exiting"),
labels = c("Total (IPv4) OR", "IPv6 announced OR", "IPv6 reachable
OR",
"IPv6 exititing")) +
expand_limits(y = 0) +
ggtitle("Relays by IP version") +
theme(legend.position = "top")
ggsave(filename = path, width = 8, height = 5, dpi = 150)
}
}}}
Other than that, the R looks good to me.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24218#comment:17>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list