class Object
Constants
- FILE_CONTENTS
- RUST_POLICY_CLASSES
- TCELL_MAX_BODY_LENGTH
Public Class Methods
config(app, options = {})
click to toggle source
# File lib/tcell_agent/servers/rack_puma_handler.rb, line 6 def config(app, options = {}) conf = tcell_original_config(app, options) if defined?(Puma::Server) && !Puma::Server.instance_methods.include?(:tcell_original_run) Puma::Server.class_eval do alias_method :tcell_original_run, :run if defined?(Gem::Version) && defined?(Puma::Const::PUMA_VERSION) && (Gem::Version.new(Puma::Const::PUMA_VERSION) >= Gem::Version.new('5.1.0')) def run(background = true, thread_name: 'server') TCellAgent.thread_agent.start('Puma') original_run(background, :thread_name => thread_name) end else def run(background = true) TCellAgent.thread_agent.start('Puma') tcell_original_run(background) end end end end conf end
Also aliased as: tcell_original_config
register_login_event(status, rails_request, user_id, user_valid = nil, password = nil)
click to toggle source
# File lib/tcell_agent/hooks/login_fraud.rb, line 52 def register_login_event(status, rails_request, user_id, user_valid = nil, password = nil) TCellAgent::Instrumentation.safe_block('Rails Auth Hooks') do tcell_data = rails_request.env[TCellAgent::Instrumentation::TCELL_ID] TCellAgent::Hooks::LoginFraud.report_login_event( status, rails_request.env, tcell_data, user_id, password, user_valid ) end end
Also aliased as: tcell_register_login_event, tcell_register_login_event
run(background = true, thread_name: 'server')
click to toggle source
# File lib/tcell_agent/servers/rack_puma_handler.rb, line 16 def run(background = true, thread_name: 'server') TCellAgent.thread_agent.start('Puma') original_run(background, :thread_name => thread_name) end
Also aliased as: original_run
tcell_register_login_event(status, rails_request, user_id, user_valid = nil, password = nil)
Alias for: register_login_event
Public Instance Methods
before_handling_requests(forked, options)
click to toggle source
# File lib/tcell_agent/servers/passenger.rb, line 3 def before_handling_requests(forked, options) result_if_needed = tcell_before_handling_requests(forked, options) TCellAgent.thread_agent.start('Passenger') result_if_needed end
build_app(app)
click to toggle source
# File lib/tcell_agent/servers/rails_server.rb, line 7 def build_app(app) require('tcell_agent/servers/rack_puma_handler') if defined?(Rack::Handler::Puma) require('tcell_agent/servers/unicorn') if defined?(Unicorn::HttpServer) require('tcell_agent/servers/webrick') if defined?(Rack::Handler::WEBrick) require('tcell_agent/servers/thin') if defined?(Thin::Server) if defined?(Puma::Server) Puma::Server.class_eval do alias_method :tcell_original_run, :run def run(background = true) TCellAgent.thread_agent.start('Puma') tcell_original_run(background) end end end tcell_build_app(app) end
get_test_resource_path(name)
click to toggle source
# File spec/spec_helper.rb, line 17 def get_test_resource_path(name) File.join(File.dirname(__FILE__), 'support', 'resources', name) end
hot_reload_tcell_agent()
click to toggle source
# File lib/tcell_agent/servers/unicorn.rb, line 36 def hot_reload_tcell_agent TCellAgent::Instrumentation.safe_block('Reloading Tcell Config') do TCellAgent.logger.debug('[TCellAgent] Reloading configuration', 'TCellAgent::Unicorn') new_config = TCellAgent::Configuration.new TCellAgent.configuration = new_config end end
init_worker_process(work)
click to toggle source
# File lib/tcell_agent/servers/unicorn.rb, line 14 def init_worker_process(work) start_process = tcell_init_worker_process(work) TCellAgent.logger.debug('Instrumenting Unicorn server', 'TCellAgent::Unicorn') TCellAgent.thread_agent.start('Unicorn Worker') start_process end
load_config!()
click to toggle source
# File lib/tcell_agent/servers/unicorn.rb, line 28 def load_config! result_if_exists = tcell_load_config! hot_reload_tcell_agent result_if_exists end
run(background = true)
click to toggle source
# File lib/tcell_agent/servers/puma.rb, line 22 def run(background = true) TCellAgent.thread_agent.start('Puma') original_run(background, options) end
start()
click to toggle source
# File lib/tcell_agent/servers/thin.rb, line 4 def start TCellAgent.thread_agent.start('Thin Server') original_start end
start_server()
click to toggle source
# File lib/tcell_agent/servers/puma.rb, line 8 def start_server TCellAgent.thread_agent.start('Puma') tcell_original_start_server end
test_passenger()
click to toggle source
# File spec/lib/tcell_agent/instrument_servers_spec.rb, line 17 def test_passenger expect(PhusionPassenger::LoaderSharedHelpers.instance_methods.include?(:tcell_before_handling_requests)) end
test_puma()
click to toggle source
# File spec/lib/tcell_agent/instrument_servers_spec.rb, line 21 def test_puma expect(Puma.cli_config.options[:preload_app]).to be_falsey expect(Puma::Server.instance_methods.include?(:tcell_original_run)).to be_truthy end
test_rails()
click to toggle source
# File spec/lib/tcell_agent/instrument_servers_spec.rb, line 3 def test_rails expect(Rails::Server.instance_methods.include?(:tcell_build_app)).to be_truthy end
test_ruby2_ruby3_keywords(cls, func, args, options, res, min_ruby = '2.0.0')
click to toggle source
# File spec/support/shared_spec.rb, line 1 def test_ruby2_ruby3_keywords(cls, func, args, options, res, min_ruby = '2.0.0') ruby_version = Gem::Version.new(RUBY_VERSION) context 'using ruby2_3 helper function' do after(:each) do expect(@result).to eq res unless res.nil? end if ruby_version >= Gem::Version.new(min_ruby) && \ ruby_version < Gem::Version.new('3.0.0') # This spec tests the following format: # File.new('/dev/null', 'w', 0o644, { :binmode => true }) it 'behaves correctly in ruby < 2.7' do args_cp = Array.new(args) args_cp << options @result = cls.send(func, *args_cp) end end if ruby_version >= Gem::Version.new(min_ruby) # This spec tests the following format: # File.new('/dev/null', 'w', 0o644, :binmode => true ) it 'behaves correctly in ruby >= 3.0' do @result = cls.send(func, *args, **options) end end end end
test_server(filenames, funcs)
click to toggle source
# File spec/lib/tcell_agent/instrument_servers_spec.rb, line 26 def test_server(filenames, funcs) fork do filenames.each do |file| load file end load 'tcell_agent/instrument_servers.rb' funcs.each do |func| method(func).call end end end
test_thin()
click to toggle source
# File spec/lib/tcell_agent/instrument_servers_spec.rb, line 7 def test_thin expect(Thin::Server.instance_methods.include?(:original_start)).to be_truthy end
test_unicorn()
click to toggle source
# File spec/lib/tcell_agent/instrument_servers_spec.rb, line 11 def test_unicorn expect(Unicorn::HttpServer::START_CTX[0]).to be_falsy expect(Unicorn::HttpServer.instance_methods.include?(:tcell_init_worker_process)).to be_truthy expect(Unicorn::HttpServer.instance_methods.include?(:tcell_load_config!)).to be_truthy end
with_tcell_middleware(app, _inner_middleware = nil)
click to toggle source
# File spec/support/middleware_helper.rb, line 5 def with_tcell_middleware(app, _inner_middleware = nil) TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware.new( TCellAgent::Instrumentation::Rails::Middleware::HeadersMiddleware.new( ActionDispatch::ParamsParser.new( TCellAgent::Instrumentation::Rails::Middleware::BodyFilterMiddleware.new( TCellAgent::Instrumentation::Rails::Middleware::GlobalMiddleware.new( app ) ) ) ) ) end