oneapm_rpm 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +30 -0
- data/.rubocop.yml +725 -0
- data/Gemfile +3 -0
- data/Guardfile +7 -0
- data/LICENSE +1 -0
- data/README.md +3 -0
- data/config/cert/cacert.pem +1177 -0
- data/config/database.yml +5 -0
- data/lib/initializers/goliath.rb +11 -0
- data/lib/initializers/other.rb +1 -0
- data/lib/initializers/rails.rb +15 -0
- data/lib/one_apm/agent.rb +253 -0
- data/lib/one_apm/agent/agent.rb +283 -0
- data/lib/one_apm/agent/agent/connect.rb +175 -0
- data/lib/one_apm/agent/agent/container_data_manager.rb +218 -0
- data/lib/one_apm/agent/agent/forkable_dispatcher_functions.rb +96 -0
- data/lib/one_apm/agent/agent/helpers.rb +45 -0
- data/lib/one_apm/agent/agent/start.rb +226 -0
- data/lib/one_apm/agent/agent/start_worker_thread.rb +148 -0
- data/lib/one_apm/agent/busy_calculator.rb +115 -0
- data/lib/one_apm/agent/cross_app/cross_app_monitor.rb +181 -0
- data/lib/one_apm/agent/cross_app/cross_app_tracing.rb +336 -0
- data/lib/one_apm/agent/database.rb +308 -0
- data/lib/one_apm/agent/database/active_record_helper.rb +80 -0
- data/lib/one_apm/agent/database/obfuscation_helpers.rb +76 -0
- data/lib/one_apm/agent/database/obfuscator.rb +78 -0
- data/lib/one_apm/agent/database/postgres_explain_obfuscator.rb +45 -0
- data/lib/one_apm/agent/datastores.rb +175 -0
- data/lib/one_apm/agent/datastores/metric_helper.rb +83 -0
- data/lib/one_apm/agent/datastores/mongo.rb +27 -0
- data/lib/one_apm/agent/datastores/mongo/metric_translator.rb +189 -0
- data/lib/one_apm/agent/datastores/mongo/obfuscator.rb +37 -0
- data/lib/one_apm/agent/datastores/mongo/statement_formatter.rb +51 -0
- data/lib/one_apm/agent/event/event_listener.rb +40 -0
- data/lib/one_apm/agent/event/event_loop.rb +191 -0
- data/lib/one_apm/agent/event/worker_loop.rb +97 -0
- data/lib/one_apm/agent/harvester.rb +48 -0
- data/lib/one_apm/agent/inbound_request_monitor.rb +30 -0
- data/lib/one_apm/agent/javascript_instrumentor.rb +186 -0
- data/lib/one_apm/agent/pipe/pipe_channel_manager.rb +275 -0
- data/lib/one_apm/agent/pipe/pipe_service.rb +81 -0
- data/lib/one_apm/agent/sampler.rb +55 -0
- data/lib/one_apm/agent/sampler_collection.rb +65 -0
- data/lib/one_apm/agent/samplers/cpu_sampler.rb +49 -0
- data/lib/one_apm/agent/samplers/delayed_job_sampler.rb +109 -0
- data/lib/one_apm/agent/samplers/memory_sampler.rb +144 -0
- data/lib/one_apm/agent/samplers/object_sampler.rb +22 -0
- data/lib/one_apm/agent/samplers/vm_sampler.rb +124 -0
- data/lib/one_apm/agent/synthetics_monitor.rb +48 -0
- data/lib/one_apm/agent/threading/agent_thread.rb +74 -0
- data/lib/one_apm/agent/threading/backtrace_node.rb +133 -0
- data/lib/one_apm/agent/threading/backtrace_service.rb +259 -0
- data/lib/one_apm/agent/threading/thread_profile.rb +155 -0
- data/lib/one_apm/collector/collector/helper.rb +139 -0
- data/lib/one_apm/collector/collector/http_connection.rb +254 -0
- data/lib/one_apm/collector/collector/server_methods.rb +71 -0
- data/lib/one_apm/collector/collector_service.rb +123 -0
- data/lib/one_apm/collector/commands/agent_command.rb +17 -0
- data/lib/one_apm/collector/commands/thread_profiler_session.rb +108 -0
- data/lib/one_apm/collector/commands/xray_session.rb +53 -0
- data/lib/one_apm/collector/commands/xray_session_collection.rb +156 -0
- data/lib/one_apm/collector/containers/agent_command_router.rb +153 -0
- data/lib/one_apm/collector/containers/custom_event_aggregator.rb +94 -0
- data/lib/one_apm/collector/containers/error_collector.rb +349 -0
- data/lib/one_apm/collector/containers/sql_sampler.rb +331 -0
- data/lib/one_apm/collector/containers/stats_engine.rb +34 -0
- data/lib/one_apm/collector/containers/transaction_event_aggregator.rb +249 -0
- data/lib/one_apm/collector/containers/transaction_sampler.rb +352 -0
- data/lib/one_apm/collector/containers/utilization_data.rb +36 -0
- data/lib/one_apm/collector/stats_engine/gc_profiler.rb +106 -0
- data/lib/one_apm/collector/stats_engine/metric_stats.rb +243 -0
- data/lib/one_apm/collector/stats_engine/stats_hash.rb +105 -0
- data/lib/one_apm/configuration.rb +429 -0
- data/lib/one_apm/configuration/autostart.rb +41 -0
- data/lib/one_apm/configuration/default_source.rb +1026 -0
- data/lib/one_apm/configuration/environment_source.rb +113 -0
- data/lib/one_apm/configuration/high_security_source.rb +56 -0
- data/lib/one_apm/configuration/manual_source.rb +13 -0
- data/lib/one_apm/configuration/server_source.rb +60 -0
- data/lib/one_apm/configuration/yaml_source.rb +134 -0
- data/lib/one_apm/errors/agent_errors.rb +26 -0
- data/lib/one_apm/errors/internal_agent_error.rb +16 -0
- data/lib/one_apm/errors/noticed_error.rb +79 -0
- data/lib/one_apm/frameworks/external.rb +15 -0
- data/lib/one_apm/frameworks/rails.rb +103 -0
- data/lib/one_apm/frameworks/rails3.rb +37 -0
- data/lib/one_apm/frameworks/rails4.rb +21 -0
- data/lib/one_apm/frameworks/ruby.rb +21 -0
- data/lib/one_apm/frameworks/sinatra.rb +12 -0
- data/lib/one_apm/inst/3rd/active_merchant.rb +35 -0
- data/lib/one_apm/inst/3rd/acts_as_solr.rb +70 -0
- data/lib/one_apm/inst/3rd/authlogic.rb +23 -0
- data/lib/one_apm/inst/3rd/sunspot.rb +31 -0
- data/lib/one_apm/inst/background_job/active_job.rb +88 -0
- data/lib/one_apm/inst/background_job/delayed_job.rb +52 -0
- data/lib/one_apm/inst/background_job/delayed_job_injection.rb +8 -0
- data/lib/one_apm/inst/background_job/resque.rb +107 -0
- data/lib/one_apm/inst/background_job/sidekiq.rb +64 -0
- data/lib/one_apm/inst/dispatcher/passenger.rb +25 -0
- data/lib/one_apm/inst/dispatcher/rainbows.rb +23 -0
- data/lib/one_apm/inst/framework/grape.rb +94 -0
- data/lib/one_apm/inst/framework/padrino.rb +30 -0
- data/lib/one_apm/inst/framework/sinatra.rb +185 -0
- data/lib/one_apm/inst/framework/sinatra/ignorer.rb +50 -0
- data/lib/one_apm/inst/framework/sinatra/transaction_namer.rb +54 -0
- data/lib/one_apm/inst/http_clients/curb.rb +189 -0
- data/lib/one_apm/inst/http_clients/excon.rb +70 -0
- data/lib/one_apm/inst/http_clients/excon/connection.rb +31 -0
- data/lib/one_apm/inst/http_clients/excon/middleware.rb +55 -0
- data/lib/one_apm/inst/http_clients/httpclient.rb +44 -0
- data/lib/one_apm/inst/http_clients/net.rb +34 -0
- data/lib/one_apm/inst/http_clients/typhoeus.rb +76 -0
- data/lib/one_apm/inst/nosql/memcache.rb +134 -0
- data/lib/one_apm/inst/nosql/mongo.rb +126 -0
- data/lib/one_apm/inst/nosql/mongo_moped.rb +85 -0
- data/lib/one_apm/inst/nosql/redis.rb +83 -0
- data/lib/one_apm/inst/orm/active_record.rb +99 -0
- data/lib/one_apm/inst/orm/active_record_4.rb +28 -0
- data/lib/one_apm/inst/orm/data_mapper.rb +180 -0
- data/lib/one_apm/inst/orm/sequel.rb +47 -0
- data/lib/one_apm/inst/rack.rb +38 -0
- data/lib/one_apm/inst/rack/rack.rb +44 -0
- data/lib/one_apm/inst/rack/rack_builder.rb +51 -0
- data/lib/one_apm/inst/rails/action_controller.rb +118 -0
- data/lib/one_apm/inst/rails/action_web_service.rb +44 -0
- data/lib/one_apm/inst/rails/errors.rb +43 -0
- data/lib/one_apm/inst/rails3/action_controller.rb +172 -0
- data/lib/one_apm/inst/rails3/errors.rb +43 -0
- data/lib/one_apm/inst/rails4/action_controller.rb +27 -0
- data/lib/one_apm/inst/rails4/action_controller_subscriber.rb +121 -0
- data/lib/one_apm/inst/rails4/action_view.rb +23 -0
- data/lib/one_apm/inst/rails4/action_view_subscriber.rb +93 -0
- data/lib/one_apm/inst/rails4/active_record_subscriber.rb +96 -0
- data/lib/one_apm/inst/rails4/errors.rb +42 -0
- data/lib/one_apm/inst/rails_middleware.rb +40 -0
- data/lib/one_apm/inst/support/evented_subscriber.rb +98 -0
- data/lib/one_apm/inst/support/ignore_actions.rb +39 -0
- data/lib/one_apm/inst/support/queue_time.rb +76 -0
- data/lib/one_apm/inst/transaction_base.rb +405 -0
- data/lib/one_apm/logger/agent_logger.rb +206 -0
- data/lib/one_apm/logger/audit_logger.rb +78 -0
- data/lib/one_apm/logger/memory_logger.rb +50 -0
- data/lib/one_apm/logger/null_logger.rb +19 -0
- data/lib/one_apm/metrics/metric_data.rb +72 -0
- data/lib/one_apm/metrics/metric_spec.rb +82 -0
- data/lib/one_apm/metrics/stats.rb +173 -0
- data/lib/one_apm/probe.rb +16 -0
- data/lib/one_apm/probe/framework_loader.rb +53 -0
- data/lib/one_apm/probe/instance_methods.rb +105 -0
- data/lib/one_apm/probe/instrumentation.rb +60 -0
- data/lib/one_apm/rack/browser_monitoring.rb +144 -0
- data/lib/one_apm/rack/middleware_base.rb +27 -0
- data/lib/one_apm/rack/middleware_hooks.rb +17 -0
- data/lib/one_apm/rack/middleware_tracing.rb +81 -0
- data/lib/one_apm/rack/middleware_wrapper.rb +86 -0
- data/lib/one_apm/support/chained_call.rb +15 -0
- data/lib/one_apm/support/coerce.rb +81 -0
- data/lib/one_apm/support/collection_helper.rb +79 -0
- data/lib/one_apm/support/dotted_hash.rb +45 -0
- data/lib/one_apm/support/encoders.rb +34 -0
- data/lib/one_apm/support/environment_report.rb +127 -0
- data/lib/one_apm/support/event_buffer.rb +82 -0
- data/lib/one_apm/support/event_buffer/sampled_buffer.rb +45 -0
- data/lib/one_apm/support/event_buffer/sized_buffer.rb +21 -0
- data/lib/one_apm/support/event_buffer/synthetics_event_buffer.rb +40 -0
- data/lib/one_apm/support/helper.rb +49 -0
- data/lib/one_apm/support/hostname.rb +13 -0
- data/lib/one_apm/support/http_clients/curb_wrappers.rb +65 -0
- data/lib/one_apm/support/http_clients/excon_wrappers.rb +63 -0
- data/lib/one_apm/support/http_clients/httpclient_wrappers.rb +61 -0
- data/lib/one_apm/support/http_clients/net_http_wrappers.rb +48 -0
- data/lib/one_apm/support/http_clients/typhoeus_wrappers.rb +73 -0
- data/lib/one_apm/support/http_clients/uri_util.rb +39 -0
- data/lib/one_apm/support/json_marshaller.rb +68 -0
- data/lib/one_apm/support/json_wrapper.rb +130 -0
- data/lib/one_apm/support/language_support.rb +142 -0
- data/lib/one_apm/support/library_detection.rb +119 -0
- data/lib/one_apm/support/local_environment.rb +196 -0
- data/lib/one_apm/support/marshaller.rb +62 -0
- data/lib/one_apm/support/method_tracer.rb +334 -0
- data/lib/one_apm/support/method_tracer/helpers.rb +92 -0
- data/lib/one_apm/support/method_tracer/traced_method_stack.rb +103 -0
- data/lib/one_apm/support/obfuscator.rb +47 -0
- data/lib/one_apm/support/okjson.rb +601 -0
- data/lib/one_apm/support/parameter_filtering.rb +35 -0
- data/lib/one_apm/support/rules_engine.rb +56 -0
- data/lib/one_apm/support/rules_engine/replacement_rule.rb +80 -0
- data/lib/one_apm/support/rules_engine/segment_terms_rule.rb +46 -0
- data/lib/one_apm/support/server.rb +11 -0
- data/lib/one_apm/support/supported_versions.rb +257 -0
- data/lib/one_apm/support/system_info.rb +211 -0
- data/lib/one_apm/support/timer_lib.rb +29 -0
- data/lib/one_apm/support/version_number.rb +51 -0
- data/lib/one_apm/support/vm.rb +30 -0
- data/lib/one_apm/support/vm/jruby_vm.rb +38 -0
- data/lib/one_apm/support/vm/monotonic_gc_profiler.rb +43 -0
- data/lib/one_apm/support/vm/mri_vm.rb +85 -0
- data/lib/one_apm/support/vm/rubinius_vm.rb +129 -0
- data/lib/one_apm/support/vm/snapshot.rb +18 -0
- data/lib/one_apm/transaction.rb +336 -0
- data/lib/one_apm/transaction/class_methods.rb +132 -0
- data/lib/one_apm/transaction/instance_helpers.rb +82 -0
- data/lib/one_apm/transaction/metric_constants.rb +42 -0
- data/lib/one_apm/transaction/sample_buffer/force_persist_sample_buffer.rb +21 -0
- data/lib/one_apm/transaction/sample_buffer/slowest_sample_buffer.rb +21 -0
- data/lib/one_apm/transaction/sample_buffer/synthetics_sample_buffer.rb +21 -0
- data/lib/one_apm/transaction/sample_buffer/transaction_sample_buffer.rb +101 -0
- data/lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb +60 -0
- data/lib/one_apm/transaction/segment.rb +193 -0
- data/lib/one_apm/transaction/segment_summary.rb +51 -0
- data/lib/one_apm/transaction/thread_local_access.rb +73 -0
- data/lib/one_apm/transaction/transaction_analysis.rb +78 -0
- data/lib/one_apm/transaction/transaction_apdex.rb +20 -0
- data/lib/one_apm/transaction/transaction_cpu.rb +22 -0
- data/lib/one_apm/transaction/transaction_finish_append.rb +67 -0
- data/lib/one_apm/transaction/transaction_ignore.rb +33 -0
- data/lib/one_apm/transaction/transaction_jruby_functions.rb +40 -0
- data/lib/one_apm/transaction/transaction_metrics.rb +53 -0
- data/lib/one_apm/transaction/transaction_name.rb +90 -0
- data/lib/one_apm/transaction/transaction_namer.rb +49 -0
- data/lib/one_apm/transaction/transaction_sample.rb +204 -0
- data/lib/one_apm/transaction/transaction_sample_builder.rb +168 -0
- data/lib/one_apm/transaction/transaction_state.rb +149 -0
- data/lib/one_apm/transaction/transaction_summary.rb +28 -0
- data/lib/one_apm/transaction/transaction_synthetics.rb +40 -0
- data/lib/one_apm/transaction/transaction_timings.rb +54 -0
- data/lib/one_apm/version.rb +13 -0
- data/lib/oneapm_rpm.rb +16 -0
- data/lib/sequel/extensions/oneapm_instrumentation.rb +84 -0
- data/lib/sequel/plugins/oneapm_instrumentation.rb +66 -0
- data/oneapm.yml +135 -0
- data/oneapm_rpm.gemspec +58 -0
- metadata +474 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'one_apm/frameworks/ruby'
|
4
|
+
|
5
|
+
module OneApm
|
6
|
+
class Probe
|
7
|
+
module Frameworks
|
8
|
+
class Rails < OneApm::Probe::Frameworks::Ruby
|
9
|
+
|
10
|
+
def env
|
11
|
+
@env ||= RAILS_ENV.dup
|
12
|
+
end
|
13
|
+
|
14
|
+
# Rails can return an empty string from this method, causing
|
15
|
+
# the agent not to start even when it is properly in a rails 3
|
16
|
+
# application, so we test the value to make sure it actually
|
17
|
+
# has contents, and bail to the parent class if it is empty.
|
18
|
+
def root
|
19
|
+
root = rails_root.to_s
|
20
|
+
if !root.empty?
|
21
|
+
root
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def rails_root
|
28
|
+
RAILS_ROOT if defined?(RAILS_ROOT)
|
29
|
+
end
|
30
|
+
|
31
|
+
def rails_config
|
32
|
+
if defined?(::Rails) && ::Rails.respond_to?(:configuration)
|
33
|
+
::Rails.configuration
|
34
|
+
else
|
35
|
+
@config
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# In versions of Rails prior to 2.0, the rails config was only available to
|
40
|
+
# the init.rb, so it had to be passed on from there. This is a best effort to
|
41
|
+
# find a config and use that.
|
42
|
+
def init_config(options={})
|
43
|
+
@config = options[:config]
|
44
|
+
|
45
|
+
if rails_config && ::Rails.configuration.respond_to?(:after_initialize)
|
46
|
+
rails_config.after_initialize do
|
47
|
+
# This will insure we load all the instrumentation as late as possible.
|
48
|
+
LibraryDetection.detect!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if !Agent.config[:agent_enabled]
|
53
|
+
# Might not be running if it does not think mongrel, thin, passenger, etc
|
54
|
+
# is running, if it thinks it's a rake task, or if the agent_enabled is false.
|
55
|
+
::OneApm::Agent.logger.info("OneApm Agent not running.")
|
56
|
+
else
|
57
|
+
install_browser_monitoring(rails_config)
|
58
|
+
install_agent_hooks(rails_config)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def install_agent_hooks(config)
|
63
|
+
return if @agent_hooks_installed
|
64
|
+
@agent_hooks_installed = true
|
65
|
+
return if config.nil? || !config.respond_to?(:middleware)
|
66
|
+
begin
|
67
|
+
require 'one_apm/rack/middleware_hooks'
|
68
|
+
return unless OneApm::Rack::MiddlewareHooks.needed?
|
69
|
+
config.middleware.use OneApm::Rack::MiddlewareHooks
|
70
|
+
::OneApm::Agent.logger.debug("Installed OneApm Agent Hooks middleware")
|
71
|
+
rescue => e
|
72
|
+
::OneApm::Agent.logger.warn("Error installing OneApm Agent Hooks middleware", e)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def install_browser_monitoring(config)
|
77
|
+
return if @browser_monitoring_installed
|
78
|
+
@browser_monitoring_installed = true
|
79
|
+
return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
|
80
|
+
begin
|
81
|
+
require 'one_apm/rack/browser_monitoring'
|
82
|
+
config.middleware.use OneApm::Rack::BrowserMonitoring
|
83
|
+
::OneApm::Agent.logger.debug("Installed OneApm Browser Monitoring middleware")
|
84
|
+
rescue => e
|
85
|
+
::OneApm::Agent.logger.warn("Error installing OneApm Browser Monitoring middleware", e)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
protected
|
90
|
+
|
91
|
+
def install_shim
|
92
|
+
super
|
93
|
+
require 'one_apm/inst/transaction_base'
|
94
|
+
if ActiveSupport.respond_to?(:on_load) # rails 3+
|
95
|
+
ActiveSupport.on_load(:action_controller) { include OneApm::Agent::Instrumentation::TransactionBase::Shim }
|
96
|
+
else
|
97
|
+
ActionController::Base.class_eval { include OneApm::Agent::Instrumentation::TransactionBase::Shim }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'one_apm/frameworks/rails'
|
4
|
+
|
5
|
+
module OneApm
|
6
|
+
class Probe
|
7
|
+
module Frameworks
|
8
|
+
class Rails3 < OneApm::Probe::Frameworks::Rails
|
9
|
+
|
10
|
+
def env
|
11
|
+
@env ||= ::Rails.env.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
def rails_root
|
15
|
+
::Rails.root.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
def vendor_root
|
19
|
+
@vendor_root ||= File.join(root,'vendor','rails')
|
20
|
+
end
|
21
|
+
|
22
|
+
def version
|
23
|
+
@rails_version ||= OneApm::VersionNumber.new(::Rails::VERSION::STRING)
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def install_shim
|
29
|
+
super
|
30
|
+
ActiveSupport.on_load(:action_controller) do
|
31
|
+
include OneApm::Agent::Instrumentation::TransactionBase::Shim
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'one_apm/frameworks/rails3'
|
4
|
+
|
5
|
+
module OneApm
|
6
|
+
class Probe
|
7
|
+
module Frameworks
|
8
|
+
class Rails4 < OneApm::Probe::Frameworks::Rails3
|
9
|
+
def rails_gem_list
|
10
|
+
Bundler.rubygems.all_specs.map do |gem|
|
11
|
+
"#{gem.name} (#{gem.version})"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def append_plugin_list
|
16
|
+
# Rails 4 does not allow plugins
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module OneApm
|
4
|
+
class Probe
|
5
|
+
module Frameworks
|
6
|
+
class Ruby < OneApm::Probe
|
7
|
+
def env
|
8
|
+
@env ||= ENV['ONE_APM_ENV'] || ENV['RUBY_ENV'] ||
|
9
|
+
ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
10
|
+
end
|
11
|
+
|
12
|
+
def root
|
13
|
+
@root ||= ENV['APP_ROOT'] || '.'
|
14
|
+
end
|
15
|
+
|
16
|
+
def init_config(options={})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
LibraryDetection.defer do
|
4
|
+
@name = :active_merchant
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(ActiveMerchant) && defined?(ActiveMerchant::Billing) &&
|
8
|
+
defined?(ActiveMerchant::Billing::Gateway) &&
|
9
|
+
ActiveMerchant::Billing::Gateway.respond_to?(:implementations)
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
::OneApm::Agent.logger.info 'Installing ActiveMerchant instrumentation'
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
class ActiveMerchant::Billing::Gateway
|
18
|
+
include OneApm::Support::MethodTracer
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveMerchant::Billing::Gateway.implementations.each do |gateway|
|
22
|
+
gateway.class_eval do
|
23
|
+
implemented_methods = public_instance_methods(false).map(&:to_sym)
|
24
|
+
gateway_name = self.name.split('::').last
|
25
|
+
[:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update].each do |operation|
|
26
|
+
if implemented_methods.include?(operation)
|
27
|
+
add_method_tracer operation, "ActiveMerchant/gateway/#{gateway_name}/#{operation}"
|
28
|
+
add_method_tracer operation, "ActiveMerchant/gateway/#{gateway_name}", :push_scope => false
|
29
|
+
add_method_tracer operation, "ActiveMerchant/operation/#{operation}", :push_scope => false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module OneApm
|
4
|
+
module Instrumentation
|
5
|
+
module ActsAsSolrInstrumentation
|
6
|
+
module ParserMethodsInstrumentation
|
7
|
+
def parse_query_with_oneapm(*args)
|
8
|
+
self.class.trace_execution_scoped(["SolrClient/ActsAsSolr/query"]) do
|
9
|
+
t0 = Time.now
|
10
|
+
begin
|
11
|
+
parse_query_without_oneapm(*args)
|
12
|
+
ensure
|
13
|
+
OneApm::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
LibraryDetection.defer do
|
23
|
+
@name = :acts_as_solr
|
24
|
+
|
25
|
+
depends_on do
|
26
|
+
defined?(ActsAsSolr)
|
27
|
+
end
|
28
|
+
|
29
|
+
depends_on do
|
30
|
+
defined?(ActsAsSolr::ParserMethods)
|
31
|
+
end
|
32
|
+
|
33
|
+
depends_on do
|
34
|
+
defined?(ActsAsSolr::ClassMethods)
|
35
|
+
end
|
36
|
+
|
37
|
+
depends_on do
|
38
|
+
defined?(ActsAsSolr::CommonMethods)
|
39
|
+
end
|
40
|
+
|
41
|
+
executes do
|
42
|
+
::OneApm::Agent.logger.info 'Installing ActsAsSolr instrumentation'
|
43
|
+
end
|
44
|
+
|
45
|
+
executes do
|
46
|
+
ActsAsSolr::ParserMethods.module_eval do
|
47
|
+
include OneApm::Instrumentation::ActsAsSolrInstrumentation::ParserMethodsInstrumentation
|
48
|
+
alias :parse_query_without_oneapm :parse_query
|
49
|
+
alias :parse_query :parse_query_with_oneapm
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
executes do
|
54
|
+
ActsAsSolr::ClassMethods.module_eval do
|
55
|
+
%w[find_by_solr find_id_by_solr multi_solr_search count_by_solr].each do |method|
|
56
|
+
add_method_tracer method, 'SolrClient/ActsAsSolr/query'
|
57
|
+
end
|
58
|
+
add_method_tracer :rebuild_solr_index, 'SolrClient/ActsAsSolr/index'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
executes do
|
63
|
+
ActsAsSolr::CommonMethods.module_eval do
|
64
|
+
add_method_tracer :solr_add, 'SolrClient/ActsAsSolr/add'
|
65
|
+
add_method_tracer :solr_delete, 'SolrClient/ActsAsSolr/delete'
|
66
|
+
add_method_tracer :solr_commit, 'SolrClient/ActsAsSolr/commit'
|
67
|
+
add_method_tracer :solr_optimize, 'SolrClient/ActsAsSolr/optimize'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
LibraryDetection.defer do
|
4
|
+
@name = :authlogic
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(Authlogic) &&
|
8
|
+
defined?(Authlogic::Session) &&
|
9
|
+
defined?(Authlogic::Session::Base)
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
::OneApm::Agent.logger.info 'Installing Authlogic instrumentation'
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
Authlogic::Session::Base.class_eval do
|
18
|
+
class << self
|
19
|
+
add_method_tracer :find, 'Custom/Authlogic/find'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
LibraryDetection.defer do
|
4
|
+
@name = :sunspot
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(::Sunspot)
|
8
|
+
end
|
9
|
+
|
10
|
+
executes do
|
11
|
+
::OneApm::Agent.logger.info 'Installing Rails Sunspot instrumentation'
|
12
|
+
end
|
13
|
+
|
14
|
+
executes do
|
15
|
+
::Sunspot.module_eval do
|
16
|
+
class << self
|
17
|
+
%w(index index!).each do |method|
|
18
|
+
add_method_tracer method, 'SolrClient/Sunspot/index'
|
19
|
+
end
|
20
|
+
add_method_tracer :commit, 'SolrClient/Sunspot/commit'
|
21
|
+
|
22
|
+
%w[search more_like_this].each do |method|
|
23
|
+
add_method_tracer method, 'SolrClient/Sunspot/query'
|
24
|
+
end
|
25
|
+
%w[remove remove! remove_by_id remove_by_id! remove_all remove_all!].each do |method|
|
26
|
+
add_method_tracer method, 'SolrClient/Sunspot/delete'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
LibraryDetection.defer do
|
4
|
+
named :activejob
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(::ActiveJob::Base)
|
8
|
+
end
|
9
|
+
|
10
|
+
executes do
|
11
|
+
::OneApm::Agent.logger.info 'Installing ActiveJob instrumentation'
|
12
|
+
|
13
|
+
::ActiveJob::Base.around_enqueue do |job, block|
|
14
|
+
::OneApm::Agent::Instrumentation::ActiveJobHelper.enqueue(job, block)
|
15
|
+
end
|
16
|
+
|
17
|
+
::ActiveJob::Base.around_perform do |job, block|
|
18
|
+
::OneApm::Agent::Instrumentation::ActiveJobHelper.perform(job, block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module OneApm
|
24
|
+
module Agent
|
25
|
+
module Instrumentation
|
26
|
+
module ActiveJobHelper
|
27
|
+
include ::OneApm::Support::MethodTracer
|
28
|
+
|
29
|
+
def self.enqueue(job, block)
|
30
|
+
run_in_trace(job, block, :Produce)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.perform(job, block)
|
34
|
+
state = ::OneApm::TransactionState.tl_get
|
35
|
+
|
36
|
+
# Don't nest transactions if we're already in a web transaction.
|
37
|
+
# Probably inline processing the job if that happens, so just trace.
|
38
|
+
if state.in_web_transaction?
|
39
|
+
run_in_trace(job, block, :Consume)
|
40
|
+
elsif state.in_background_transaction?
|
41
|
+
::OneApm::Transaction.set_default_transaction_name(
|
42
|
+
transaction_name_suffix_for_job(job),
|
43
|
+
transaction_category)
|
44
|
+
block.call
|
45
|
+
else
|
46
|
+
run_in_transaction(state, job, block)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.run_in_trace(job, block, event)
|
51
|
+
trace_execution_scoped("MessageBroker/#{adapter}/Queue/#{event}/Named/#{job.queue_name}") do
|
52
|
+
block.call
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.run_in_transaction(state, job, block)
|
57
|
+
::OneApm::Transaction.wrap(state,
|
58
|
+
transaction_name_for_job(job),
|
59
|
+
:other,
|
60
|
+
&block)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.transaction_category
|
64
|
+
"OtherTransaction/#{adapter}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.transaction_name_suffix_for_job(job)
|
68
|
+
"#{job.class}/execute"
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.transaction_name_for_job(job)
|
72
|
+
"#{transaction_category}/#{transaction_name_suffix_for_job(job)}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.adapter
|
76
|
+
clean_adapter_name(::ActiveJob::Base.queue_adapter.name)
|
77
|
+
end
|
78
|
+
|
79
|
+
ADAPTER_REGEX = /ActiveJob::QueueAdapters::(.*)Adapter/
|
80
|
+
|
81
|
+
def self.clean_adapter_name(name)
|
82
|
+
name = "ActiveJob::#{$1}" if ADAPTER_REGEX =~ name
|
83
|
+
name
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|