Skip to content

Commit

Permalink
Adding a TracePoint instrument implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
aantix committed Nov 12, 2023
1 parent ddf099d commit 599d4ce
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 206 deletions.
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
callstacking-rails (0.1.36)
callstacking-rails (0.1.37)
faraday (>= 1.10.3)
faraday-follow_redirects
rails (>= 4)
Expand Down Expand Up @@ -85,8 +85,8 @@ GEM
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-net_http (3.0.2)
globalid (1.1.0)
activesupport (>= 5.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
loofah (2.20.0)
Expand All @@ -99,13 +99,13 @@ GEM
net-smtp
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_mime (1.1.5)
minitest (5.18.0)
minitest-silence (0.2.4)
minitest (~> 5.12)
mocha (2.0.2)
ruby2_keywords (>= 0.0.5)
net-imap (0.3.6)
net-imap (0.3.7)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -158,13 +158,13 @@ GEM
sprockets (>= 3.0.0)
sqlite3 (1.6.2-arm64-darwin)
thor (1.2.2)
timeout (0.3.2)
timeout (0.4.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.5)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.8)
zeitwerk (2.6.11)

PLATFORMS
arm64-darwin-21
Expand Down
5 changes: 3 additions & 2 deletions lib/callstacking/rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
require "active_support/cache"
require "callstacking/rails/env"
require "callstacking/rails/trace"
require "callstacking/rails/instrument"
require "callstacking/rails/instrument/method_override_instrumentor"
require "callstacking/rails/instrument/trace_point_instrumentor"
require 'callstacking/rails/spans'
require "callstacking/rails/setup"
require "callstacking/rails/settings"
Expand All @@ -28,7 +29,7 @@ class Engine < ::Rails::Engine
@@spans||={}
@@traces||={}
@@lock||=Mutex.new
@@instrumenter||=Instrument.new
@@instrumenter||=Callstacking::Rails::Instrument::MethodOverrideInstrumentor.new
@@settings||=Callstacking::Rails::Settings.new

initializer "engine_name.assets.precompile" do |app|
Expand Down
4 changes: 2 additions & 2 deletions lib/callstacking/rails/helpers/instrument_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module InstrumentHelper
extend ActiveSupport::Concern
def callstacking_setup
exception = nil
@last_callstacking_sample = TIme.utc.now
@last_callstacking_sample = Time.now.utc
Callstacking::Rails::Engine.start_tracing(self)

yield
rescue Exception => e
@last_callstacking_exception = Time.utc.now
@last_callstacking_exception = Time.now.utc
exception = e
raise e
ensure
Expand Down
180 changes: 0 additions & 180 deletions lib/callstacking/rails/instrument.rb

This file was deleted.

21 changes: 21 additions & 0 deletions lib/callstacking/rails/instrument/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Callstacking
module Rails
module Instrument
class Base
def self.arguments_for(m, args)
param_names = m.parameters&.map(&:last)
return {} if param_names.nil?

h = param_names.map.with_index do |param, index|
next if [:&, :*, :**].include?(param)
[param, args[index].inspect]
end.compact.to_h

filter = ::Rails.application.config.filter_parameters
f = ActiveSupport::ParameterFilter.new filter
f.filter h
end
end
end
end
end

0 comments on commit 599d4ce

Please sign in to comment.