newrelic_rpm 8.0.0 → 8.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +1936 -0
- data/Brewfile +10 -0
- data/CHANGELOG.md +96 -0
- data/CONTRIBUTING.md +15 -3
- data/Guardfile +8 -8
- data/README.md +3 -1
- data/Rakefile +7 -9
- data/bin/mongrel_rpm +8 -9
- data/bin/newrelic +1 -1
- data/bin/nrdebug +14 -14
- data/init.rb +0 -2
- data/lefthook.yml +9 -0
- data/lib/new_relic/agent/adaptive_sampler.rb +7 -3
- data/lib/new_relic/agent/agent.rb +38 -40
- data/lib/new_relic/agent/agent_logger.rb +8 -9
- data/lib/new_relic/agent/attribute_filter.rb +31 -31
- data/lib/new_relic/agent/attributes.rb +2 -2
- data/lib/new_relic/agent/autostart.rb +6 -7
- data/lib/new_relic/agent/commands/agent_command.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +0 -3
- data/lib/new_relic/agent/configuration/default_source.rb +343 -337
- data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +3 -4
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +2 -4
- data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
- data/lib/new_relic/agent/configuration/manager.rb +57 -57
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
- data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
- data/lib/new_relic/agent/configuration/server_source.rb +10 -10
- data/lib/new_relic/agent/configuration/yaml_source.rb +9 -9
- data/lib/new_relic/agent/connect/request_builder.rb +13 -16
- data/lib/new_relic/agent/connect/response_handler.rb +0 -3
- data/lib/new_relic/agent/custom_event_aggregator.rb +9 -10
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
- data/lib/new_relic/agent/database.rb +20 -24
- data/lib/new_relic/agent/datastores/metric_helper.rb +10 -10
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
- data/lib/new_relic/agent/datastores/redis.rb +2 -4
- data/lib/new_relic/agent/datastores.rb +1 -3
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +11 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -11
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +41 -42
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +24 -24
- data/lib/new_relic/agent/distributed_tracing.rb +17 -18
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +17 -17
- data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/error_filter.rb +16 -10
- data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_buffer.rb +6 -7
- data/lib/new_relic/agent/event_listener.rb +0 -1
- data/lib/new_relic/agent/event_loop.rb +10 -10
- data/lib/new_relic/agent/external.rb +1 -2
- data/lib/new_relic/agent/guid_generator.rb +2 -9
- data/lib/new_relic/agent/harvester.rb +3 -4
- data/lib/new_relic/agent/heap.rb +1 -3
- data/lib/new_relic/agent/hostname.rb +3 -3
- data/lib/new_relic/agent/http_clients/abstract.rb +5 -7
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +8 -3
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +9 -10
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
- data/lib/new_relic/agent/instrumentation/active_job.rb +4 -3
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +36 -42
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -6
- data/lib/new_relic/agent/instrumentation/active_storage.rb +1 -1
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +8 -9
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +7 -8
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +41 -41
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +19 -20
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +9 -10
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +10 -10
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +5 -9
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +0 -1
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
- data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
- data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +58 -0
- data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +25 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +7 -2
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -1
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +9 -2
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +4 -5
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +2 -2
- data/lib/new_relic/agent/instrumentation/padrino.rb +2 -5
- data/lib/new_relic/agent/instrumentation/queue_time.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
- data/lib/new_relic/agent/instrumentation/resque.rb +7 -7
- data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -4
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -3
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +40 -0
- data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +28 -28
- data/lib/new_relic/agent/logging.rb +11 -8
- data/lib/new_relic/agent/memory_logger.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +42 -43
- data/lib/new_relic/agent/method_tracer.rb +17 -15
- data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +19 -16
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
- data/lib/new_relic/agent/monitors.rb +1 -2
- data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
- data/lib/new_relic/agent/new_relic_service.rb +26 -33
- data/lib/new_relic/agent/noticible_error.rb +0 -2
- data/lib/new_relic/agent/null_logger.rb +6 -2
- data/lib/new_relic/agent/obfuscator.rb +6 -8
- data/lib/new_relic/agent/parameter_filtering.rb +15 -7
- data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
- data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
- data/lib/new_relic/agent/rules_engine.rb +2 -2
- data/lib/new_relic/agent/sampler.rb +2 -3
- data/lib/new_relic/agent/sampler_collection.rb +2 -3
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +10 -7
- data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -3
- data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
- data/lib/new_relic/agent/span_event_aggregator.rb +8 -8
- data/lib/new_relic/agent/span_event_primitive.rb +39 -39
- data/lib/new_relic/agent/sql_sampler.rb +9 -9
- data/lib/new_relic/agent/stats.rb +16 -16
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
- data/lib/new_relic/agent/stats_engine.rb +6 -6
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +0 -1
- data/lib/new_relic/agent/system_info.rb +22 -20
- data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
- data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
- data/lib/new_relic/agent/threading/backtrace_service.rb +8 -8
- data/lib/new_relic/agent/threading/thread_profile.rb +15 -18
- data/lib/new_relic/agent/tracer.rb +37 -43
- data/lib/new_relic/agent/transaction/abstract_segment.rb +6 -6
- data/lib/new_relic/agent/transaction/datastore_segment.rb +7 -6
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +8 -9
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
- data/lib/new_relic/agent/transaction/external_request_segment.rb +6 -5
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +23 -23
- data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
- data/lib/new_relic/agent/transaction/segment.rb +6 -3
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
- data/lib/new_relic/agent/transaction/trace.rb +8 -8
- data/lib/new_relic/agent/transaction/trace_context.rb +13 -15
- data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
- data/lib/new_relic/agent/transaction/tracing.rb +1 -3
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
- data/lib/new_relic/agent/transaction.rb +79 -81
- data/lib/new_relic/agent/transaction_error_primitive.rb +16 -16
- data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -6
- data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
- data/lib/new_relic/agent/transaction_metrics.rb +3 -3
- data/lib/new_relic/agent/transaction_sampler.rb +0 -1
- data/lib/new_relic/agent/transaction_time_aggregator.rb +6 -6
- data/lib/new_relic/agent/utilization/azure.rb +1 -1
- data/lib/new_relic/agent/utilization_data.rb +3 -4
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/snapshot.rb +3 -3
- data/lib/new_relic/agent/worker_loop.rb +3 -5
- data/lib/new_relic/agent.rb +22 -22
- data/lib/new_relic/cli/command.rb +15 -17
- data/lib/new_relic/cli/commands/deployments.rb +20 -22
- data/lib/new_relic/cli/commands/install.rb +6 -10
- data/lib/new_relic/coerce.rb +5 -8
- data/lib/new_relic/collection_helper.rb +48 -47
- data/lib/new_relic/control/class_methods.rb +2 -2
- data/lib/new_relic/control/frameworks/external.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +5 -6
- data/lib/new_relic/control/frameworks/rails3.rb +2 -3
- data/lib/new_relic/control/frameworks/ruby.rb +2 -2
- data/lib/new_relic/control/frameworks/sinatra.rb +6 -0
- data/lib/new_relic/control/instance_methods.rb +4 -5
- data/lib/new_relic/control/instrumentation.rb +4 -5
- data/lib/new_relic/control/server_methods.rb +2 -3
- data/lib/new_relic/control.rb +0 -1
- data/lib/new_relic/dependency_detection.rb +6 -8
- data/lib/new_relic/environment_report.rb +16 -18
- data/lib/new_relic/helper.rb +5 -5
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/latest_changes.rb +2 -2
- data/lib/new_relic/local_environment.rb +7 -7
- data/lib/new_relic/metric_data.rb +6 -7
- data/lib/new_relic/metric_spec.rb +3 -3
- data/lib/new_relic/noticed_error.rb +14 -15
- data/lib/new_relic/rack/agent_middleware.rb +2 -2
- data/lib/new_relic/rack/browser_monitoring.rb +9 -9
- data/lib/new_relic/recipes/capistrano3.rb +11 -13
- data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
- data/lib/new_relic/supportability_helper.rb +1 -2
- data/lib/new_relic/version.rb +3 -4
- data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
- data/lib/tasks/all.rb +1 -1
- data/lib/tasks/config.rake +21 -21
- data/lib/tasks/multiverse.rb +4 -6
- data/lib/tasks/tests.rake +3 -7
- data/newrelic.yml +8 -21
- data/newrelic_rpm.gemspec +13 -12
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +55 -55
- metadata +43 -7
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
- data/lib/new_relic/agent/supported_versions.rb +0 -275
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
EXPLAINER = lambda do |statement|
|
12
12
|
connection = NewRelic::Agent::Database.get_connection(statement.config) do
|
13
13
|
::ActiveRecord::Base.send("#{statement.config[:adapter]}_connection",
|
14
|
-
|
14
|
+
statement.config)
|
15
15
|
end
|
16
16
|
if connection && connection.respond_to?(:execute)
|
17
17
|
return connection.execute("EXPLAIN #{statement.sql}")
|
@@ -46,28 +46,29 @@ module NewRelic
|
|
46
46
|
if RUBY_VERSION < "2.7.0"
|
47
47
|
def log_with_newrelic_instrumentation(*args, &block)
|
48
48
|
state = NewRelic::Agent::Tracer.state
|
49
|
-
|
49
|
+
|
50
50
|
if !state.is_execution_traced?
|
51
51
|
return log_without_newrelic_instrumentation(*args, &block)
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
sql, name, _ = args
|
55
|
-
|
55
|
+
|
56
56
|
product, operation, collection = ActiveRecordHelper.product_operation_collection_for(
|
57
57
|
NewRelic::Helper.correctly_encoded(name),
|
58
58
|
NewRelic::Helper.correctly_encoded(sql),
|
59
|
-
@config && @config[:adapter]
|
60
|
-
|
59
|
+
@config && @config[:adapter]
|
60
|
+
)
|
61
|
+
|
61
62
|
host = nil
|
62
63
|
port_path_or_id = nil
|
63
64
|
database = nil
|
64
|
-
|
65
|
+
|
65
66
|
if ActiveRecordHelper::InstanceIdentification.supported_adapter?(@config)
|
66
67
|
host = ActiveRecordHelper::InstanceIdentification.host(@config)
|
67
68
|
port_path_or_id = ActiveRecordHelper::InstanceIdentification.port_path_or_id(@config)
|
68
69
|
database = @config && @config[:database]
|
69
70
|
end
|
70
|
-
|
71
|
+
|
71
72
|
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
72
73
|
product: product,
|
73
74
|
operation: operation,
|
@@ -77,7 +78,7 @@ module NewRelic
|
|
77
78
|
database_name: database
|
78
79
|
)
|
79
80
|
segment._notice_sql(sql, @config, EXPLAINER)
|
80
|
-
|
81
|
+
|
81
82
|
begin
|
82
83
|
NewRelic::Agent::Tracer.capture_segment_error segment do
|
83
84
|
log_without_newrelic_instrumentation(*args, &block)
|
@@ -86,31 +87,32 @@ module NewRelic
|
|
86
87
|
segment.finish if segment
|
87
88
|
end
|
88
89
|
end
|
89
|
-
else
|
90
|
+
else
|
90
91
|
def log_with_newrelic_instrumentation(*args, **kwargs, &block)
|
91
92
|
state = NewRelic::Agent::Tracer.state
|
92
|
-
|
93
|
+
|
93
94
|
if !state.is_execution_traced?
|
94
95
|
return log_without_newrelic_instrumentation(*args, **kwargs, &block)
|
95
96
|
end
|
96
|
-
|
97
|
+
|
97
98
|
sql, name, _ = args
|
98
|
-
|
99
|
+
|
99
100
|
product, operation, collection = ActiveRecordHelper.product_operation_collection_for(
|
100
101
|
NewRelic::Helper.correctly_encoded(name),
|
101
102
|
NewRelic::Helper.correctly_encoded(sql),
|
102
|
-
@config && @config[:adapter]
|
103
|
-
|
103
|
+
@config && @config[:adapter]
|
104
|
+
)
|
105
|
+
|
104
106
|
host = nil
|
105
107
|
port_path_or_id = nil
|
106
108
|
database = nil
|
107
|
-
|
109
|
+
|
108
110
|
if ActiveRecordHelper::InstanceIdentification.supported_adapter?(@config)
|
109
111
|
host = ActiveRecordHelper::InstanceIdentification.host(@config)
|
110
112
|
port_path_or_id = ActiveRecordHelper::InstanceIdentification.port_path_or_id(@config)
|
111
113
|
database = @config && @config[:database]
|
112
114
|
end
|
113
|
-
|
115
|
+
|
114
116
|
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
115
117
|
product: product,
|
116
118
|
operation: operation,
|
@@ -120,7 +122,7 @@ module NewRelic
|
|
120
122
|
database_name: database
|
121
123
|
)
|
122
124
|
segment._notice_sql(sql, @config, EXPLAINER)
|
123
|
-
|
125
|
+
|
124
126
|
begin
|
125
127
|
NewRelic::Agent::Tracer.capture_segment_error segment do
|
126
128
|
log_without_newrelic_instrumentation(*args, **kwargs, &block)
|
@@ -19,7 +19,7 @@ module NewRelic
|
|
19
19
|
def instrument_save_methods
|
20
20
|
::ActiveRecord::Base.class_eval do
|
21
21
|
alias_method :save_without_newrelic, :save
|
22
|
-
|
22
|
+
|
23
23
|
def save(*args, &blk)
|
24
24
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
25
25
|
save_without_newrelic(*args, &blk)
|
@@ -45,7 +45,7 @@ module NewRelic
|
|
45
45
|
update_all_without_newrelic(*args, &blk)
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
alias_method :delete_all_without_newrelic, :delete_all
|
50
50
|
|
51
51
|
if RUBY_VERSION < "2.7.0"
|
@@ -70,7 +70,6 @@ module NewRelic
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
73
|
alias_method :calculate_without_newrelic, :calculate
|
75
74
|
|
76
75
|
def calculate(*args, &blk)
|
@@ -79,7 +78,6 @@ module NewRelic
|
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
82
|
-
|
83
81
|
if method_defined?(:pluck)
|
84
82
|
alias_method :pluck_without_newrelic, :pluck
|
85
83
|
|
@@ -94,12 +92,12 @@ module NewRelic
|
|
94
92
|
end
|
95
93
|
|
96
94
|
ACTIVE_RECORD = "ActiveRecord".freeze
|
97
|
-
OTHER
|
95
|
+
OTHER = "other".freeze
|
98
96
|
|
99
97
|
def product_operation_collection_for name, sql, adapter_name
|
100
|
-
product
|
101
|
-
splits
|
102
|
-
model
|
98
|
+
product = map_product(adapter_name)
|
99
|
+
splits = split_name(name)
|
100
|
+
model = model_from_splits(splits)
|
103
101
|
operation = operation_from_splits(splits, sql)
|
104
102
|
NewRelic::Agent::Datastores::MetricHelper.product_operation_collection_for product, operation, model, ACTIVE_RECORD
|
105
103
|
end
|
@@ -118,8 +116,6 @@ module NewRelic
|
|
118
116
|
def model_from_splits(splits)
|
119
117
|
if splits.length == 2
|
120
118
|
splits.first
|
121
|
-
else
|
122
|
-
nil
|
123
119
|
end
|
124
120
|
end
|
125
121
|
|
@@ -135,16 +131,16 @@ module NewRelic
|
|
135
131
|
# known operations coming in. Anything not matching the list is fine,
|
136
132
|
# it just needs to get downcased directly for use.
|
137
133
|
OPERATION_NAMES = {
|
138
|
-
'Find'
|
139
|
-
'Load'
|
140
|
-
'Count'
|
141
|
-
'Exists'
|
142
|
-
'Create'
|
134
|
+
'Find' => 'find',
|
135
|
+
'Load' => 'find',
|
136
|
+
'Count' => 'find',
|
137
|
+
'Exists' => 'find',
|
138
|
+
'Create' => 'create',
|
143
139
|
'Columns' => 'columns',
|
144
140
|
'Indexes' => 'indexes',
|
145
141
|
'Destroy' => 'destroy',
|
146
|
-
'Update'
|
147
|
-
'Save'
|
142
|
+
'Update' => 'update',
|
143
|
+
'Save' => 'save'
|
148
144
|
}.freeze
|
149
145
|
|
150
146
|
def map_operation(raw_operation)
|
@@ -155,41 +151,41 @@ module NewRelic
|
|
155
151
|
end
|
156
152
|
|
157
153
|
PRODUCT_NAMES = {
|
158
|
-
"mysql"
|
159
|
-
"mysql2"
|
154
|
+
"mysql" => "MySQL",
|
155
|
+
"mysql2" => "MySQL",
|
160
156
|
|
161
157
|
"postgresql" => "Postgres",
|
162
158
|
|
163
|
-
"sqlite3"
|
159
|
+
"sqlite3" => "SQLite",
|
164
160
|
|
165
161
|
# https://rubygems.org/gems/activerecord-jdbcpostgresql-adapter
|
166
|
-
"jdbcmysql"
|
162
|
+
"jdbcmysql" => "MySQL",
|
167
163
|
|
168
164
|
# https://rubygems.org/gems/activerecord-jdbcpostgresql-adapter
|
169
165
|
"jdbcpostgresql" => "Postgres",
|
170
|
-
|
166
|
+
|
171
167
|
# https://rubygems.org/gems/activerecord-postgis-adapter
|
172
|
-
"postgis"
|
168
|
+
"postgis" => "Postgres",
|
173
169
|
|
174
170
|
# https://rubygems.org/gems/activerecord-jdbcsqlite3-adapter
|
175
|
-
"jdbcsqlite3"
|
171
|
+
"jdbcsqlite3" => "SQLite",
|
176
172
|
|
177
173
|
# https://rubygems.org/gems/activerecord-jdbcderby-adapter
|
178
|
-
"derby"
|
179
|
-
"jdbcderby"
|
174
|
+
"derby" => "Derby",
|
175
|
+
"jdbcderby" => "Derby",
|
180
176
|
|
181
177
|
# https://rubygems.org/gems/activerecord-jdbc-adapter
|
182
|
-
"jdbc"
|
178
|
+
"jdbc" => "JDBC",
|
183
179
|
|
184
180
|
# https://rubygems.org/gems/activerecord-jdbcmssql-adapter
|
185
|
-
"jdbcmssql"
|
186
|
-
"mssql"
|
181
|
+
"jdbcmssql" => "MSSQL",
|
182
|
+
"mssql" => "MSSQL",
|
187
183
|
|
188
184
|
# https://rubygems.org/gems/activerecord-sqlserver-adapter
|
189
|
-
"sqlserver"
|
185
|
+
"sqlserver" => "MSSQL",
|
190
186
|
|
191
187
|
# https://rubygems.org/gems/activerecord-odbc-adapter
|
192
|
-
"odbc"
|
188
|
+
"odbc" => "ODBC",
|
193
189
|
|
194
190
|
# https://rubygems.org/gems/activerecord-oracle_enhanced-adapter
|
195
191
|
"oracle_enhanced" => "Oracle"
|
@@ -199,24 +195,24 @@ module NewRelic
|
|
199
195
|
|
200
196
|
def map_product(adapter_name)
|
201
197
|
PRODUCT_NAMES.fetch(adapter_name,
|
202
|
-
|
198
|
+
ACTIVE_RECORD_DEFAULT_PRODUCT_NAME)
|
203
199
|
end
|
204
200
|
|
205
201
|
module InstanceIdentification
|
206
202
|
extend self
|
207
203
|
|
208
204
|
PRODUCT_SYMBOLS = {
|
209
|
-
"mysql"
|
210
|
-
"mysql2"
|
211
|
-
"jdbcmysql"
|
205
|
+
"mysql" => :mysql,
|
206
|
+
"mysql2" => :mysql,
|
207
|
+
"jdbcmysql" => :mysql,
|
212
208
|
|
213
|
-
"postgresql"
|
209
|
+
"postgresql" => :postgres,
|
214
210
|
"jdbcpostgresql" => :postgres,
|
215
|
-
"postgis"
|
211
|
+
"postgis" => :postgres
|
216
212
|
}.freeze
|
217
213
|
|
218
214
|
DATASTORE_DEFAULT_PORTS = {
|
219
|
-
:mysql
|
215
|
+
:mysql => "3306",
|
220
216
|
:postgres => "5432"
|
221
217
|
}.freeze
|
222
218
|
|
@@ -228,10 +224,10 @@ module NewRelic
|
|
228
224
|
def host(config)
|
229
225
|
return UNKNOWN unless config
|
230
226
|
|
231
|
-
configured_value
|
227
|
+
configured_value = config[:host]
|
232
228
|
adapter = PRODUCT_SYMBOLS[config[:adapter]]
|
233
229
|
if configured_value.nil? ||
|
234
|
-
|
230
|
+
postgres_unix_domain_socket_case?(configured_value, adapter)
|
235
231
|
|
236
232
|
LOCALHOST
|
237
233
|
elsif configured_value.empty?
|
@@ -239,7 +235,6 @@ module NewRelic
|
|
239
235
|
else
|
240
236
|
configured_value
|
241
237
|
end
|
242
|
-
|
243
238
|
rescue => e
|
244
239
|
NewRelic::Agent.logger.debug "Failed to retrieve ActiveRecord host: #{e}"
|
245
240
|
UNKNOWN
|
@@ -260,7 +255,6 @@ module NewRelic
|
|
260
255
|
else
|
261
256
|
UNKNOWN
|
262
257
|
end
|
263
|
-
|
264
258
|
rescue => e
|
265
259
|
NewRelic::Agent.logger.debug "Failed to retrieve ActiveRecord port_path_or_id: #{e}"
|
266
260
|
UNKNOWN
|
@@ -5,7 +5,6 @@
|
|
5
5
|
require 'new_relic/agent/instrumentation/active_record_subscriber'
|
6
6
|
require 'new_relic/agent/instrumentation/active_record_prepend'
|
7
7
|
|
8
|
-
|
9
8
|
# Provides a way to send :connection through ActiveSupport notifications to avoid
|
10
9
|
# looping through connection handlers to locate a connection by connection_id
|
11
10
|
# This is not needed in Rails 6+: https://github.com/rails/rails/pull/34602
|
@@ -20,12 +19,13 @@ module NewRelic
|
|
20
19
|
def log(sql, name = "SQL", binds = [], statement_name = nil)
|
21
20
|
@instrumenter.instrument(
|
22
21
|
SQL_ACTIVE_RECORD,
|
23
|
-
:sql
|
24
|
-
:name
|
25
|
-
:connection_id
|
26
|
-
:connection
|
22
|
+
:sql => sql,
|
23
|
+
:name => name,
|
24
|
+
:connection_id => object_id,
|
25
|
+
:connection => self,
|
27
26
|
:statement_name => statement_name,
|
28
|
-
:binds
|
27
|
+
:binds => binds
|
28
|
+
) { yield }
|
29
29
|
rescue => e
|
30
30
|
# The translate_exception_class method got introduced in 4.1
|
31
31
|
if ::ActiveRecord::VERSION::MINOR == 0
|
@@ -41,13 +41,14 @@ module NewRelic
|
|
41
41
|
def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil)
|
42
42
|
@instrumenter.instrument(
|
43
43
|
SQL_ACTIVE_RECORD,
|
44
|
-
sql:
|
45
|
-
name:
|
46
|
-
binds:
|
44
|
+
sql: sql,
|
45
|
+
name: name,
|
46
|
+
binds: binds,
|
47
47
|
type_casted_binds: type_casted_binds,
|
48
|
-
statement_name:
|
49
|
-
connection_id:
|
50
|
-
connection:
|
48
|
+
statement_name: statement_name,
|
49
|
+
connection_id: object_id,
|
50
|
+
connection: self
|
51
|
+
) { yield }
|
51
52
|
rescue => e
|
52
53
|
raise translate_exception_class(e, sql)
|
53
54
|
end
|
@@ -58,17 +59,18 @@ module NewRelic
|
|
58
59
|
def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil) # :doc:
|
59
60
|
@instrumenter.instrument(
|
60
61
|
SQL_ACTIVE_RECORD,
|
61
|
-
sql:
|
62
|
-
name:
|
63
|
-
binds:
|
62
|
+
sql: sql,
|
63
|
+
name: name,
|
64
|
+
binds: binds,
|
64
65
|
type_casted_binds: type_casted_binds,
|
65
|
-
statement_name:
|
66
|
-
connection_id:
|
67
|
-
connection:
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
statement_name: statement_name,
|
67
|
+
connection_id: object_id,
|
68
|
+
connection: self
|
69
|
+
) do
|
70
|
+
@lock.synchronize do
|
71
|
+
yield
|
71
72
|
end
|
73
|
+
end
|
72
74
|
rescue => e
|
73
75
|
raise translate_exception_class(e, sql)
|
74
76
|
end
|
@@ -104,8 +106,9 @@ DependencyDetection.defer do
|
|
104
106
|
executes do
|
105
107
|
ActiveSupport.on_load(:active_record) do
|
106
108
|
::NewRelic::Agent::PrependSupportability.record_metrics_for(
|
107
|
-
|
108
|
-
|
109
|
+
::ActiveRecord::Base,
|
110
|
+
::ActiveRecord::Relation
|
111
|
+
)
|
109
112
|
|
110
113
|
# Default to .prepending, unless the ActiveRecord version is <=4
|
111
114
|
# **AND** the :prepend_active_record_instrumentation config is false
|
@@ -113,9 +116,9 @@ DependencyDetection.defer do
|
|
113
116
|
|| ::NewRelic::Agent.config[:prepend_active_record_instrumentation]
|
114
117
|
|
115
118
|
::ActiveRecord::Base.send(:prepend,
|
116
|
-
|
119
|
+
::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions)
|
117
120
|
::ActiveRecord::Relation.send(:prepend,
|
118
|
-
|
121
|
+
::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions)
|
119
122
|
else
|
120
123
|
::NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_additional_methods
|
121
124
|
end
|
@@ -11,13 +11,13 @@ module NewRelic
|
|
11
11
|
ACTIVE_RECORD = 'ActiveRecord'.freeze
|
12
12
|
|
13
13
|
module BaseExtensions
|
14
|
-
|
15
14
|
if RUBY_VERSION < "2.7.0"
|
16
15
|
def save(*args, &blk)
|
17
16
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
18
17
|
super
|
19
18
|
end
|
20
19
|
end
|
20
|
+
|
21
21
|
def save!(*args, &blk)
|
22
22
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
23
23
|
super
|
@@ -30,11 +30,12 @@ module NewRelic
|
|
30
30
|
super
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
33
34
|
def save!(*args, **kwargs, &blk)
|
34
35
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
35
36
|
super
|
36
37
|
end
|
37
|
-
end
|
38
|
+
end
|
38
39
|
|
39
40
|
end
|
40
41
|
end
|
@@ -58,7 +59,6 @@ module NewRelic
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
61
|
-
|
62
62
|
end
|
63
63
|
|
64
64
|
module RelationExtensions
|
@@ -43,7 +43,7 @@ module NewRelic
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def start(name, id, payload) #THREAD_LOCAL_ACCESS
|
46
|
+
def start(name, id, payload) # THREAD_LOCAL_ACCESS
|
47
47
|
return if cached?(payload)
|
48
48
|
return unless NewRelic::Agent.tl_is_execution_traced?
|
49
49
|
|
@@ -54,7 +54,7 @@ module NewRelic
|
|
54
54
|
log_notification_error(e, name, 'start')
|
55
55
|
end
|
56
56
|
|
57
|
-
def finish(name, id, payload) #THREAD_LOCAL_ACCESS
|
57
|
+
def finish(name, id, payload) # THREAD_LOCAL_ACCESS
|
58
58
|
return if cached?(payload)
|
59
59
|
return unless state.is_execution_traced?
|
60
60
|
|
@@ -64,7 +64,6 @@ module NewRelic
|
|
64
64
|
end
|
65
65
|
segment.finish
|
66
66
|
end
|
67
|
-
|
68
67
|
rescue => e
|
69
68
|
log_notification_error(e, name, 'finish')
|
70
69
|
end
|
@@ -72,12 +71,12 @@ module NewRelic
|
|
72
71
|
def get_explain_plan(statement)
|
73
72
|
connection = NewRelic::Agent::Database.get_connection(statement.config) do
|
74
73
|
::ActiveRecord::Base.send("#{statement.config[:adapter]}_connection",
|
75
|
-
|
74
|
+
statement.config)
|
76
75
|
end
|
77
76
|
if connection && connection.respond_to?(:exec_query)
|
78
77
|
return connection.exec_query("EXPLAIN #{statement.sql}",
|
79
|
-
|
80
|
-
|
78
|
+
"Explain #{statement.name}",
|
79
|
+
statement.binds)
|
81
80
|
end
|
82
81
|
rescue => e
|
83
82
|
NewRelic::Agent.logger.debug "Couldn't fetch the explain plan for #{statement} due to #{e}"
|
@@ -8,17 +8,16 @@ module NewRelic
|
|
8
8
|
module Instrumentation
|
9
9
|
module ActsAsSolrInstrumentation
|
10
10
|
module ParserMethodsInstrumentation
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
txn.current_segment.params[:statement] = ::NewRelic::Agent::Database.truncate_query(args.first.inspect) rescue nil
|
19
|
-
end
|
11
|
+
def parse_query_with_newrelic(*args)
|
12
|
+
self.class.trace_execution_scoped(["SolrClient/ActsAsSolr/query"]) do
|
13
|
+
begin
|
14
|
+
parse_query_without_newrelic(*args)
|
15
|
+
ensure
|
16
|
+
return unless txn = ::NewRelic::Agent::Tracer.current_transaction
|
17
|
+
txn.current_segment.params[:statement] = ::NewRelic::Agent::Database.truncate_query(args.first.inspect) rescue nil
|
20
18
|
end
|
21
19
|
end
|
20
|
+
end
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
@@ -12,7 +12,7 @@ module NewRelic
|
|
12
12
|
LIBRARY = 'RabbitMQ'
|
13
13
|
DEFAULT_NAME = 'Default'
|
14
14
|
DEFAULT_TYPE = :direct
|
15
|
-
SLASH
|
15
|
+
SLASH = '/'
|
16
16
|
|
17
17
|
def exchange_name name
|
18
18
|
name.empty? ? DEFAULT_NAME : name
|
@@ -74,11 +74,11 @@ module NewRelic
|
|
74
74
|
|
75
75
|
begin
|
76
76
|
exch_name, exch_type = if delivery_info
|
77
|
-
[
|
78
|
-
exchange_type(delivery_info, channel)
|
77
|
+
[exchange_name(delivery_info.exchange),
|
78
|
+
exchange_type(delivery_info, channel)]
|
79
79
|
else
|
80
|
-
[
|
81
|
-
exchange_type({}, channel)
|
80
|
+
[exchange_name(NewRelic::EMPTY_STR),
|
81
|
+
exchange_type({}, channel)]
|
82
82
|
end
|
83
83
|
|
84
84
|
segment = NewRelic::Agent::Messaging.start_amqp_consume_segment(
|
@@ -139,12 +139,11 @@ module NewRelic
|
|
139
139
|
delivery_info: delivery_info,
|
140
140
|
message_properties: message_properties,
|
141
141
|
exchange_type: exchange_type(delivery_info, channel),
|
142
|
-
queue_name: queue_name
|
143
|
-
|
142
|
+
queue_name: queue_name
|
143
|
+
) do
|
144
144
|
yield
|
145
145
|
end
|
146
146
|
end
|
147
|
-
|
148
147
|
end
|
149
148
|
end
|
150
149
|
end
|