Skip to content

Commit

Permalink
Clean up usage_q infrastructure.
Browse files Browse the repository at this point in the history
  • Loading branch information
spladug committed Dec 1, 2011
1 parent 794baba commit 502ebd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
15 changes: 9 additions & 6 deletions r2/r2/controllers/reddit_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,15 @@ def post(self):
log_text("unknown action", "no action for %r" % path_info,
"warning")
if g.usage_sampling >= 1.0 or rand.random() < g.usage_sampling:

amqp.add_kw("usage_q",
start_time = c.start_time,
end_time = end_time,
sampling_rate = g.usage_sampling,
action = action)
amqp.add_kw(
"request_info",
ip=request.ip,
start_time=c.start_time,
end_time=end_time,
sampling_rate=g.usage_sampling,
action=action,
headers=dict(request.headers)
)

# this thread is probably going to be reused, but it could be
# a while before it is. So we might as well dump the cache in
Expand Down
7 changes: 6 additions & 1 deletion r2/r2/lib/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,19 @@ def queues(self):
self._q('vote_link_q', self_refer=True)
self._q('vote_comment_q', self_refer=True)
self._q('log_q', self_refer=True)
self._q('usage_q', self_refer=True, durable=False)

self._q('solrsearch_changes')
self._q('indextank_changes', self_refer=True)
self._bind('search_changes', 'solrsearch_changes')
self._bind('search_changes', 'indextank_changes')

self._q('usage_q', durable=False)

def bindings(self):
self.newlink_bindings()
self.newcomment_bindings()
self.newsubreddit_bindings()
self.requestinfo_bindings()

def newlink_bindings(self):
self._bind('new_link', 'scraper_q')
Expand All @@ -98,6 +100,9 @@ def newcomment_bindings(self):
def newsubreddit_bindings(self):
pass

def requestinfo_bindings(self):
self._bind('request_info', 'usage_q')

try:
from r2admin.lib.adminqueues import *
except ImportError:
Expand Down

0 comments on commit 502ebd2

Please sign in to comment.