rails中使用bleak_house

阅读更多
Stage1)使用bleak_house
geminstallbleak_house
在environment.rb中加上:
require'bleak_house'
启动
RAILS_ENV = productionBLEAK_HOUSE = trueruby-bleak-house ./ script / server
错误
/ usr / local / ruby2 / lib / ruby / gems / 1.8 / gems / bleak_house- 3.6 / lib / bleak_house / rails / dispatcher . rb: 8 :undefinedlocalvariableormethod`callbacks' for Dispatcher :Class ( NameError )
from
/ usr / local / ruby2 / lib / ruby / site_ruby / 1.8 / rubygems / custom_require . rb: 27 :in `gem_original_require'
from
/ usr / local / ruby2 / lib / ruby / site_ruby / 1.8 / rubygems / custom_require . rb: 27 :in `require'
解决方法:
作者如是说 :
Yeah,onmyblogImentionedthatyouneedtostickwith - v3. 5.1 if youstilluseRails 1 .2x.
源文档: https: // rubyforge.org/forum/forum.php?thread_id=20904&forum_id=13983
要么升级rails至2.0,要么降级使用bleak_house 3.5.1
我选择了后者,因为我发现我升级rails后,目前的程序有很多错误
请求一个action,你会看到
**bleak_house:enabled ( log / bleak_house_production . dump )
看来 bleak_house在动作了并产生了日志
多请求几个,然后
bleak path / to / log / bleak_house_production . dump
否则回提示
Not enoughframes for accurateresults . Pleaserecordatleast 45 frames .
看到分析结果
..........................
usermanage__friend
/ index / GETleakedperrequest( 2 ):
379.5 String
63.5 Symbol
6.0 Array
5.5 Hash
3.0 Class
2.5 Module
2.0 ActiveRecord::ConnectionAdapters::MysqlColumn
1.5 Usermanage::FriendHelper
1.0 ApplicationHelper
1.0 Set
1.0 Time
1.0 # < Module: 0xb76e1b14 >
1.0 # < Module: 0xb76e25c8 >
1.0 # < Module: 0xb7766e04 >
0.5 Usermanage::FriendBlockHelper
0.5 Usermanage::MessageHelper
0.5 Usermanage::FriendDirHelper
.............................
Stage2) 更换启动方式
总不能使用./script/server来启动rails吧,这与我们目前mongrel cluster的启动方式不一致,为了使bleak_house适用我们目前的生产环境,于是:
修改environment.rb
ENV['BLEAK_HOUSE'] = 'true'
ENV['INTERVAL']
= ' 5 '
require'bleak_house'
直接启动会报如下错误,典型是因为你没使用bleak_house发布的带patch的ruby版本即(ruby-bleak-house),
/ usr / local / ruby2 / bin / ruby:symbollookuperror: / usr / local / ruby2 / lib / ruby / gems / 1.8 / gems / bleak_house- 3.5 . 1 / ext / bleak_house / logger / snapshot . so:undefinedsymbol:rb_gc_heap_slots
让我们参考下面一段话来得到答案:
Mattsays(May 06 , 2007 ):
Isitpossibletomonitoramongrel/railsprocessthisway—orjustwebrick/rails?
WhenIusethesuppliedstartingcommand
, Iwindupwitha‘normal’rubyprocess , notaruby-bleak-houseprocess.
IsupposeIcouldsymlinkmy/usr/local/bin/rubytomyruby-bleak-house.
evansays(June
22 , 2007 ):
Therearevariouswaysyoucanmanuallystarttheserver
, butthesymlinkistheeasiest.TheBleakHousebinaryisjustasreliableasregularRuby.
源文档 < http://blog.evanweaver.com/articles/2007/05/06/leak-proof-direct-heap-instrumentation-for-bleak_house/>
于是采用
ln -s ruby-bleak-house ruby
Ok
Stage3) 漂亮的图???
日志随着点击不断增长,你也可以看到文字输出,但是图呢??
作者说了下面的话:
Question# 2
Wereallylikethegraphing
, isitcomingbackever?Itseemseveninyour " Letmehityouwithsomeknowledge " postthatitwasfarfastertospottheleakwithgraphs.Isthereawaytohackitonto 3.7 ?

>Question
2

DunnoinmyownworkIthoughtthegraphswerelessusefulthanthetextoutput
, soIdroppedthem.IfsomeonewantedtoworkonrestoringthemIwouldacceptapatch(forexamplebleak--graph)tooptionallyhavegraphstoo.
源文档 < https://rubyforge.org/forum/forum.php?thread_id=21064&forum_id=13983>
Hey , Ichangedmymind.Version 3.7 restorescompatibilitywithRails 1.2.6 .
源文档 < http://rubyforge.org/forum/forum.php?thread_id=20904&forum_id=13983>
改用v 3.7,仍然不知道如何使用图,让我拭目以待作者更新的版本

你可能感兴趣的:(Rails,Ruby,rubygems,PHP,EXT)