mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-23 05:48:11 -05:00
Move stats collection sample rate to config
This way, we can update the rate in one place.
This commit is contained in:
@@ -202,6 +202,8 @@ error_reporters =
|
||||
statsd_addr =
|
||||
# how often to send them [0.0 - 1.0]
|
||||
statsd_sample_rate = 1.0
|
||||
# percentage of stats for sampling (0-100)
|
||||
stats_sample_rate = 1
|
||||
|
||||
|
||||
############################################ MEDIA STORAGE
|
||||
|
||||
@@ -151,6 +151,7 @@ def js_config(extra_config=None):
|
||||
# where do ajax requests go?
|
||||
"ajax_domain": get_domain(cname=c.authorized_cname, subreddit=False),
|
||||
"stats_domain": g.stats_domain or '',
|
||||
"stats_sample_rate": g.stats_sample_rate or 0,
|
||||
"extension": c.extension,
|
||||
"https_endpoint": is_subdomain(request.host, g.domain) and g.https_endpoint,
|
||||
# does the client only want to communicate over HTTPS?
|
||||
|
||||
@@ -86,11 +86,15 @@ r.ui.initLiveTimestamps = function() {
|
||||
}
|
||||
|
||||
r.ui.initTimings = function() {
|
||||
// sample at a rate of 1%
|
||||
if (Math.random() > 0.01) { return }
|
||||
// return if we're not configured for sending stats
|
||||
if (!r.config.pageInfo.actionName || !r.config.stats_domain) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!r.config.pageInfo.actionName) { return }
|
||||
if (!r.config.stats_domain) { return }
|
||||
// Sample based on the configuration sample rate
|
||||
if (Math.random() > r.config.stats_sample_rate / 100) {
|
||||
return
|
||||
}
|
||||
|
||||
var browserTimings = new r.NavigationTimings()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user