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,44 @@
|
|
1
|
+
module OneApm
|
2
|
+
module Agent
|
3
|
+
module Instrumentation
|
4
|
+
module Rack
|
5
|
+
include TransactionBase
|
6
|
+
|
7
|
+
def oneapm_request_headers(_)
|
8
|
+
@oneapm_request.env
|
9
|
+
end
|
10
|
+
|
11
|
+
def call_with_oneapm(*args)
|
12
|
+
@oneapm_request = ::Rack::Request.new(args.first)
|
13
|
+
perform_action_with_oneapm_trace(:category => :middleware, :request => @oneapm_request) do
|
14
|
+
result = call_without_oneapm(*args)
|
15
|
+
# Ignore cascaded calls
|
16
|
+
Transaction.abort_transaction! if result.first == 404
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.included middleware
|
22
|
+
middleware.class_eval do
|
23
|
+
alias call_without_oneapm call
|
24
|
+
alias call call_with_oneapm
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.extended middleware
|
29
|
+
middleware.class_eval do
|
30
|
+
class << self
|
31
|
+
alias call_without_oneapm call
|
32
|
+
alias call call_with_oneapm
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def _oa_has_middleware_tracing
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module OneApm
|
2
|
+
module Agent
|
3
|
+
module Instrumentation
|
4
|
+
module RackBuilder
|
5
|
+
|
6
|
+
def run_with_oneapm(app, *args)
|
7
|
+
unless OneApm::Agent.config[:disable_rack_middleware]
|
8
|
+
wrapped_app = ::OneApm::Rack::MiddlewareWrapper.wrap(app, true)
|
9
|
+
run_without_oneapm(wrapped_app, *args)
|
10
|
+
else
|
11
|
+
run_without_oneapm(app, *args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def use_with_oneapm(middleware_class, *args, &blk)
|
16
|
+
unless OneApm::Agent.config[:disable_rack_middleware]
|
17
|
+
wrapped_middleware_class = ::OneApm::Rack::MiddlewareWrapper.wrap_class(middleware_class)
|
18
|
+
use_without_oneapm(wrapped_middleware_class, *args, &blk)
|
19
|
+
else
|
20
|
+
use_without_oneapm(middleware_class, *args, &blk)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# defered detection to avoid something later required
|
25
|
+
def to_app_with_oneapm_deferred_library_detection
|
26
|
+
unless ::Rack::Builder._oa_deferred_detection_ran
|
27
|
+
OneApm::Agent.logger.info "Doing deferred library-detection before Rack startup"
|
28
|
+
LibraryDetection.detect!
|
29
|
+
::Rack::Builder._oa_deferred_detection_ran = true
|
30
|
+
end
|
31
|
+
|
32
|
+
result = to_app_without_oneapm
|
33
|
+
_check_for_late_instrumentation(result)
|
34
|
+
|
35
|
+
result
|
36
|
+
end
|
37
|
+
|
38
|
+
def _check_for_late_instrumentation(app)
|
39
|
+
return if @checked_for_late_instrumentation
|
40
|
+
@checked_for_late_instrumentation = true
|
41
|
+
unless ::OneApm::Agent.config[:disable_rack_middleware]
|
42
|
+
if ::OneApm::Rack::MiddlewareWrapper.needs_wrapping?(app)
|
43
|
+
# TODO Fix it in the future
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
LibraryDetection.defer do
|
4
|
+
@name = :rails21_view
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
!OneApm::Agent.config[:disable_view_instrumentation] &&
|
8
|
+
defined?(ActionController) && defined?(ActionController::Base) && defined?(ActionView::PartialTemplate) && defined?(ActionView::Template) &&
|
9
|
+
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.1\./ # Rails 2.1 &&
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
::OneApm::Agent.logger.info 'Installing Rails 2.1 View instrumentation'
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
ActionView::PartialTemplate.class_eval do
|
18
|
+
include OneApm::Support::MethodTracer
|
19
|
+
add_method_tracer :render, 'View/#{path_without_extension[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Partial'
|
20
|
+
end
|
21
|
+
|
22
|
+
# this is for template rendering, as opposed to partial rendering.
|
23
|
+
ActionView::Template.class_eval do
|
24
|
+
include OneApm::Support::MethodTracer
|
25
|
+
add_method_tracer :render, 'View/#{(path_without_extension || @view.controller.oneapm_metric_path)[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Rendering'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
LibraryDetection.defer do
|
31
|
+
@name = :old_rails_view
|
32
|
+
|
33
|
+
depends_on do
|
34
|
+
!OneApm::Agent.config[:disable_view_instrumentation] &&
|
35
|
+
defined?(ActionController) && defined?(ActionController::Base) &&
|
36
|
+
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^(1\.|2\.0)/ # Rails 1.* - 2.0
|
37
|
+
end
|
38
|
+
|
39
|
+
executes do
|
40
|
+
::OneApm::Agent.logger.info 'Installing Rails 1.* - 2.0 View instrumentation'
|
41
|
+
end
|
42
|
+
|
43
|
+
executes do
|
44
|
+
ActionController::Base.class_eval do
|
45
|
+
include OneApm::Support::MethodTracer
|
46
|
+
add_method_tracer :render, 'View/#{oneapm_metric_path}/Rendering'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
LibraryDetection.defer do
|
52
|
+
@name = :rails23_view
|
53
|
+
|
54
|
+
depends_on do
|
55
|
+
!OneApm::Agent.config[:disable_view_instrumentation] &&
|
56
|
+
defined?(ActionView) && defined?(ActionView::Template) && defined?(ActionView::RenderablePartial) &&
|
57
|
+
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.[23]/
|
58
|
+
end
|
59
|
+
|
60
|
+
executes do
|
61
|
+
::OneApm::Agent.logger.info 'Installing Rails 2.2 - 2.3 View instrumentation'
|
62
|
+
end
|
63
|
+
|
64
|
+
executes do
|
65
|
+
ActionView::RenderablePartial.module_eval do
|
66
|
+
include OneApm::Support::MethodTracer
|
67
|
+
add_method_tracer :render_partial, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Partial'
|
68
|
+
end
|
69
|
+
|
70
|
+
ActionView::Template.class_eval do
|
71
|
+
include OneApm::Support::MethodTracer
|
72
|
+
add_method_tracer :render, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
LibraryDetection.defer do
|
78
|
+
@name = :rails2_controller
|
79
|
+
|
80
|
+
depends_on do
|
81
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
82
|
+
end
|
83
|
+
|
84
|
+
depends_on do
|
85
|
+
defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
|
86
|
+
end
|
87
|
+
|
88
|
+
executes do
|
89
|
+
::OneApm::Agent.logger.info 'Installing Rails 2 Controller instrumentation'
|
90
|
+
end
|
91
|
+
|
92
|
+
executes do
|
93
|
+
ActionController::Base.class_eval do
|
94
|
+
include OneApm::Agent::Instrumentation::TransactionBase
|
95
|
+
|
96
|
+
def perform_action_with_oneapm_trace_wrapper
|
97
|
+
options = {}
|
98
|
+
options[:params] = (respond_to?(:filter_parameters)) ? filter_parameters(params) : params
|
99
|
+
perform_action_with_oneapm_trace(options) { perform_action_without_oneapm_trace }
|
100
|
+
end
|
101
|
+
|
102
|
+
alias_method :perform_action_without_oneapm_trace, :perform_action
|
103
|
+
alias_method :perform_action, :perform_action_with_oneapm_trace_wrapper
|
104
|
+
private :perform_action
|
105
|
+
|
106
|
+
# determine the path that is used in the metric name for
|
107
|
+
# the called controller action
|
108
|
+
def oneapm_metric_path(action_name_override = nil)
|
109
|
+
action_part = action_name_override || action_name
|
110
|
+
if action_name_override || self.class.action_methods.include?(action_part)
|
111
|
+
"#{self.class.controller_path}/#{action_part}"
|
112
|
+
else
|
113
|
+
"#{self.class.controller_path}/(other)"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
LibraryDetection.defer do
|
4
|
+
@name = :rails_action_web_service
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(ActionWebService)
|
8
|
+
end
|
9
|
+
|
10
|
+
executes do
|
11
|
+
::OneApm::Agent.logger.info 'Installing Rails ActionWebService instrumentation'
|
12
|
+
end
|
13
|
+
|
14
|
+
executes do
|
15
|
+
# OneApm Agent instrumentation for WebServices
|
16
|
+
|
17
|
+
# Note Action Web Service is removed from default package in rails
|
18
|
+
# 2.0, this is purely here as a service to our legacy customers.
|
19
|
+
|
20
|
+
# instrumentation for Web Service martialing - XML RPC
|
21
|
+
ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.class_eval do
|
22
|
+
add_method_tracer :decode_request, "WebService/Xml Rpc/XML Decode"
|
23
|
+
add_method_tracer :encode_request, "WebService/Xml Rpc/XML Encode"
|
24
|
+
add_method_tracer :decode_response, "WebService/Xml Rpc/XML Decode"
|
25
|
+
add_method_tracer :encode_response, "WebService/Xml Rpc/XML Encode"
|
26
|
+
end
|
27
|
+
|
28
|
+
# instrumentation for Web Service martialing - Soap
|
29
|
+
ActionWebService::Protocol::Soap::SoapProtocol.class_eval do
|
30
|
+
add_method_tracer :decode_request, "WebService/Soap/XML Decode"
|
31
|
+
add_method_tracer :encode_request, "WebService/Soap/XML Encode"
|
32
|
+
add_method_tracer :decode_response, "WebService/Soap/XML Decode"
|
33
|
+
add_method_tracer :encode_response, "WebService/Soap/XML Encode"
|
34
|
+
end
|
35
|
+
|
36
|
+
if defined?(ActionController) && defined?(ActionController::Base)
|
37
|
+
ActionController::Base.class_eval do
|
38
|
+
if method_defined? :perform_invocation
|
39
|
+
add_method_tracer :perform_invocation, 'WebService/#{controller_name}/#{args.first}'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
LibraryDetection.defer do
|
4
|
+
@name = :rails2_error
|
5
|
+
|
6
|
+
depends_on do
|
7
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
8
|
+
end
|
9
|
+
|
10
|
+
depends_on do
|
11
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 2
|
12
|
+
end
|
13
|
+
|
14
|
+
executes do
|
15
|
+
::OneApm::Agent.logger.info 'Installing Rails 2 Error instrumentation'
|
16
|
+
end
|
17
|
+
|
18
|
+
executes do
|
19
|
+
|
20
|
+
ActionController::Base.class_eval do
|
21
|
+
|
22
|
+
# Make a note of an exception associated with the currently executing
|
23
|
+
# controller action. Note that this used to be available on Object
|
24
|
+
# but we replaced that global method with OneApm::Agent#notice_error.
|
25
|
+
# Use that one outside of controller actions.
|
26
|
+
def oneapm_notice_error(exception, custom_params = {})
|
27
|
+
OneApm::Transaction.notice_error exception, :custom_params => custom_params, :request => request
|
28
|
+
end
|
29
|
+
|
30
|
+
def rescue_action_with_oneapm_trace(exception)
|
31
|
+
rescue_action_without_oneapm_trace exception
|
32
|
+
OneApm::Transaction.notice_error exception, :request => request
|
33
|
+
end
|
34
|
+
|
35
|
+
# Compare with #alias_method_chain, which is not available in
|
36
|
+
# Rails 1.1:
|
37
|
+
alias_method :rescue_action_without_oneapm_trace, :rescue_action
|
38
|
+
alias_method :rescue_action, :rescue_action_with_oneapm_trace
|
39
|
+
protected :rescue_action
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module OneApm
|
4
|
+
module Agent
|
5
|
+
module Instrumentation
|
6
|
+
module Rails3
|
7
|
+
module ActionController
|
8
|
+
# determine the path that is used in the metric name for
|
9
|
+
# the called controller action
|
10
|
+
def oneapm_metric_path(action_name_override = nil)
|
11
|
+
action_part = action_name_override || action_name
|
12
|
+
if action_name_override || self.class.action_methods.include?(action_part)
|
13
|
+
"#{self.class.controller_path}/#{action_part}"
|
14
|
+
else
|
15
|
+
"#{self.class.controller_path}/(other)"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_action(*args) #THREAD_LOCAL_ACCESS
|
20
|
+
perform_action_with_oneapm_trace(:category => :controller,
|
21
|
+
:name => self.action_name,
|
22
|
+
:path => oneapm_metric_path,
|
23
|
+
:params => request.filtered_parameters,
|
24
|
+
:class_name => self.class.name) do
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
module ActionView
|
32
|
+
module OneApm
|
33
|
+
extend self
|
34
|
+
def template_metric(identifier, options = {})
|
35
|
+
if options[:file]
|
36
|
+
"file"
|
37
|
+
elsif identifier.nil?
|
38
|
+
OneApm::Transaction::UNKNOWN_METRIC
|
39
|
+
elsif identifier.include? '/' # this is a filepath
|
40
|
+
identifier.split('/')[-2..-1].join('/')
|
41
|
+
else
|
42
|
+
identifier
|
43
|
+
end
|
44
|
+
end
|
45
|
+
def render_type(file_path)
|
46
|
+
file = File.basename(file_path)
|
47
|
+
if file.starts_with?('_')
|
48
|
+
return 'Partial'
|
49
|
+
else
|
50
|
+
return 'Rendering'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
LibraryDetection.defer do
|
61
|
+
@name = :rails3_controller
|
62
|
+
|
63
|
+
depends_on do
|
64
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
|
65
|
+
end
|
66
|
+
|
67
|
+
depends_on do
|
68
|
+
defined?(ActionController) && defined?(ActionController::Base)
|
69
|
+
end
|
70
|
+
|
71
|
+
executes do
|
72
|
+
::OneApm::Agent.logger.info 'Installing Rails 3 Controller instrumentation'
|
73
|
+
end
|
74
|
+
|
75
|
+
executes do
|
76
|
+
class ActionController::Base
|
77
|
+
include OneApm::Agent::Instrumentation::TransactionBase
|
78
|
+
include OneApm::Agent::Instrumentation::Rails3::ActionController
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
LibraryDetection.defer do
|
83
|
+
@name = :rails30_view
|
84
|
+
|
85
|
+
depends_on do
|
86
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3 && ::Rails::VERSION::MINOR.to_i == 0
|
87
|
+
end
|
88
|
+
|
89
|
+
depends_on do
|
90
|
+
!OneApm::Agent.config[:disable_view_instrumentation]
|
91
|
+
end
|
92
|
+
|
93
|
+
executes do
|
94
|
+
::OneApm::Agent.logger.info 'Installing Rails 3.0 view instrumentation'
|
95
|
+
end
|
96
|
+
|
97
|
+
executes do
|
98
|
+
ActionView::Template.class_eval do
|
99
|
+
include OneApm::Support::MethodTracer
|
100
|
+
def render_with_oneapm(*args, &block)
|
101
|
+
options = if @virtual_path && @virtual_path.starts_with?('/') # file render
|
102
|
+
{:file => true }
|
103
|
+
else
|
104
|
+
{}
|
105
|
+
end
|
106
|
+
template_metric = OneApm::Agent::Instrumentation::Rails3::ActionView::OneApm.template_metric(@identifier, options)
|
107
|
+
render_type = OneApm::Agent::Instrumentation::Rails3::ActionView::OneApm.render_type(@identifier)
|
108
|
+
str = "View/#{template_metric}/#{render_type}"
|
109
|
+
trace_execution_scoped str do
|
110
|
+
render_without_oneapm(*args, &block)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
alias_method :render_without_oneapm, :render
|
115
|
+
alias_method :render, :render_with_oneapm
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
LibraryDetection.defer do
|
122
|
+
@name = :rails31_view
|
123
|
+
|
124
|
+
# We can't be sure that this will work with future versions of Rails 3.
|
125
|
+
# Currently enabled for Rails 3.1 and 3.2
|
126
|
+
depends_on do
|
127
|
+
defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3 && ([1,2].member?(::Rails::VERSION::MINOR.to_i))
|
128
|
+
end
|
129
|
+
|
130
|
+
depends_on do
|
131
|
+
!OneApm::Agent.config[:disable_view_instrumentation]
|
132
|
+
end
|
133
|
+
|
134
|
+
executes do
|
135
|
+
::OneApm::Agent.logger.info 'Installing Rails 3.1/3.2 view instrumentation'
|
136
|
+
end
|
137
|
+
|
138
|
+
executes do
|
139
|
+
ActionView::TemplateRenderer.class_eval do
|
140
|
+
include OneApm::Support::MethodTracer
|
141
|
+
# namespaced helper methods
|
142
|
+
|
143
|
+
def render_with_oneapm(context, options)
|
144
|
+
# This is needed for rails 3.2 compatibility
|
145
|
+
@details = extract_details(options) if respond_to? :extract_details, true
|
146
|
+
identifier = determine_template(options) ? determine_template(options).identifier : nil
|
147
|
+
scope_name = "View/#{OneApm::Agent::Instrumentation::Rails3::ActionView::OneApm.template_metric(identifier, options)}/Rendering"
|
148
|
+
trace_execution_scoped scope_name do
|
149
|
+
render_without_oneapm(context, options)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
alias_method :render_without_oneapm, :render
|
154
|
+
alias_method :render, :render_with_oneapm
|
155
|
+
end
|
156
|
+
|
157
|
+
ActionView::PartialRenderer.class_eval do
|
158
|
+
include OneApm::Support::MethodTracer
|
159
|
+
|
160
|
+
def instrument_with_oneapm(name, payload = {}, &block)
|
161
|
+
identifier = payload[:identifier]
|
162
|
+
scope_name = "View/#{OneApm::Agent::Instrumentation::Rails3::ActionView::OneApm.template_metric(identifier)}/Partial"
|
163
|
+
trace_execution_scoped(scope_name) do
|
164
|
+
instrument_without_oneapm(name, payload, &block)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
alias_method :instrument_without_oneapm, :instrument
|
169
|
+
alias_method :instrument, :instrument_with_oneapm
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|