0.0
No commit activity in last 3 years
No release in over 3 years
adds caller method as SQL comment
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

PgDecorator

This gem is inspired by marginalia by 37signals but instead of patching Rails, patches Pg gem

PgDecorator adds first line of caller (tries to detect place in your code by ignoring gems, ruby and rbenv lines) as /* SQL comment */ so you could later identify "strange" or long queries in your PostgreSQL log directly.

Several reasons for creating gem:

  • marginalia did not decorate some of PostgreSQL adapter queries
  • no Rails 'dependency', you can use this gem if you use pg gem directly, or if you have non rails wrapper, such as pg_helper
  • having aggressive connection pooler in front of database server may lead to loss of "set application_name = 'newappname';",

Installation

Add this line to your application's Gemfile:

gem 'pg_decorator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pg_decorator

Usage

in your ruby script add following:

 require 'rubygems'
 require 'pg_decorator'
 PgDecorator::Injector.inject('AppToRuleWorld', '/home/ruby/world_ruler)

If you use Rails then you could create config/initializers/pg_decorator

 PgDecorator::Injector.inject(Rails.application.class.to_s.split("::").first, Rails.root.to_s)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request