Permalink
Browse files

Collect some metrics in statsd

  • Loading branch information...
1 parent 6a1f998 commit 406f7e2d52d078951ea9638226f997ab8ee29859 @mutle committed Dec 28, 2012
@@ -35,6 +35,10 @@ def notification(type, object)
$redis.publish 'fu2_live', {:type => type, :object => object.as_json}.to_json
end
+ def increment_metric(name)
+ METRICS.increment name
+ end
+
def highlight_results(text, query)
query.split(" ").inject(text) { |s,q| s = highlight(s, q) }
end
@@ -51,6 +51,11 @@ def new
def create
@channel = Channel.create(params[:channel].merge(:user_id => current_user.id, :markdown => current_user.markdown?))
notification :channel_create, @channel
+ increment_metric "posts"
+ increment_metric "posts.user.#{current_user.id}"
+ increment_metric "channels"
+ increment_metric "channels.id.#{@channel.id}.posts"
+ increment_metric "channels.user.#{current_user.id}"
respond_with @channel do |f|
f.html { redirect_to channel_path(@channel) }
@@ -8,6 +8,9 @@ class PostsController < ApplicationController
def create
@post = @channel.posts.create(:body => params[:post][:body], :user_id => current_user.id, :markdown => current_user.markdown?)
notification :post_create, @post
+ increment_metric "posts"
+ increment_metric "channels.id.#{@channel.id}.posts"
+ increment_metric "posts.user.#{current_user.id}"
respond_with @post do |f|
f.html { redirect_to channel_path(@channel, :anchor => "post_#{@post.id}") }
View
@@ -42,7 +42,7 @@ def delete_channel_visits
end
def update_channel_last_post
- channel.update_attribute(:last_post, created_at)
+ channel.update_attribute(:last_post, created_at) if channel
end
def set_markdown

0 comments on commit 406f7e2

Please sign in to comment.