<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Katipo Developers Blog</title>
	<atom:link href="http://blog.katipo.co.nz/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.katipo.co.nz</link>
	<description></description>
	<lastBuildDate>Wed, 27 Apr 2011 08:23:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick Ruby script to write file types report</title>
		<link>http://blog.katipo.co.nz/2011/04/27/quick-ruby-script-to-write-file-types-report/</link>
		<comments>http://blog.katipo.co.nz/2011/04/27/quick-ruby-script-to-write-file-types-report/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 08:23:31 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=141</guid>
		<description><![CDATA[Today I had to evaluate whether it was worth it to use Kete&#8217;s bulk import facility to migrate an existing site&#8217;s content to Kete or whether to just have someone drag the content over page by page.
To figure this out, I wanted to know roughly how many pages along with other files were on the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had to evaluate whether it was worth it to use Kete&#8217;s bulk import facility to migrate an existing site&#8217;s content to Kete or whether to just have someone drag the content over page by page.</p>
<p>To figure this out, I wanted to know roughly how many pages along with other files were on the site. I knew that it wasn&#8217;t going to absolutely massive, so I started by grabbing all of the site&#8217;s public content with wget (the details coming from <a href="http://linuxreviews.org/quicktips/wget/">http://linuxreviews.org/quicktips/wget/</a>):</p>
<pre>
<div class="codesnip-container" >wget -p -r --wait=20 --limit-rate=20K -U Mozilla http://the_site/</div>
</pre>
<p>I let that run in the background while I did other work.</p>
<p>When it finished I wrote up a little (ugly, unDRY, but took < 5 minutes) Ruby to give me a report by file type and called it file_report.rb based on a skeleton grabbed from <a href="http://blogs.sourceallies.com/2009/12/word-counts-example-in-ruby-and-scala/">http://blogs.sourceallies.com/2009/12/word-counts-example-in-ruby-and-scala/</a>:</p>
<pre>
<div class="codesnip-container" >require 'yaml'

# Change rootDir to the location of downloaded site
rootDir = "/path/to/roodDir/for/entire/downloaded/site"
raise rootDir + " does not exist" unless File.directory? rootDir

# recursively add files and directories to report_hash based on their type
def files(rootDir, report_hash)
  report_hash['directories'] = report_hash['directories'] || Array.new

  Dir.foreach(rootDir) do |dir|
    if dir != "." &#038;&#038; dir != ".."
      dir_path = rootDir + "/" + dir

      if File.directory?(dir_path)
        puts "Processing " + dir

        report_hash['directories'] = report_hash['directories'] << dir_path

        Dir.foreach(dir_path) do |file|
          if file != "." &#038;&#038; file != ".."
            file_path = rootDir + "/" + dir + "/" + file
            if File.directory?(file_path)
              report_hash['directories'] = report_hash['directories'] << file_path

              files(file_path, report_hash)
            else
              # add path to report_hash's entry for the file extension
              extension = File.extname(file).sub('.', '')

              report_hash[extension] = report_hash[extension] || Array.new

              report_hash[extension] = report_hash[extension] << file_path
            end
          end
        end
      else
        # add path to report_hash's entry for the file extension
        extension = File.extname(dir).sub('.', '')

        report_hash[extension] = report_hash[extension] || Array.new

        report_hash[extension] = report_hash[extension] << dir_path
      end
    end
  end
end

t1 = Time.now
report_hash = Hash.new
files(rootDir, report_hash)

puts "File type counts: "

report_hash.each do |k, v|
  puts "#{k} : #{v.size}"
end

puts "Writing complete report"
File.open('report.yml', "w") do |f|
    f.write(report_hash.to_yaml)
end

t2 = Time.now
puts "Finished in " + (t2 - t1).to_s + " seconds"</div>
</pre>
<p>Finally, I called it with:</p>
<pre>
<div class="codesnip-container" >ruby file_report.rb</div>
</pre>
<p>Nothing flash, but handy to have when you need it. I saved myself a lot of clicking around on their website.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2011/04/27/quick-ruby-script-to-write-file-types-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple migration_template calls in Rails (2.3x) generator manifest</title>
		<link>http://blog.katipo.co.nz/2011/04/26/multiple-migration_template-calls-in-rails-2-3x-generator-manifest/</link>
		<comments>http://blog.katipo.co.nz/2011/04/26/multiple-migration_template-calls-in-rails-2-3x-generator-manifest/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 01:56:22 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=138</guid>
		<description><![CDATA[If you have created a Rails generator that needs to include more than one migration_template in its record block, I&#8217;ve found a trick so you don&#8217;t run into a &#8220;Multiple migrations have the version number&#8221; error when running db:migrate.
You need to tell the generator to take a one second snooze, so that the next_migration_string method [...]]]></description>
			<content:encoded><![CDATA[<p>If you have created a Rails generator that needs to include more than one migration_template in its record block, I&#8217;ve found a trick so you don&#8217;t run into a &#8220;Multiple migrations have the version number&#8221; error when running db:migrate.</p>
<p>You need to tell the generator to take a one second snooze, so that the next_migration_string method returns a timestamp that is one second later.</p>
<p>You would think a simple call to the sleep method would do the trick, but because the generator manifest&#8217;s record has a special syntax (that relies on method_missing to define recorded actions), you need to do a small tweek by calling the sleep method on the block&#8217;s object, i.e. &#8220;m.sleep(1)&#8221;.</p>
<p>Here&#8217;s what it looks like in practice:</p>
<pre>
<div class="codesnip-container" >class TrolliedMigrationsGenerator < Rails::Generator::Base
  def manifest
    record do |m|
      m.migration_template 'trolleys_migration.rb', 'db/migrate', { :migration_file_name => "create_trolleys" }
      m.sleep(1)
      m.migration_template 'purchase_orders_migration.rb', 'db/migrate', { :migration_file_name => "create_purchase_orders" }
      m.sleep(1)
      m.migration_template 'line_items_migration.rb', 'db/migrate', { :migration_file_name => "create_line_items" }
    end
  end
end</div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2011/04/26/multiple-migration_template-calls-in-rails-2-3x-generator-manifest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mongo_translatable Rails engine Ruby gem released</title>
		<link>http://blog.katipo.co.nz/2011/03/11/mongo_translatable-rails-engine-ruby-gem-released/</link>
		<comments>http://blog.katipo.co.nz/2011/03/11/mongo_translatable-rails-engine-ruby-gem-released/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 00:07:46 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[kete development]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=135</guid>
		<description><![CDATA[Version 0.1 of the mongo_translatable gem is out.
We&#8217;ve been using mongo_translatable for awhile as a part of a feature in Kete (an open source Rails app, http://kete.net.nz) for a content translation add-on for awhile now. Thought it was about time to share.
mongo_translatable is a Rails specific I18n model localization mechanism meant to tie-in to existing ActiveRecord models, ala Globalize2, [...]]]></description>
			<content:encoded><![CDATA[<p>Version 0.1 of the mongo_translatable gem is out.</p>
<p>We&#8217;ve been using mongo_translatable for awhile as a part of a feature in Kete (an open source Rails app, <a style="color: #0000cc;" href="http://kete.net.nz/" target="_blank">http://kete.net.nz</a>) for a content translation add-on for awhile now. Thought it was about time to share.</p>
<p>mongo_translatable is a Rails specific I18n model localization mechanism meant to tie-in to existing ActiveRecord models, ala Globalize2, backed by MongoDB rather than an RDBMS.</p>
<p>The gem has only been developed with Rails 2.3.5 up to this point, as that is what my needs are right now, but it would be great if others contributed compatibility with later versions of Rails.</p>
<p>Project information can be found on github:</p>
<p><a style="color: #0000cc;" href="https://github.com/kete/mongo_translatable" target="_blank">https://github.com/kete/mongo_translatable</a></p>
<p>Thanks to Te Reo o Taranaki, the Chinese Association of New Zealand Auckland Branch, and Auckland City Libraries for funding the work.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2011/03/11/mongo_translatable-rails-engine-ruby-gem-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>oembed_provider Rails engine Ruby gem released</title>
		<link>http://blog.katipo.co.nz/2011/02/16/oembed_provider-rails-engine-ruby-gem-released/</link>
		<comments>http://blog.katipo.co.nz/2011/02/16/oembed_provider-rails-engine-ruby-gem-released/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 00:35:14 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[html/css]]></category>
		<category><![CDATA[kete development]]></category>
		<category><![CDATA[oEmbed]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=131</guid>
		<description><![CDATA[Version 0.1 of the oembed_provider gem is out.

oembed_provider is a Rails engine to answer oEmbed requests for application media asset models.]]></description>
			<content:encoded><![CDATA[<p>Version 0.1 of the oembed_provider gem is out.</p>
<p>oembed_provider is a Rails engine to answer oEmbed requests for application media asset models. In other words, this gem allows your application, after configuring the gem and the relevant models, to act as an oEmbed Provider by providing a controller that returns JSON or XML for a given oEmbed consumer request for the specified media asset. This gem does not offer oEmbed consumer functionality.</p>
<p>The gem has only been developed with Rails 2.3.5 up to this point, as that is what my needs are right now, but it would be great if others contributed compatibility with later versions of Rails.</p>
<p>More information is available at <a href="https://github.com/kete/oembed_provider">https://github.com/kete/oembed_provider</a>.</p>
<p>Issues can be reported at <a href="http://kete.lighthouseapp.com/projects/69994-oembed_provider">http://kete.lighthouseapp.com/projects/69994-oembed_provider</a>.</p>
<p>This gem was developed for the Kete open source application (<a href="http://kete.net.nz">http://kete.net.nz</a>) and was funded by pledge campaign to improve media selection from with the rich text editor (i.e. the TinyMCE plugin, look for TinyMCE media selector plugin soon). Horowhenua Library Trust, Wellington City Libraries, Te Reo o Taranaki, Environmental Earth Sciences, CALYX, and many individual contributors. Thanks to all contributors.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2011/02/16/oembed_provider-rails-engine-ruby-gem-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharl is your friend</title>
		<link>http://blog.katipo.co.nz/2010/10/11/sharl-is-your-friend/</link>
		<comments>http://blog.katipo.co.nz/2010/10/11/sharl-is-your-friend/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 23:15:37 +0000</pubDate>
		<dc:creator>bob</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://funnelblog.katipo.co.nz/?p=124</guid>
		<description><![CDATA[Sometimes your linux server partitions fill up faster than you expect and suddenly you are getting warning emails screaming at you.
This is when Sharl comes in handy.
ls -Sharl
It is a quick way to list the contents of a dir by size of file with the biggest ones being the last on the list just right [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes your linux server partitions fill up faster than you expect and suddenly you are getting warning emails screaming at you.</p>
<p>This is when Sharl comes in handy.</p>
<div class="codesnip-container" >ls -Sharl</div>
<p>It is a quick way to list the contents of a dir by size of file with the biggest ones being the last on the list just right there above the command prompt allowing you to easy banish those not needed tar, sql, zip files that are not needed with flourish to free up as much space as one can with the least number of keystrokes</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/10/11/sharl-is-your-friend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kakama Technical Overview</title>
		<link>http://blog.katipo.co.nz/2010/06/04/kakama-technical-overview/</link>
		<comments>http://blog.katipo.co.nz/2010/06/04/kakama-technical-overview/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 02:39:27 +0000</pubDate>
		<dc:creator>kieran</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=122</guid>
		<description><![CDATA[I&#8217;ve just posted a technical overview of how Kakama functions. You can view it at Kakama.org
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just posted a technical overview of how Kakama functions. You can view it at <a href="http://kakama.org/en/documentation/topics/show/18-how-kakama-works-a-quick-technical-overview">Kakama.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/06/04/kakama-technical-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A more concise way to call single test file in ruby</title>
		<link>http://blog.katipo.co.nz/2010/04/25/a-more-concise-way-to-call-single-test-files-in-ruby/</link>
		<comments>http://blog.katipo.co.nz/2010/04/25/a-more-concise-way-to-call-single-test-files-in-ruby/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 03:52:12 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=118</guid>
		<description><![CDATA[I&#8217;ve been working with Rails and Ruby since 2006 and I&#8217;m surprised I hadn&#8217;t put this together for myself:

$ cd test # from your rails app root
$ ruby unit/a_model_test.rb

As compared to:

$ ruby -I"lib:test" "/usr/local/Cellar/ruby-enterprise-edition/1.8.7-20090928/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/a_model_test.rb"

Definitely a hand to forehead moment when I read that! Found it in a comment here:
https://rails.lighthouseapp.com/projects/16213/tickets/8
*Assumes your ruby command is set [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with Rails and Ruby since 2006 and I&#8217;m surprised I hadn&#8217;t put this together for myself:</p>
<pre>
<div class="codesnip-container" >$ cd test # from your rails app root
$ ruby unit/a_model_test.rb</div>
</pre>
<p>As compared to:</p>
<pre>
<div class="codesnip-container" >$ ruby -I"lib:test" "/usr/local/Cellar/ruby-enterprise-edition/1.8.7-20090928/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/a_model_test.rb"</div>
</pre>
<p>Definitely a hand to forehead moment when I read that! Found it in a comment here:</p>
<p><a href="https://rails.lighthouseapp.com/projects/16213/tickets/8">https://rails.lighthouseapp.com/projects/16213/tickets/8</a></p>
<p>*Assumes your ruby command is set up correctly in your shell&#8217;s environment, of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/04/25/a-more-concise-way-to-call-single-test-files-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using git feature branches to make your master branch commits list concise</title>
		<link>http://blog.katipo.co.nz/2010/03/18/using-git-feature-branches-to-make-your-master-branch-commits-list-concise/</link>
		<comments>http://blog.katipo.co.nz/2010/03/18/using-git-feature-branches-to-make-your-master-branch-commits-list-concise/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 23:18:37 +0000</pubDate>
		<dc:creator>kieran</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[commits]]></category>
		<category><![CDATA[squash]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=112</guid>
		<description><![CDATA[When you&#8217;re starting off, it&#8217;s fairly easy to commit to the master branch. But once your application is released, you probably want to keep things stable on the master branch. So use feature branches.

You do all your work in a feature branch, then pull it into the master branch. There are numerous topics on the [...]]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re starting off, it&#8217;s fairly easy to commit to the master branch. But once your application is released, you probably want to keep things stable on the master branch. So use feature branches.</p>
<p><span id="more-112"></span></p>
<p>You do all your work in a feature branch, then pull it into the master branch. There are numerous topics on the web for this.</p>
<p>But there is a problem with this approach. When you run `git pull origin my_branch`, you end up creating merge commits. Some get around this with `git rebase`, but then you end up rewriting commit shas. So how do you get a clean history without messing up the master branch?</p>
<p>Use `&#8211;squash`. Here is a simplified example:</p>
<pre>
<div class="codesnip-container" >git checkout -b my_branch
touch File1
git commit -a -m "File 1"
touch File2
git commit -a -m "File 2"
git push origin my_branch
git checkout master
git pull --squash origin my_branch
git commit -a -m "File 1 and 2"</div>
</pre>
<p>Note the last two steps. We use &#8211;squash to compact the feature branch commits. This leaves all changes in the other branch in an uncommitted state (which you can then do one final review on). We then go ahead and make a commit.</p>
<p>The result? One commit in master, containing all code from the feature branch.</p>
<p>Now, the caveat: If you have multiple developers who made commits on this branch, you probably want to leave the commits apart for credits sake. But if you&#8217;re the only one who&#8217;s committed, and you don&#8217;t mind squashing the history, this works great!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/03/18/using-git-feature-branches-to-make-your-master-branch-commits-list-concise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing MongoDB on Mac OS X using Homebrew</title>
		<link>http://blog.katipo.co.nz/2010/03/16/installing-mongodb-on-mac-os-x-using-homebrew/</link>
		<comments>http://blog.katipo.co.nz/2010/03/16/installing-mongodb-on-mac-os-x-using-homebrew/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 01:20:42 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[Homebrew]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[kete development]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=108</guid>
		<description><![CDATA[I&#8217;ve moved from MacPorts to Homebrew which includes a recipe for installing MongoDB. After installing Homebrew, just run this as your normal user:
brew install mongodb
If you prefer to store your MongoDB data all under your home directory, you might find Mislav&#8217;s gist suits your needs instead:
http://gist.github.com/265272
If you prefer installing from source, check out this post:
http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x
Enjoy.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve moved from MacPorts to <a href="http://github.com/mxcl/homebrew">Homebrew</a> which includes a recipe for installing MongoDB. After installing Homebrew, just run this as your normal user:</p>
<div class="codesnip-container" >brew install mongodb</div>
<p>If you prefer to store your MongoDB data all under your home directory, you might find Mislav&#8217;s gist suits your needs instead:</p>
<p><a href="http://gist.github.com/265272">http://gist.github.com/265272</a></p>
<p>If you prefer installing from source, check out this post:</p>
<p><a href="http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x">http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x</a></p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/03/16/installing-mongodb-on-mac-os-x-using-homebrew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three ways to increase New Relic RPM&#8217;s usefulness</title>
		<link>http://blog.katipo.co.nz/2010/03/03/three-ways-to-increase-new-relic-rpms-usefulness/</link>
		<comments>http://blog.katipo.co.nz/2010/03/03/three-ways-to-increase-new-relic-rpms-usefulness/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 04:13:07 +0000</pubDate>
		<dc:creator>kieran</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[new relic]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rpm]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=104</guid>
		<description><![CDATA[Three recent and little known features of New Relic RPM which help increase usefulness.]]></description>
			<content:encoded><![CDATA[<p>Here at Katipo, we&#8217;re using New Relic RPM to monitor our deployed <a href="http://kete.net.nz">Kete</a> applications, to help make things as fast as possible. In order to make New Relic as useful as possible, I&#8217;ve been trying out three New Relic RPM features, some available in only the latest versions of RPM, on one of those sites. These recent and little-known features aren&#8217;t enabled by default, so I&#8217;m going to run you through them and how to set them up in this post.</p>
<p>If you don&#8217;t yet use New Relic RPM, you can get a Lite account for free by going to <a href="http://newrelic.com">newrelic.com</a>, where you can also test drive New Relic RPM on a real application. <span id="more-104"></span></p>
<p><strong>Custom request parameters</strong></p>
<p>New Relic does it&#8217;s best to record as much information about the current request as possible. The URL, split down into controller, action, id etc, the request referrer, GET and POST data&#8230;. but there is data that it doesn&#8217;t know about. Things like the current locale, the user who is currently logged in, or custom session params. Thankfully, there is a solution.</p>
<p>New Relic RPM contains a method for adding custom data to each transaction or error that is sent to it&#8217;s servers. Utilize this method inside of a before_filter in your application controller, and you&#8217;ll be gathering that extra data in no time. Here is the code we use.</p>
<blockquote>
<pre># Collect additional debug details for New Relic RPM is available
# Do this after all other before filters so details are present
before_filter :set_new_relic_custom_parameters
def set_new_relic_custom_parameters
  return unless defined?(NewRelic)
  NewRelic::Agent.add_custom_parameters(
    :locale =&gt; (I18n.locale if I18n.locale),
    :account =&gt; (logged_in? ? current_user.login : 'guest'),
    :return_to =&gt; (session[:return_to] if session[:return_to])
  )
end
private :set_new_relic_custom_parameters</pre>
</blockquote>
<p>Now, whenever RPM sends information about slow web requests or error reports, you&#8217;ll have more data to help replicate the issue.</p>
<p><strong>Passenger Queue Wait</strong></p>
<p>Sometimes the slowness might not be your app, but your app server. How do you tell if it&#8217;s serving requests fast enough? New Relic RPM now has the ability to report how long your visits were waiting in the &#8216;queue&#8217;, that is, the time between requesting the site and Apache actually processing that request. Getting this working is fairly simple.</p>
<blockquote><p>RequestHeader set X-REQUEST_START &#8220;%t&#8221;</p></blockquote>
<p>Simply set that in either your main apache.conf file, the VirtualHost directive, or a Directory directive.</p>
<p>Also, ensure that the headers Apache module is enabled. On Debian, you can do this by running the following as root.</p>
<blockquote><p># a2enmod headers</p></blockquote>
<p>That&#8217;s all it takes. Now, when RPM sends along information, it&#8217;ll send how long each request stayed in the queue, and display it at New Relic RPM&#8217;s web interface, on all graphs as &#8216;Queue Wait&#8217;. This should give you an indication of whether your application server is performing well.</p>
<p><span style="text-decoration: underline;"><span style="color: #000000;">Important Note:</span></span> If you run your application across multiple machines, each machine needs this header, and the clock on each machine must be synced with NTP or similar, or you&#8217;ll end up with very incorrect queue times. Users who run the entire site off one box need not worry about this issue.</p>
<p><strong>Garbage Collection delays</strong></p>
<p>I&#8217;m not going to go into much detail about Ruby Garbage collection here. Google &#8216;Ruby Garbage Collection&#8217; if you want to know more. Put simply though, in Ruby, while Garbage Collection runs, it stops the processing of your app. This could lead to slow page requests if it garbage collector, or GC, runs multiple times in the same request.</p>
<p>There are ways to tweak this using settings, but how do you know if it&#8217;s a problem to begin with? If you use Ruby Enterprise Edition, or another version of Ruby with the Railsbench GC patches compiled in, then all you need is the following line in your application.</p>
<blockquote><p>GC.enable_stats if defined?(GC) &amp;&amp; GC.respond_to?(:enable_stats)</p></blockquote>
<p>For Ruby on Rails users, you can stick that at the bottom of your config/environment.rb file. Basically, if GC is defined, and responds to the correct method, then use it. RPM will send this information back to New Relic, where you can view how long GC took in each of your requests, and deal with it accordingly.</p>
<p><strong>Conclusion</strong></p>
<p>Well, that&#8217;s all for now. Please feel free to share any additional features which help make New Relic even more useful in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/03/03/three-ways-to-increase-new-relic-rpms-usefulness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
