Upgrade to Pro — share decks privately, control downloads, hide ads and more …

〇〇を切り出したいときに / Extract something from big rails...

〇〇を切り出したいときに / Extract something from big rails app

TokyuRuby会議12 での飛び入り LT 資料です
http://regional.rubykaigi.org/tokyu12/

Masayuki Izumi

July 29, 2018
Tweet

More Decks by Masayuki Izumi

Other Decks in Programming

Transcript

  1. izumin5210 Engineer at Wantedly, Inc. Wantedly People ‣ Web Application

    Engineer - Profile Data Strategy Group ‣ Interests in developer productivity on microservices Gopher, Rubyist, JavaScripter and Androider
  2.  DBMMFSΛه࿥͢Δ  ͡  `Thread.current[:controller] = controller_name`͠ͱ͘ͱศར  ͋͘·ͰҰ࣌తͳϩάऩूͳͷͰɼਖ਼͠͞खܰ͞ɾརศੑ

     ࡶʹϩάΛཷΊࠐΊΔπʔϧɾαʔϏεΛ࢖͏ ƁŞƄŪžUJQT caller.find do |c| !c.to_s.start_with?(Bundler.bundle_path.to_s) && c.to_s.start_with?(Rails.root.to_s) end
  3.  DBMMFSΛه࿥͢Δ  ࡶʹϩάΛཷΊࠐΊΔπʔϧɾαʔϏεΛ࢖͏  ʮϨεϙϯεʹӨڹΛ༩͑ͳ͍ʯ͸ॏཁ  ͍͍ײ͡ʹCVGGFSJOHͨ͠ΓඇಉظͰσʔλૹͬͯ͘ΕΔ܅Λ͔ͭ͏  qVFOUMPHHFSSVCZ

    UEMPHHFSSVCZ FUD  Ұ࣌తͳϩάऩूͳͷͰɼਖ਼͠͞खܰ͞ɾརศੑେ੾ͳ͜ͱͳͷͰʢ͈́ ƁŞƄŪžUJQT caller_app = caller.find do |c| !c.to_s.start_with?(Bundler.bundle_path.to_s) && c.to_s.start_with?(Rails.root.to_s) end TD.event.post("hoge_log", { caller_app: caller_app, request_controller: Tread.current[:request_controller], request_action: Tread.current[:request_action], # sinp. }) Կ΋ߟ͑ͣʢUFTUBCJMJUZʹӨڹΛ༩͑ͣʣɼࡶʹϩά౤͛ΒΕΔͷ͸3VCZ͔ͩΒͦ͜
  4.  DBMMFSΛه࿥͢Δ  ࡶʹϩάΛཷΊࠐΊΔπʔϧɾαʔϏεΛ࢖͏  ʮϨεϙϯεʹӨڹΛ༩͑ͳ͍ʯ͸ॏཁ  ͍͍ײ͡ʹCVGGFSJOHͨ͠ΓඇಉظͰσʔλૹͬͯ͘ΕΔ܅Λ͔ͭ͏  qVFOUMPHHFSSVCZ

    UEMPHHFSSVCZ FUD  Ұ࣌తͳϩάऩूͳͷͰɼਖ਼͠͞खܰ͞ɾརศੑେ੾ͳ͜ͱͳͷͰʢ͈́ ƁŞƄŪžUJQT class ActiveRecrod::Relation def eager_loading? super.tap do |loading| if loading # send logs end end end 3VCZͳͷͰܭଌ༻ίʔυ͸Ͳ͜ʹͰ΋࢓ࠐΊΔ ʢ˞༻͕ࡁΜͩΒফ͠·͠ΐ͏ʣ