newrelic_rpm 8.7.0 → 8.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rubocop.yml +68 -189
- data/.rubocop_todo.yml +52 -0
- data/.simplecov +15 -0
- data/.snyk +11 -0
- data/.yardopts +1 -0
- data/Brewfile +1 -0
- data/CHANGELOG.md +181 -23
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +0 -1
- data/Guardfile +1 -0
- data/README.md +1 -1
- data/Rakefile +13 -20
- data/Thorfile +5 -0
- data/bin/newrelic +2 -1
- data/bin/newrelic_cmd +1 -0
- data/bin/nrdebug +66 -45
- data/config.dot +5 -5
- data/init.rb +4 -4
- data/install.rb +2 -2
- data/lib/new_relic/agent/adaptive_sampler.rb +4 -4
- data/lib/new_relic/agent/agent/shutdown.rb +34 -0
- data/lib/new_relic/agent/agent/special_startup.rb +70 -0
- data/lib/new_relic/agent/agent/start_worker_thread.rb +163 -0
- data/lib/new_relic/agent/agent/startup.rb +196 -0
- data/lib/new_relic/agent/agent.rb +134 -534
- data/lib/new_relic/agent/agent_logger.rb +8 -10
- data/lib/new_relic/agent/attribute_filter.rb +40 -21
- data/lib/new_relic/agent/attribute_processing.rb +7 -7
- data/lib/new_relic/agent/attributes.rb +2 -2
- data/lib/new_relic/agent/audit_logger.rb +3 -3
- data/lib/new_relic/agent/autostart.rb +2 -2
- data/lib/new_relic/agent/chained_call.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command_router.rb +8 -8
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +1 -1
- data/lib/new_relic/agent/configuration/default_source.rb +105 -41
- data/lib/new_relic/agent/configuration/dotted_hash.rb +2 -2
- data/lib/new_relic/agent/configuration/environment_source.rb +5 -5
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +1 -1
- data/lib/new_relic/agent/configuration/high_security_source.rb +1 -1
- data/lib/new_relic/agent/configuration/manager.rb +5 -5
- data/lib/new_relic/agent/configuration/manual_source.rb +1 -1
- data/lib/new_relic/agent/configuration/mask_defaults.rb +3 -3
- data/lib/new_relic/agent/configuration/security_policy_source.rb +7 -4
- data/lib/new_relic/agent/configuration/server_source.rb +7 -7
- data/lib/new_relic/agent/configuration/yaml_source.rb +6 -4
- data/lib/new_relic/agent/configuration.rb +1 -1
- data/lib/new_relic/agent/connect/request_builder.rb +3 -3
- data/lib/new_relic/agent/connect/response_handler.rb +5 -5
- data/lib/new_relic/agent/custom_event_aggregator.rb +5 -5
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +1 -1
- data/lib/new_relic/agent/database/obfuscator.rb +2 -2
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +1 -1
- data/lib/new_relic/agent/database.rb +21 -21
- data/lib/new_relic/agent/database_adapter.rb +1 -1
- data/lib/new_relic/agent/datastores/metric_helper.rb +12 -13
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +4 -3
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +2 -4
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +2 -2
- data/lib/new_relic/agent/datastores/mongo.rb +1 -1
- data/lib/new_relic/agent/datastores/redis.rb +3 -3
- data/lib/new_relic/agent/datastores.rb +4 -4
- data/lib/new_relic/agent/deprecator.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +16 -17
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +9 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +18 -19
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +8 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +2 -3
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +40 -40
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +16 -15
- 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 +6 -5
- data/lib/new_relic/agent/error_event_aggregator.rb +3 -4
- data/lib/new_relic/agent/error_filter.rb +5 -5
- data/lib/new_relic/agent/error_trace_aggregator.rb +3 -3
- data/lib/new_relic/agent/event_aggregator.rb +20 -20
- data/lib/new_relic/agent/event_buffer.rb +1 -1
- data/lib/new_relic/agent/event_listener.rb +1 -1
- data/lib/new_relic/agent/event_loop.rb +9 -9
- data/lib/new_relic/agent/external.rb +10 -10
- data/lib/new_relic/agent/guid_generator.rb +2 -2
- data/lib/new_relic/agent/harvester.rb +1 -1
- data/lib/new_relic/agent/heap.rb +5 -5
- data/lib/new_relic/agent/hostname.rb +4 -3
- data/lib/new_relic/agent/http_clients/abstract.rb +1 -2
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +5 -6
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -5
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +0 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/uri_util.rb +1 -2
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +6 -5
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +31 -23
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +7 -6
- data/lib/new_relic/agent/instrumentation/active_job.rb +11 -4
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +4 -3
- data/lib/new_relic/agent/instrumentation/active_record.rb +9 -9
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +37 -21
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +21 -11
- data/lib/new_relic/agent/instrumentation/active_storage.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +16 -15
- data/lib/new_relic/agent/instrumentation/active_support_logger/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +2 -2
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
- data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -2
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +10 -10
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +10 -11
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/bunny.rb +1 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +25 -17
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +21 -22
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +19 -16
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +2 -3
- data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +44 -44
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -2
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +2 -3
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +1 -2
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -3
- data/lib/new_relic/agent/instrumentation/excon.rb +2 -2
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +6 -6
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +97 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +89 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +111 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +30 -0
- data/lib/new_relic/agent/instrumentation/grpc/helper.rb +32 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/chain.rb +69 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +134 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/rpc_desc_prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/rpc_server_prepend.rb +26 -0
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +23 -0
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +25 -0
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httprb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -2
- data/lib/new_relic/agent/instrumentation/logger/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/logger/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/logger.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +24 -17
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +8 -9
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +17 -15
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +21 -15
- data/lib/new_relic/agent/instrumentation/memcache.rb +5 -6
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +0 -1
- data/lib/new_relic/agent/instrumentation/mongo.rb +2 -2
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +15 -14
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net_http.rb +2 -2
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +6 -6
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino.rb +2 -2
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -2
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +12 -12
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +7 -7
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +4 -4
- 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_middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -2
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rake.rb +3 -3
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +3 -4
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +5 -6
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +3 -4
- data/lib/new_relic/agent/instrumentation/redis.rb +2 -2
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sequel.rb +8 -8
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -5
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -4
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread.rb +2 -2
- data/lib/new_relic/agent/instrumentation/tilt/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +8 -8
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
- data/lib/new_relic/agent/instrumentation.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +8 -8
- data/lib/new_relic/agent/linking_metadata.rb +2 -3
- data/lib/new_relic/agent/local_log_decorator.rb +0 -1
- data/lib/new_relic/agent/log_event_aggregator.rb +7 -7
- data/lib/new_relic/agent/log_once.rb +1 -1
- data/lib/new_relic/agent/log_priority.rb +1 -1
- data/lib/new_relic/agent/logging.rb +13 -13
- data/lib/new_relic/agent/memory_logger.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +19 -20
- data/lib/new_relic/agent/method_tracer.rb +15 -10
- data/lib/new_relic/agent/method_tracer_helpers.rb +83 -1
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -4
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +3 -3
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +1 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +2 -2
- data/lib/new_relic/agent/monitors.rb +5 -5
- data/lib/new_relic/agent/new_relic_service/encoders.rb +2 -2
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +4 -4
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +1 -1
- data/lib/new_relic/agent/new_relic_service.rb +214 -166
- data/lib/new_relic/agent/{noticible_error.rb → noticeable_error.rb} +2 -3
- data/lib/new_relic/agent/null_logger.rb +1 -1
- data/lib/new_relic/agent/obfuscator.rb +3 -3
- data/lib/new_relic/agent/parameter_filtering.rb +1 -1
- data/lib/new_relic/agent/payload_metric_mapping.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +10 -5
- data/lib/new_relic/agent/pipe_service.rb +2 -2
- data/lib/new_relic/agent/prepend_supportability.rb +2 -2
- data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -4
- data/lib/new_relic/agent/range_extensions.rb +8 -28
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +2 -2
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -1
- data/lib/new_relic/agent/rules_engine.rb +2 -2
- data/lib/new_relic/agent/sampler.rb +1 -1
- data/lib/new_relic/agent/sampler_collection.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -2
- data/lib/new_relic/agent/samplers/memory_sampler.rb +10 -10
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/vm_sampler.rb +3 -1
- data/lib/new_relic/agent/span_event_aggregator.rb +2 -2
- data/lib/new_relic/agent/span_event_primitive.rb +24 -19
- data/lib/new_relic/agent/sql_sampler.rb +8 -8
- data/lib/new_relic/agent/stats.rb +15 -4
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -2
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -4
- data/lib/new_relic/agent/stats_engine.rb +1 -1
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +6 -6
- data/lib/new_relic/agent/system_info.rb +68 -53
- data/lib/new_relic/agent/threading/agent_thread.rb +13 -9
- data/lib/new_relic/agent/threading/backtrace_node.rb +6 -4
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
- data/lib/new_relic/agent/threading/thread_profile.rb +4 -4
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +19 -17
- data/lib/new_relic/agent/transaction/abstract_segment.rb +93 -34
- data/lib/new_relic/agent/transaction/datastore_segment.rb +12 -12
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +52 -48
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
- data/lib/new_relic/agent/transaction/external_request_segment.rb +37 -29
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +6 -6
- data/lib/new_relic/agent/transaction/request_attributes.rb +29 -29
- data/lib/new_relic/agent/transaction/segment.rb +8 -8
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/trace.rb +3 -3
- data/lib/new_relic/agent/transaction/trace_builder.rb +10 -10
- data/lib/new_relic/agent/transaction/trace_context.rb +22 -20
- data/lib/new_relic/agent/transaction/trace_node.rb +9 -9
- data/lib/new_relic/agent/transaction/tracing.rb +7 -7
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
- data/lib/new_relic/agent/transaction.rb +35 -31
- data/lib/new_relic/agent/transaction_error_primitive.rb +9 -9
- data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -5
- data/lib/new_relic/agent/transaction_event_primitive.rb +3 -4
- data/lib/new_relic/agent/transaction_event_recorder.rb +15 -14
- data/lib/new_relic/agent/transaction_metrics.rb +4 -4
- data/lib/new_relic/agent/transaction_sampler.rb +5 -5
- data/lib/new_relic/agent/transaction_time_aggregator.rb +14 -14
- data/lib/new_relic/agent/utilization/aws.rb +4 -4
- data/lib/new_relic/agent/utilization/azure.rb +2 -2
- data/lib/new_relic/agent/utilization/gcp.rb +7 -7
- data/lib/new_relic/agent/utilization/pcf.rb +4 -4
- data/lib/new_relic/agent/utilization/vendor.rb +28 -28
- data/lib/new_relic/agent/utilization_data.rb +1 -1
- data/lib/new_relic/agent/vm/jruby_vm.rb +1 -1
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +36 -23
- data/lib/new_relic/agent/vm/snapshot.rb +2 -2
- data/lib/new_relic/agent/vm.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +2 -2
- data/lib/new_relic/agent.rb +27 -27
- data/lib/new_relic/cli/command.rb +6 -6
- data/lib/new_relic/cli/commands/deployments.rb +81 -29
- data/lib/new_relic/cli/commands/install.rb +6 -6
- data/lib/new_relic/coerce.rb +5 -6
- data/lib/new_relic/collection_helper.rb +4 -4
- data/lib/new_relic/constants.rb +0 -1
- data/lib/new_relic/control/class_methods.rb +1 -1
- data/lib/new_relic/control/frameworks/external.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +3 -3
- data/lib/new_relic/control/frameworks/rails3.rb +1 -1
- data/lib/new_relic/control/frameworks/rails4.rb +1 -1
- data/lib/new_relic/control/frameworks/rails_notifications.rb +1 -1
- data/lib/new_relic/control/frameworks/ruby.rb +1 -1
- data/lib/new_relic/control/frameworks/sinatra.rb +1 -1
- data/lib/new_relic/control/frameworks.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +20 -42
- data/lib/new_relic/control/instrumentation.rb +7 -7
- data/lib/new_relic/control/private_instance_methods.rb +48 -0
- data/lib/new_relic/control/server_methods.rb +2 -2
- data/lib/new_relic/control.rb +1 -1
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +23 -22
- data/lib/new_relic/environment_report.rb +24 -14
- data/lib/new_relic/helper.rb +5 -5
- data/lib/new_relic/language_support.rb +8 -3
- data/lib/new_relic/latest_changes.rb +4 -4
- data/lib/new_relic/local_environment.rb +9 -11
- data/lib/new_relic/metric_data.rb +30 -24
- data/lib/new_relic/metric_spec.rb +3 -3
- data/lib/new_relic/noticed_error.rb +3 -6
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +1 -1
- data/lib/new_relic/rack/browser_monitoring.rb +132 -123
- data/lib/new_relic/rack.rb +1 -1
- data/lib/new_relic/recipes/capistrano3.rb +3 -59
- data/lib/new_relic/recipes/capistrano_legacy.rb +13 -13
- data/lib/new_relic/recipes/helpers/send_deployment.rb +69 -0
- data/lib/new_relic/recipes.rb +1 -1
- data/lib/new_relic/supportability_helper.rb +6 -6
- data/lib/new_relic/traced_thread.rb +5 -7
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +8 -8
- data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
- data/lib/tasks/all.rb +1 -1
- data/lib/tasks/config.rake +8 -112
- data/lib/tasks/coverage_report.rake +28 -0
- data/lib/tasks/{config.html.erb → helpers/config.html.erb} +0 -0
- data/lib/tasks/{config.text.erb → helpers/config.text.erb} +0 -0
- data/lib/tasks/helpers/format.rb +120 -0
- data/lib/tasks/helpers/matches.rb +12 -0
- data/lib/tasks/helpers/prompt.rb +24 -0
- data/lib/tasks/helpers/removers.rb +33 -0
- data/lib/tasks/install.rake +4 -0
- data/lib/tasks/instrumentation_generator/README.md +63 -0
- data/lib/tasks/instrumentation_generator/TODO.md +33 -0
- data/lib/tasks/instrumentation_generator/instrumentation.thor +102 -0
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +9 -0
- data/lib/tasks/instrumentation_generator/templates/chain.tt +21 -0
- data/lib/tasks/instrumentation_generator/templates/chain_method.tt +7 -0
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +29 -0
- data/lib/tasks/instrumentation_generator/templates/instrumentation.tt +12 -0
- data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +3 -0
- data/lib/tasks/instrumentation_generator/templates/newrelic.yml.tt +19 -0
- data/lib/tasks/instrumentation_generator/templates/prepend.tt +13 -0
- data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +3 -0
- data/lib/tasks/instrumentation_generator/templates/test.tt +15 -0
- data/lib/tasks/multiverse.rake +4 -0
- data/lib/tasks/multiverse.rb +5 -30
- data/lib/tasks/newrelic.rb +1 -1
- data/lib/tasks/tests.rake +7 -8
- data/newrelic.yml +514 -483
- data/newrelic_rpm.gemspec +16 -21
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +125 -147
- metadata +82 -90
- data/bin/mongrel_rpm +0 -32
@@ -1,6 +1,7 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
4
5
|
require 'new_relic/agent/instrumentation/notifications_subscriber'
|
5
6
|
require 'new_relic/agent/instrumentation/ignore_actions'
|
6
7
|
require 'new_relic/agent/parameter_filtering'
|
@@ -10,13 +11,10 @@ module NewRelic
|
|
10
11
|
module Instrumentation
|
11
12
|
class ActionControllerSubscriber < NotificationsSubscriber
|
12
13
|
def start(name, id, payload) # THREAD_LOCAL_ACCESS
|
13
|
-
# @req is a historically stable but not guaranteed Rails header property
|
14
|
-
request = payload[:headers].instance_variable_get(:@req)
|
15
|
-
|
16
14
|
controller_class = controller_class(payload)
|
17
15
|
|
18
16
|
if state.is_execution_traced? && !should_ignore(payload, controller_class)
|
19
|
-
finishable = start_transaction_or_segment(payload,
|
17
|
+
finishable = start_transaction_or_segment(payload, request_for_payload(payload), controller_class)
|
20
18
|
push_segment(id, finishable)
|
21
19
|
else
|
22
20
|
# if this transaction is ignored, make sure child
|
@@ -50,27 +48,30 @@ module NewRelic
|
|
50
48
|
Tracer.start_transaction_or_segment(
|
51
49
|
name: format_metric_name(payload[:action], controller_class),
|
52
50
|
category: :controller,
|
53
|
-
options:
|
54
|
-
request: request,
|
55
|
-
filtered_params: NewRelic::Agent::ParameterFiltering.filter_using_rails(
|
56
|
-
payload[:params],
|
57
|
-
Rails.application.config.filter_parameters
|
58
|
-
),
|
59
|
-
apdex_start_time: queue_start(request),
|
60
|
-
ignore_apdex: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
|
61
|
-
ControllerInstrumentation::NR_IGNORE_APDEX_KEY,
|
62
|
-
controller_class,
|
63
|
-
payload[:action]
|
64
|
-
),
|
65
|
-
ignore_enduser: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
|
66
|
-
ControllerInstrumentation::NR_IGNORE_ENDUSER_KEY,
|
67
|
-
controller_class,
|
68
|
-
payload[:action]
|
69
|
-
)
|
70
|
-
}
|
51
|
+
options: tracer_options(payload, request, controller_class)
|
71
52
|
)
|
72
53
|
end
|
73
54
|
|
55
|
+
def tracer_options(payload, request, controller_class)
|
56
|
+
{
|
57
|
+
request: request,
|
58
|
+
filtered_params: filtered_params(payload[:params]),
|
59
|
+
apdex_start_time: queue_start(request),
|
60
|
+
ignore_apdex: ignore?(payload[:action], ControllerInstrumentation::NR_IGNORE_APDEX_KEY, controller_class),
|
61
|
+
ignore_enduser: ignore?(payload[:action],
|
62
|
+
ControllerInstrumentation::NR_IGNORE_ENDUSER_KEY,
|
63
|
+
controller_class)
|
64
|
+
}.merge(NewRelic::Agent::MethodTracerHelpers.code_information(controller_class, payload[:action]))
|
65
|
+
end
|
66
|
+
|
67
|
+
def filtered_params(params)
|
68
|
+
NewRelic::Agent::ParameterFiltering.filter_using_rails(params, Rails.application.config.filter_parameters)
|
69
|
+
end
|
70
|
+
|
71
|
+
def ignore?(action, key, controller_class)
|
72
|
+
NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(key, controller_class, action)
|
73
|
+
end
|
74
|
+
|
74
75
|
def format_metric_name(metric_action, controller)
|
75
76
|
controller_class = controller.is_a?(Class) ? controller : Object.const_get(controller)
|
76
77
|
"Controller/#{controller_class.controller_path}/#{metric_action}"
|
@@ -93,6 +94,13 @@ module NewRelic
|
|
93
94
|
QueueTime.parse_frontend_timestamp(request.env, Process.clock_gettime(Process::CLOCK_REALTIME))
|
94
95
|
end
|
95
96
|
end
|
97
|
+
|
98
|
+
def request_for_payload(payload)
|
99
|
+
# @req is a historically stable but not guaranteed Rails header property
|
100
|
+
return unless payload[:headers].instance_variables.include?(:@req)
|
101
|
+
|
102
|
+
payload[:headers].instance_variable_get(:@req)
|
103
|
+
end
|
96
104
|
end
|
97
105
|
end
|
98
106
|
end
|
@@ -1,6 +1,7 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
4
5
|
require 'new_relic/agent/instrumentation/notifications_subscriber'
|
5
6
|
|
6
7
|
# Listen for ActiveSupport::Notifications events for ActionView render
|
@@ -17,7 +18,7 @@ module NewRelic
|
|
17
18
|
if state.is_execution_traced? && recordable?(name, metric_name)
|
18
19
|
event.finishable = Tracer.start_segment(name: metric_name)
|
19
20
|
end
|
20
|
-
push_segment
|
21
|
+
push_segment(id, event)
|
21
22
|
rescue => e
|
22
23
|
log_notification_error(e, name, 'start')
|
23
24
|
end
|
@@ -25,7 +26,7 @@ module NewRelic
|
|
25
26
|
def finish(name, id, payload)
|
26
27
|
if segment = pop_segment(id)
|
27
28
|
if exception = exception_object(payload)
|
28
|
-
segment.notice_error
|
29
|
+
segment.notice_error(exception)
|
29
30
|
end
|
30
31
|
segment.finish
|
31
32
|
end
|
@@ -63,7 +64,7 @@ module NewRelic
|
|
63
64
|
|
64
65
|
def metric_action(name)
|
65
66
|
case name
|
66
|
-
when /#{RENDER_TEMPLATE_EVENT_NAME}$/ then 'Rendering'
|
67
|
+
when /#{RENDER_TEMPLATE_EVENT_NAME}$/o then 'Rendering'
|
67
68
|
when RENDER_PARTIAL_EVENT_NAME then 'Partial'
|
68
69
|
when RENDER_COLLECTION_EVENT_NAME then 'Partial'
|
69
70
|
end
|
@@ -101,8 +102,8 @@ module NewRelic
|
|
101
102
|
@finishable.finish if @finishable
|
102
103
|
end
|
103
104
|
|
104
|
-
def notice_error
|
105
|
-
@finishable.notice_error
|
105
|
+
def notice_error(error)
|
106
|
+
@finishable.notice_error(error) if @finishable
|
106
107
|
end
|
107
108
|
end
|
108
109
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/prepend_supportability'
|
6
6
|
|
@@ -12,7 +12,7 @@ DependencyDetection.defer do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
executes do
|
15
|
-
::NewRelic::Agent.logger.info
|
15
|
+
::NewRelic::Agent.logger.info('Installing ActiveJob instrumentation')
|
16
16
|
|
17
17
|
ActiveSupport.on_load(:active_job) do
|
18
18
|
::ActiveJob::Base.around_enqueue do |job, block|
|
@@ -58,14 +58,21 @@ module NewRelic
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.run_in_trace(job, block, event)
|
61
|
-
trace_execution_scoped("MessageBroker/#{adapter}/Queue/#{event}/Named/#{job.queue_name}"
|
61
|
+
trace_execution_scoped("MessageBroker/#{adapter}/Queue/#{event}/Named/#{job.queue_name}",
|
62
|
+
code_information: code_information_for_job(job)) do
|
62
63
|
block.call
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
66
67
|
def self.run_in_transaction(job, block)
|
68
|
+
options = code_information_for_job(job)
|
69
|
+
options = {} if options.frozen? # the hash will be added to later
|
67
70
|
::NewRelic::Agent::Tracer.in_transaction(name: transaction_name_for_job(job),
|
68
|
-
category: :other, &block)
|
71
|
+
category: :other, options: options, &block)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.code_information_for_job(job)
|
75
|
+
NewRelic::Agent::MethodTracerHelpers.code_information(job.class, :perform)
|
69
76
|
end
|
70
77
|
|
71
78
|
def self.transaction_category
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
DependencyDetection.defer do
|
6
6
|
@name = :active_merchant
|
@@ -12,7 +12,7 @@ DependencyDetection.defer do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
executes do
|
15
|
-
::NewRelic::Agent.logger.info
|
15
|
+
::NewRelic::Agent.logger.info('Installing ActiveMerchant instrumentation')
|
16
16
|
end
|
17
17
|
|
18
18
|
executes do
|
@@ -24,7 +24,8 @@ DependencyDetection.defer do
|
|
24
24
|
gateway.class_eval do
|
25
25
|
implemented_methods = public_instance_methods(false).map(&:to_sym)
|
26
26
|
gateway_name = self.name.split('::').last
|
27
|
-
[:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update]
|
27
|
+
actions = [:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update]
|
28
|
+
actions.each do |operation|
|
28
29
|
if implemented_methods.include?(operation)
|
29
30
|
add_method_tracer operation, [-> (*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
|
30
31
|
-> (*) { "ActiveMerchant/gateway/#{gateway_name}" },
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/instrumentation/active_record_prepend'
|
6
6
|
|
@@ -21,8 +21,8 @@ module NewRelic
|
|
21
21
|
def self.insert_instrumentation
|
22
22
|
if defined?(::ActiveRecord::VERSION::MAJOR) && ::ActiveRecord::VERSION::MAJOR.to_i >= 3
|
23
23
|
if ::NewRelic::Agent.config[:prepend_active_record_instrumentation]
|
24
|
-
::ActiveRecord::Base.prepend
|
25
|
-
::ActiveRecord::Relation.prepend
|
24
|
+
::ActiveRecord::Base.prepend(::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions)
|
25
|
+
::ActiveRecord::Relation.prepend(::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions)
|
26
26
|
else
|
27
27
|
::NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_additional_methods
|
28
28
|
end
|
@@ -36,9 +36,9 @@ module NewRelic
|
|
36
36
|
def self.included(instrumented_class)
|
37
37
|
instrumented_class.class_eval do
|
38
38
|
unless instrumented_class.method_defined?(:log_without_newrelic_instrumentation)
|
39
|
-
alias_method
|
40
|
-
alias_method
|
41
|
-
protected
|
39
|
+
alias_method(:log_without_newrelic_instrumentation, :log)
|
40
|
+
alias_method(:log, :log_with_newrelic_instrumentation)
|
41
|
+
protected(:log)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -80,7 +80,7 @@ module NewRelic
|
|
80
80
|
segment._notice_sql(sql, @config, EXPLAINER)
|
81
81
|
|
82
82
|
begin
|
83
|
-
NewRelic::Agent::Tracer.capture_segment_error
|
83
|
+
NewRelic::Agent::Tracer.capture_segment_error(segment) do
|
84
84
|
log_without_newrelic_instrumentation(*args, &block)
|
85
85
|
end
|
86
86
|
ensure
|
@@ -124,7 +124,7 @@ module NewRelic
|
|
124
124
|
segment._notice_sql(sql, @config, EXPLAINER)
|
125
125
|
|
126
126
|
begin
|
127
|
-
NewRelic::Agent::Tracer.capture_segment_error
|
127
|
+
NewRelic::Agent::Tracer.capture_segment_error(segment) do
|
128
128
|
log_without_newrelic_instrumentation(*args, **kwargs, &block)
|
129
129
|
end
|
130
130
|
ensure
|
@@ -151,7 +151,7 @@ DependencyDetection.defer do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
executes do
|
154
|
-
::NewRelic::Agent.logger.info
|
154
|
+
::NewRelic::Agent.logger.info('Installing ActiveRecord instrumentation')
|
155
155
|
end
|
156
156
|
|
157
157
|
executes do
|
@@ -1,8 +1,9 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/datastores/metric_helper'
|
6
|
+
require 'new_relic/constants'
|
6
7
|
|
7
8
|
module NewRelic
|
8
9
|
module Agent
|
@@ -18,7 +19,7 @@ module NewRelic
|
|
18
19
|
|
19
20
|
def instrument_save_methods
|
20
21
|
::ActiveRecord::Base.class_eval do
|
21
|
-
alias_method
|
22
|
+
alias_method(:save_without_newrelic, :save)
|
22
23
|
|
23
24
|
def save(*args, &blk)
|
24
25
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
@@ -26,7 +27,7 @@ module NewRelic
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
alias_method
|
30
|
+
alias_method(:save_without_newrelic!, :save!)
|
30
31
|
|
31
32
|
def save!(*args, &blk)
|
32
33
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
@@ -38,7 +39,7 @@ module NewRelic
|
|
38
39
|
|
39
40
|
def instrument_relation_methods
|
40
41
|
::ActiveRecord::Relation.class_eval do
|
41
|
-
alias_method
|
42
|
+
alias_method(:update_all_without_newrelic, :update_all)
|
42
43
|
|
43
44
|
def update_all(*args, &blk)
|
44
45
|
::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
|
@@ -46,7 +47,7 @@ module NewRelic
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
alias_method
|
50
|
+
alias_method(:delete_all_without_newrelic, :delete_all)
|
50
51
|
|
51
52
|
if RUBY_VERSION < "2.7.0"
|
52
53
|
def delete_all(*args, &blk)
|
@@ -62,7 +63,7 @@ module NewRelic
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
alias_method
|
66
|
+
alias_method(:destroy_all_without_newrelic, :destroy_all)
|
66
67
|
|
67
68
|
def destroy_all(*args, &blk)
|
68
69
|
::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
|
@@ -70,7 +71,7 @@ module NewRelic
|
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
|
-
alias_method
|
74
|
+
alias_method(:calculate_without_newrelic, :calculate)
|
74
75
|
|
75
76
|
def calculate(*args, &blk)
|
76
77
|
::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
|
@@ -79,7 +80,7 @@ module NewRelic
|
|
79
80
|
end
|
80
81
|
|
81
82
|
if method_defined?(:pluck)
|
82
|
-
alias_method
|
83
|
+
alias_method(:pluck_without_newrelic, :pluck)
|
83
84
|
|
84
85
|
def pluck(*args, &blk)
|
85
86
|
::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
|
@@ -93,23 +94,34 @@ module NewRelic
|
|
93
94
|
|
94
95
|
ACTIVE_RECORD = "ActiveRecord".freeze
|
95
96
|
OTHER = "other".freeze
|
97
|
+
MAKARA_SUFFIX = "_makara".freeze
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
+
# convert vendor (makara, etc.) wrapper names to their bare names
|
100
|
+
# ex: postgresql_makara -> postgresql
|
101
|
+
def bare_adapter_name(adapter_name)
|
102
|
+
# TODO: OLD RUBIES - RUBY_VERSION < 2.5
|
103
|
+
# With Ruby 2.5+ we could use #delete_suffix instead of #chomp for a
|
104
|
+
# potential speed boost
|
105
|
+
return adapter_name.chomp(MAKARA_SUFFIX) if adapter_name && adapter_name.end_with?(MAKARA_SUFFIX)
|
106
|
+
|
107
|
+
adapter_name
|
108
|
+
end
|
109
|
+
|
110
|
+
def product_operation_collection_for(name, sql, adapter_name)
|
111
|
+
product = map_product(bare_adapter_name(adapter_name))
|
99
112
|
splits = split_name(name)
|
100
113
|
model = model_from_splits(splits)
|
101
114
|
operation = operation_from_splits(splits, sql)
|
102
|
-
NewRelic::Agent::Datastores::MetricHelper.product_operation_collection_for
|
115
|
+
NewRelic::Agent::Datastores::MetricHelper.product_operation_collection_for(product, operation, model, ACTIVE_RECORD)
|
103
116
|
end
|
104
117
|
|
105
118
|
SPACE = ' '.freeze
|
106
|
-
EMPTY = [].freeze
|
107
119
|
|
108
120
|
def split_name(name)
|
109
121
|
if name && name.respond_to?(:split)
|
110
122
|
name.split(SPACE)
|
111
123
|
else
|
112
|
-
|
124
|
+
NewRelic::EMPTY_ARRAY
|
113
125
|
end
|
114
126
|
end
|
115
127
|
|
@@ -194,8 +206,7 @@ module NewRelic
|
|
194
206
|
ACTIVE_RECORD_DEFAULT_PRODUCT_NAME = "ActiveRecord".freeze
|
195
207
|
|
196
208
|
def map_product(adapter_name)
|
197
|
-
PRODUCT_NAMES.fetch(adapter_name,
|
198
|
-
ACTIVE_RECORD_DEFAULT_PRODUCT_NAME)
|
209
|
+
PRODUCT_NAMES.fetch(adapter_name, ACTIVE_RECORD_DEFAULT_PRODUCT_NAME)
|
199
210
|
end
|
200
211
|
|
201
212
|
module InstanceIdentification
|
@@ -221,11 +232,16 @@ module NewRelic
|
|
221
232
|
SLASH = "/".freeze
|
222
233
|
LOCALHOST = "localhost".freeze
|
223
234
|
|
235
|
+
def adapter_from_config(config)
|
236
|
+
bare_name = NewRelic::Agent::Instrumentation::ActiveRecordHelper.bare_adapter_name(config[:adapter])
|
237
|
+
PRODUCT_SYMBOLS[bare_name]
|
238
|
+
end
|
239
|
+
|
224
240
|
def host(config)
|
225
241
|
return UNKNOWN unless config
|
226
242
|
|
227
243
|
configured_value = config[:host]
|
228
|
-
adapter =
|
244
|
+
adapter = adapter_from_config(config)
|
229
245
|
if configured_value.nil? ||
|
230
246
|
postgres_unix_domain_socket_case?(configured_value, adapter)
|
231
247
|
|
@@ -236,14 +252,14 @@ module NewRelic
|
|
236
252
|
configured_value
|
237
253
|
end
|
238
254
|
rescue => e
|
239
|
-
NewRelic::Agent.logger.debug
|
255
|
+
NewRelic::Agent.logger.debug("Failed to retrieve ActiveRecord host: #{e}")
|
240
256
|
UNKNOWN
|
241
257
|
end
|
242
258
|
|
243
259
|
def port_path_or_id(config)
|
244
260
|
return UNKNOWN unless config
|
245
261
|
|
246
|
-
adapter =
|
262
|
+
adapter = adapter_from_config(config)
|
247
263
|
if config[:socket]
|
248
264
|
config[:socket].empty? ? UNKNOWN : config[:socket]
|
249
265
|
elsif postgres_unix_domain_socket_case?(config[:host], adapter) || mysql_default_case?(config, adapter)
|
@@ -256,14 +272,14 @@ module NewRelic
|
|
256
272
|
UNKNOWN
|
257
273
|
end
|
258
274
|
rescue => e
|
259
|
-
NewRelic::Agent.logger.debug
|
275
|
+
NewRelic::Agent.logger.debug("Failed to retrieve ActiveRecord port_path_or_id: #{e}")
|
260
276
|
UNKNOWN
|
261
277
|
end
|
262
278
|
|
263
279
|
SUPPORTED_ADAPTERS = [:mysql, :postgres].freeze
|
264
280
|
|
265
|
-
def supported_adapter?
|
266
|
-
config && SUPPORTED_ADAPTERS.include?(
|
281
|
+
def supported_adapter?(config)
|
282
|
+
config && SUPPORTED_ADAPTERS.include?(adapter_from_config(config))
|
267
283
|
end
|
268
284
|
|
269
285
|
private
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/instrumentation/active_record_subscriber'
|
6
6
|
require 'new_relic/agent/instrumentation/active_record_prepend'
|
@@ -95,7 +95,7 @@ DependencyDetection.defer do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
executes do
|
98
|
-
::NewRelic::Agent.logger.info
|
98
|
+
::NewRelic::Agent.logger.info('Installing notifications based Active Record instrumentation')
|
99
99
|
end
|
100
100
|
|
101
101
|
executes do
|
@@ -149,7 +149,7 @@ DependencyDetection.defer do
|
|
149
149
|
&& ::ActiveRecord::VERSION::MINOR.to_i == 1 \
|
150
150
|
&& ::ActiveRecord::VERSION::TINY.to_i >= 6
|
151
151
|
|
152
|
-
::ActiveRecord::Base.prepend
|
152
|
+
::ActiveRecord::Base.prepend(::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions516)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
@@ -1,6 +1,7 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
4
5
|
require 'new_relic/agent/instrumentation/active_record_helper'
|
5
6
|
require 'new_relic/agent/instrumentation/notifications_subscriber'
|
6
7
|
|
@@ -79,7 +80,7 @@ module NewRelic
|
|
79
80
|
statement.binds)
|
80
81
|
end
|
81
82
|
rescue => e
|
82
|
-
NewRelic::Agent.logger.debug
|
83
|
+
NewRelic::Agent.logger.debug("Couldn't fetch the explain plan for #{statement} due to #{e}")
|
83
84
|
end
|
84
85
|
|
85
86
|
def active_record_config(payload)
|
@@ -91,21 +92,30 @@ module NewRelic
|
|
91
92
|
end
|
92
93
|
|
93
94
|
return unless connection_id = payload[:connection_id]
|
94
|
-
connection = nil
|
95
95
|
|
96
96
|
::ActiveRecord::Base.connection_handler.connection_pool_list.each do |handler|
|
97
|
-
connection = handler.connections.detect
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
connection = handler.connections.detect { |conn| conn.object_id == connection_id }
|
98
|
+
return connection.instance_variable_get(:@config) if connection
|
99
|
+
|
100
|
+
# when using makara, handler.connections will be empty, so use the
|
101
|
+
# spec config instead.
|
102
|
+
# https://github.com/newrelic/newrelic-ruby-agent/issues/507
|
103
|
+
# thank you @lucasklaassen
|
104
|
+
return handler.spec.config if use_spec_config?(handler)
|
102
105
|
end
|
103
106
|
|
104
|
-
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
def use_spec_config?(handler)
|
111
|
+
handler.respond_to?(:spec) &&
|
112
|
+
handler.spec &&
|
113
|
+
handler.spec.config &&
|
114
|
+
handler.spec.config[:adapter].end_with?('makara')
|
105
115
|
end
|
106
116
|
|
107
117
|
def start_segment(config, payload)
|
108
|
-
sql = Helper.correctly_encoded
|
118
|
+
sql = Helper.correctly_encoded(payload[:sql])
|
109
119
|
product, operation, collection = ActiveRecordHelper.product_operation_collection_for(
|
110
120
|
payload[:name],
|
111
121
|
sql,
|
@@ -129,7 +139,7 @@ module NewRelic
|
|
129
139
|
port_path_or_id: port_path_or_id,
|
130
140
|
database_name: database)
|
131
141
|
|
132
|
-
segment._notice_sql
|
142
|
+
segment._notice_sql(sql, config, @explainer, payload[:binds], payload[:name])
|
133
143
|
segment
|
134
144
|
end
|
135
145
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/instrumentation/active_storage_subscriber'
|
6
6
|
|
@@ -13,7 +13,7 @@ DependencyDetection.defer do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
executes do
|
16
|
-
::NewRelic::Agent.logger.info
|
16
|
+
::NewRelic::Agent.logger.info('Installing ActiveStorage instrumentation')
|
17
17
|
end
|
18
18
|
|
19
19
|
executes do
|
@@ -1,34 +1,35 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
4
5
|
require 'new_relic/agent/instrumentation/notifications_subscriber'
|
5
6
|
|
6
7
|
module NewRelic
|
7
8
|
module Agent
|
8
9
|
module Instrumentation
|
9
10
|
class ActiveStorageSubscriber < NotificationsSubscriber
|
10
|
-
def start
|
11
|
+
def start(name, id, payload)
|
11
12
|
return unless state.is_execution_traced?
|
12
|
-
start_segment
|
13
|
+
start_segment(name, id, payload)
|
13
14
|
rescue => e
|
14
|
-
log_notification_error
|
15
|
+
log_notification_error(e, name, 'start')
|
15
16
|
end
|
16
17
|
|
17
|
-
def finish
|
18
|
+
def finish(name, id, payload)
|
18
19
|
return unless state.is_execution_traced?
|
19
|
-
finish_segment
|
20
|
+
finish_segment(id, payload)
|
20
21
|
rescue => e
|
21
|
-
log_notification_error
|
22
|
+
log_notification_error(e, name, 'finish')
|
22
23
|
end
|
23
24
|
|
24
|
-
def start_segment
|
25
|
-
segment = Tracer.start_segment
|
25
|
+
def start_segment(name, id, payload)
|
26
|
+
segment = Tracer.start_segment(name: metric_name(name, payload))
|
26
27
|
segment.params[:key] = payload[:key]
|
27
|
-
segment.params[:exist] = payload[:exist] if payload.key?
|
28
|
-
push_segment
|
28
|
+
segment.params[:exist] = payload[:exist] if payload.key?(:exist)
|
29
|
+
push_segment(id, segment)
|
29
30
|
end
|
30
31
|
|
31
|
-
def finish_segment
|
32
|
+
def finish_segment(id, payload)
|
32
33
|
if segment = pop_segment(id)
|
33
34
|
if exception = exception_object(payload)
|
34
35
|
segment.notice_error(exception)
|
@@ -37,9 +38,9 @@ module NewRelic
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
def metric_name
|
41
|
+
def metric_name(name, payload)
|
41
42
|
service = payload[:service]
|
42
|
-
method = method_from_name
|
43
|
+
method = method_from_name(name)
|
43
44
|
"Ruby/ActiveStorage/#{service}Service/#{method}"
|
44
45
|
end
|
45
46
|
|
@@ -54,7 +55,7 @@ module NewRelic
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
|
-
def method_from_name
|
58
|
+
def method_from_name(name)
|
58
59
|
METHOD_NAME_MAPPING[name]
|
59
60
|
end
|
60
61
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
module NewRelic::Agent::Instrumentation
|
6
6
|
module ActiveSupportLogger
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
module NewRelic::Agent::Instrumentation
|
6
6
|
module ActiveSupportLogger::Prepend
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require_relative 'active_support_logger/instrumentation'
|
6
6
|
require_relative 'active_support_logger/chain'
|
@@ -12,7 +12,7 @@ DependencyDetection.defer do
|
|
12
12
|
depends_on { defined?(::ActiveSupport::Logger) }
|
13
13
|
|
14
14
|
executes do
|
15
|
-
::NewRelic::Agent.logger.info
|
15
|
+
::NewRelic::Agent.logger.info('Installing ActiveSupport::Logger instrumentation')
|
16
16
|
|
17
17
|
if use_prepend?
|
18
18
|
# the only method currently instrumented is a class method
|