newrelic_rpm 8.15.0 → 9.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.build_ignore +26 -0
- data/CHANGELOG.md +538 -44
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -1
- data/README.md +11 -6
- data/Rakefile +9 -9
- data/Thorfile +1 -1
- data/bin/newrelic +1 -0
- data/bin/newrelic_cmd +1 -0
- data/bin/nrdebug +36 -36
- data/init.rb +1 -1
- data/lib/new_relic/agent/agent.rb +3 -16
- data/lib/new_relic/agent/agent_helpers/connect.rb +5 -10
- data/lib/new_relic/agent/agent_helpers/harvest.rb +4 -4
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +5 -5
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +3 -4
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +47 -39
- data/lib/new_relic/agent/agent_helpers/startup.rb +13 -13
- data/lib/new_relic/agent/agent_helpers/transmit.rb +6 -6
- data/lib/new_relic/agent/agent_logger.rb +9 -9
- data/lib/new_relic/agent/attribute_filter.rb +2 -4
- data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
- data/lib/new_relic/agent/attribute_processing.rb +2 -2
- data/lib/new_relic/agent/audit_logger.rb +5 -5
- data/lib/new_relic/agent/autostart.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command_router.rb +5 -4
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +8 -8
- data/lib/new_relic/agent/configuration/default_source.rb +428 -586
- data/lib/new_relic/agent/configuration/environment_source.rb +2 -2
- data/lib/new_relic/agent/configuration/high_security_source.rb +3 -5
- data/lib/new_relic/agent/configuration/manager.rb +16 -2
- data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -26
- data/lib/new_relic/agent/configuration/server_source.rb +24 -24
- data/lib/new_relic/agent/configuration/yaml_source.rb +17 -4
- data/lib/new_relic/agent/connect/request_builder.rb +1 -1
- data/lib/new_relic/agent/connect/response_handler.rb +1 -1
- data/lib/new_relic/agent/custom_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +2 -2
- data/lib/new_relic/agent/database/obfuscator.rb +2 -2
- data/lib/new_relic/agent/database.rb +4 -18
- data/lib/new_relic/agent/datastores/metric_helper.rb +5 -5
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -11
- data/lib/new_relic/agent/datastores/redis.rb +6 -6
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +8 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +6 -6
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +4 -4
- data/lib/new_relic/agent/distributed_tracing.rb +6 -6
- data/lib/new_relic/agent/error_collector.rb +36 -8
- data/lib/new_relic/agent/error_filter.rb +5 -5
- data/lib/new_relic/agent/error_trace_aggregator.rb +5 -4
- data/lib/new_relic/agent/event_loop.rb +3 -3
- data/lib/new_relic/agent/external.rb +1 -1
- data/lib/new_relic/agent/harvester.rb +1 -3
- data/lib/new_relic/agent/heap.rb +2 -1
- data/lib/new_relic/agent/hostname.rb +1 -1
- data/lib/new_relic/agent/http_clients/abstract.rb +9 -21
- data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +83 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +7 -3
- data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +111 -0
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +7 -5
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +4 -0
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +6 -2
- data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +93 -0
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +8 -5
- data/lib/new_relic/agent/http_clients/uri_util.rb +2 -2
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +6 -19
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +42 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +3 -2
- data/lib/new_relic/agent/instrumentation/action_dispatch.rb +31 -0
- data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +64 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox_subscriber.rb +33 -0
- data/lib/new_relic/agent/instrumentation/action_mailer.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb +85 -0
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +10 -10
- data/lib/new_relic/agent/instrumentation/active_job.rb +16 -3
- data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record.rb +4 -3
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +38 -36
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +5 -4
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +3 -2
- data/lib/new_relic/agent/instrumentation/active_storage.rb +4 -0
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -30
- data/lib/new_relic/agent/instrumentation/active_support.rb +21 -6
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
- data/lib/new_relic/agent/instrumentation/active_support_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
- data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +12 -3
- data/lib/new_relic/agent/instrumentation/bunny.rb +1 -1
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +3 -4
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +7 -6
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +9 -5
- data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
- data/lib/new_relic/agent/instrumentation/custom_events.rb +12 -0
- data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +2 -1
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +4 -1
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -1
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +8 -4
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +2 -2
- data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
- data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
- data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +5 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +27 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +23 -0
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +25 -0
- data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +8 -4
- data/lib/new_relic/agent/instrumentation/grape.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +7 -2
- data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +8 -4
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +2 -2
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
- data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +3 -1
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +14 -5
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +3 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +12 -12
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +3 -3
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +6 -8
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/net_http.rb +2 -2
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +46 -1
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +7 -3
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +7 -2
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +14 -1
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +12 -15
- data/lib/new_relic/agent/instrumentation/rake.rb +3 -3
- data/lib/new_relic/agent/instrumentation/redis/constants.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +6 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
- data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
- data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
- data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +68 -0
- data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +29 -0
- data/lib/new_relic/agent/instrumentation/roda.rb +36 -0
- data/lib/new_relic/agent/instrumentation/sequel.rb +8 -9
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +10 -10
- data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -3
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +10 -5
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +2 -4
- data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
- data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -8
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +6 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +10 -6
- data/lib/new_relic/agent/javascript_instrumentor.rb +29 -24
- data/lib/new_relic/agent/linking_metadata.rb +2 -2
- data/lib/new_relic/agent/log_event_aggregator.rb +64 -17
- data/lib/new_relic/agent/log_event_attributes.rb +115 -0
- data/lib/new_relic/agent/logging.rb +77 -37
- data/lib/new_relic/agent/messaging.rb +9 -7
- data/lib/new_relic/agent/method_tracer.rb +7 -7
- data/lib/new_relic/agent/method_tracer_helpers.rb +27 -6
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -5
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +1 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
- data/lib/new_relic/agent/new_relic_service/encoders.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
- data/lib/new_relic/agent/new_relic_service.rb +47 -32
- data/lib/new_relic/agent/obfuscator.rb +1 -1
- data/lib/new_relic/agent/parameter_filtering.rb +6 -6
- data/lib/new_relic/agent/pipe_channel_manager.rb +7 -6
- data/lib/new_relic/agent/pipe_service.rb +5 -3
- data/lib/new_relic/agent/priority_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
- data/lib/new_relic/agent/rules_engine.rb +1 -1
- data/lib/new_relic/agent/sampler.rb +2 -1
- data/lib/new_relic/agent/sampler_collection.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +5 -5
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +9 -9
- data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -9
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/span_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/span_event_primitive.rb +18 -6
- data/lib/new_relic/agent/sql_sampler.rb +2 -2
- data/lib/new_relic/agent/stats.rb +1 -1
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/system_info.rb +36 -10
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
- data/lib/new_relic/agent/threading/backtrace_node.rb +3 -3
- data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
- data/lib/new_relic/agent/threading/thread_profile.rb +5 -5
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +25 -16
- data/lib/new_relic/agent/transaction/abstract_segment.rb +109 -48
- data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -6
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +13 -14
- data/lib/new_relic/agent/transaction/external_request_segment.rb +16 -13
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +2 -3
- data/lib/new_relic/agent/transaction/request_attributes.rb +47 -11
- data/lib/new_relic/agent/transaction/segment.rb +1 -1
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/trace.rb +1 -1
- data/lib/new_relic/agent/transaction/trace_context.rb +4 -4
- data/lib/new_relic/agent/transaction/trace_node.rb +8 -7
- data/lib/new_relic/agent/transaction/tracing.rb +10 -4
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +90 -58
- data/lib/new_relic/agent/transaction_error_primitive.rb +21 -5
- data/lib/new_relic/agent/transaction_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/transaction_event_primitive.rb +22 -3
- data/lib/new_relic/agent/transaction_sampler.rb +3 -3
- data/lib/new_relic/agent/transaction_time_aggregator.rb +7 -3
- data/lib/new_relic/agent/utilization/aws.rb +1 -1
- data/lib/new_relic/agent/utilization/azure.rb +3 -3
- data/lib/new_relic/agent/utilization/gcp.rb +4 -6
- data/lib/new_relic/agent/utilization/pcf.rb +1 -1
- data/lib/new_relic/agent/utilization/vendor.rb +6 -8
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +9 -8
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +133 -36
- data/lib/new_relic/cli/command.rb +4 -3
- data/lib/new_relic/cli/commands/deployments.rb +26 -25
- data/lib/new_relic/cli/commands/install.rb +23 -23
- data/lib/new_relic/collection_helper.rb +2 -2
- data/lib/new_relic/constants.rb +10 -8
- data/lib/new_relic/control/class_methods.rb +4 -10
- data/lib/new_relic/control/frameworks/rails.rb +44 -20
- data/lib/new_relic/control/frameworks/roda.rb +20 -0
- data/lib/new_relic/control/instance_methods.rb +6 -6
- data/lib/new_relic/control/instrumentation.rb +1 -15
- data/lib/new_relic/control/private_instance_methods.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +20 -18
- data/lib/new_relic/environment_report.rb +4 -4
- data/lib/new_relic/helper.rb +2 -1
- data/lib/new_relic/language_support.rb +10 -1
- data/lib/new_relic/latest_changes.rb +6 -6
- data/lib/new_relic/local_environment.rb +0 -10
- data/lib/new_relic/noticed_error.rb +25 -20
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +0 -16
- data/lib/new_relic/rack/browser_monitoring.rb +21 -17
- data/lib/new_relic/recipes/capistrano3.rb +1 -1
- data/lib/new_relic/recipes/capistrano_legacy.rb +6 -6
- data/lib/new_relic/recipes/helpers/send_deployment.rb +5 -5
- data/lib/new_relic/supportability_helper.rb +4 -1
- data/lib/new_relic/traced_thread.rb +2 -3
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +4 -4
- data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +6 -6
- data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +4 -4
- data/lib/tasks/bump_version.rake +21 -0
- data/lib/tasks/config.rake +13 -12
- data/lib/tasks/coverage_report.rake +4 -4
- data/lib/tasks/helpers/config.html.erb +93 -0
- data/lib/tasks/helpers/format.rb +19 -15
- data/lib/tasks/helpers/newrelicyml.rb +144 -0
- data/lib/tasks/helpers/version_bump.rb +62 -0
- data/lib/tasks/install.rake +4 -4
- data/lib/tasks/instrumentation_generator/instrumentation.thor +16 -19
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/chain.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +1 -1
- data/lib/tasks/newrelic.rb +1 -0
- data/lib/tasks/newrelicyml.rake +13 -0
- data/lib/tasks/tests.rake +77 -6
- data/newrelic.yml +393 -274
- data/newrelic_rpm.gemspec +41 -30
- data/test/agent_helper.rb +25 -24
- metadata +172 -35
- data/.gitignore +0 -42
- data/.project +0 -23
- data/.rubocop.yml +0 -1946
- data/.rubocop_todo.yml +0 -62
- data/.simplecov +0 -15
- data/.snyk +0 -11
- data/.yardopts +0 -27
- data/Brewfile +0 -12
- data/DOCKER.md +0 -167
- data/Dockerfile +0 -10
- data/Guardfile +0 -26
- data/config/database.yml +0 -5
- data/config.dot +0 -278
- data/docker-compose.yml +0 -107
- data/lefthook.yml +0 -9
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
- data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
- data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
- data/lib/new_relic/agent/range_extensions.rb +0 -27
- data/lib/tasks/helpers/removers.rb +0 -33
- data/lib/tasks/multiverse.rake +0 -6
- data/lib/tasks/multiverse.rb +0 -77
@@ -0,0 +1,85 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'new_relic/agent/instrumentation/notifications_subscriber'
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
module Agent
|
9
|
+
module Instrumentation
|
10
|
+
# NOTE: as of v7.1.0.0.alpha, deliver.action_mailer will provide
|
11
|
+
# an empty payload hash ({}) to #start, so in this subscriber class
|
12
|
+
# we defer params population until #finish and start the segment with
|
13
|
+
# a temporary name that is later replaced
|
14
|
+
class ActionMailerSubscriber < NotificationsSubscriber
|
15
|
+
BASE_NAME = 'Ruby/ActionMailer'
|
16
|
+
PAYLOAD_KEYS = %i[action data key mailer message_id perform_deliveries subject]
|
17
|
+
PATTERN = /\A([^\.]+)\.action_mailer\z/
|
18
|
+
UNKNOWN_MAILER = %r{^#{BASE_NAME}/#{UNKNOWN}/}
|
19
|
+
|
20
|
+
METHOD_NAME_MAPPING = Hash.new do |h, k|
|
21
|
+
if PATTERN =~ k
|
22
|
+
h[k] = $1
|
23
|
+
else
|
24
|
+
h[k] = NewRelic::UNKNOWN
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def start(name, id, payload)
|
29
|
+
return unless state.is_execution_traced?
|
30
|
+
|
31
|
+
start_segment(name, id, payload)
|
32
|
+
rescue => e
|
33
|
+
log_notification_error(e, name, 'start')
|
34
|
+
end
|
35
|
+
|
36
|
+
def finish(name, id, payload)
|
37
|
+
return unless state.is_execution_traced?
|
38
|
+
|
39
|
+
finish_segment(id, payload)
|
40
|
+
rescue => e
|
41
|
+
log_notification_error(e, name, 'finish')
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def start_segment(name, id, payload)
|
47
|
+
segment = Tracer.start_segment(name: metric_name(name, payload))
|
48
|
+
push_segment(id, segment)
|
49
|
+
end
|
50
|
+
|
51
|
+
def finish_segment(id, payload)
|
52
|
+
segment = pop_segment(id)
|
53
|
+
return unless segment
|
54
|
+
|
55
|
+
if segment.name.match?(UNKNOWN_MAILER) && payload.key?(:mailer)
|
56
|
+
segment.name = segment.name.sub(UNKNOWN_MAILER, "#{BASE_NAME}/#{payload[:mailer]}/")
|
57
|
+
end
|
58
|
+
|
59
|
+
PAYLOAD_KEYS.each do |key|
|
60
|
+
segment.params[key] = payload[key] if payload.key?(key)
|
61
|
+
end
|
62
|
+
|
63
|
+
notice_exception(segment, payload)
|
64
|
+
segment.finish
|
65
|
+
end
|
66
|
+
|
67
|
+
def notice_exception(segment, payload)
|
68
|
+
if exception = exception_object(payload)
|
69
|
+
segment.notice_error(exception)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def metric_name(name, payload)
|
74
|
+
mailer = payload[:mailer] || UNKNOWN
|
75
|
+
method = method_from_name(name)
|
76
|
+
"#{BASE_NAME}/#{mailer}/#{method}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def method_from_name(name)
|
80
|
+
METHOD_NAME_MAPPING[name]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -10,28 +10,25 @@ module NewRelic
|
|
10
10
|
module Agent
|
11
11
|
module Instrumentation
|
12
12
|
class ActionViewSubscriber < NotificationsSubscriber
|
13
|
-
def
|
13
|
+
def start_segment(name, id, payload)
|
14
14
|
parent = segment_stack[id].last
|
15
15
|
metric_name = format_metric_name(name, payload, parent)
|
16
16
|
|
17
17
|
event = ActionViewEvent.new(metric_name, payload[:identifier])
|
18
|
-
|
18
|
+
|
19
|
+
if recordable?(name, metric_name)
|
19
20
|
event.finishable = Tracer.start_segment(name: metric_name)
|
20
21
|
end
|
21
22
|
push_segment(id, event)
|
22
|
-
rescue => e
|
23
|
-
log_notification_error(e, name, 'start')
|
24
23
|
end
|
25
24
|
|
26
|
-
def
|
25
|
+
def finish_segment(id, payload)
|
27
26
|
if segment = pop_segment(id)
|
28
27
|
if exception = exception_object(payload)
|
29
28
|
segment.notice_error(exception)
|
30
29
|
end
|
31
30
|
segment.finish
|
32
31
|
end
|
33
|
-
rescue => e
|
34
|
-
log_notification_error(e, name, 'finish')
|
35
32
|
end
|
36
33
|
|
37
34
|
def format_metric_name(event_name, payload, parent)
|
@@ -61,12 +58,15 @@ module NewRelic
|
|
61
58
|
RENDER_TEMPLATE_EVENT_NAME = 'render_template.action_view'.freeze
|
62
59
|
RENDER_PARTIAL_EVENT_NAME = 'render_partial.action_view'.freeze
|
63
60
|
RENDER_COLLECTION_EVENT_NAME = 'render_collection.action_view'.freeze
|
61
|
+
RENDER_LAYOUT_EVENT_NAME = 'render_layout.action_view'.freeze
|
64
62
|
|
65
63
|
def metric_action(name)
|
66
64
|
case name
|
67
65
|
when /#{RENDER_TEMPLATE_EVENT_NAME}$/o then 'Rendering'
|
68
66
|
when RENDER_PARTIAL_EVENT_NAME then 'Partial'
|
69
67
|
when RENDER_COLLECTION_EVENT_NAME then 'Partial'
|
68
|
+
when RENDER_LAYOUT_EVENT_NAME then 'Layout'
|
69
|
+
else NewRelic::UNKNOWN
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -75,7 +75,7 @@ module NewRelic
|
|
75
75
|
# so do not mistake rendering a collection for rendering a file.
|
76
76
|
if identifier.nil? && name != RENDER_COLLECTION_EVENT_NAME
|
77
77
|
'file'
|
78
|
-
elsif
|
78
|
+
elsif /template$/.match?(identifier)
|
79
79
|
identifier
|
80
80
|
elsif identifier && (parts = identifier.split('/')).size > 1
|
81
81
|
parts[-2..-1].join('/')
|
@@ -99,11 +99,11 @@ module NewRelic
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def finish
|
102
|
-
@finishable
|
102
|
+
@finishable&.finish
|
103
103
|
end
|
104
104
|
|
105
105
|
def notice_error(error)
|
106
|
-
@finishable
|
106
|
+
@finishable&.notice_error(error)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
@@ -12,7 +12,7 @@ DependencyDetection.defer do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
executes do
|
15
|
-
NewRelic::Agent.logger.info('Installing ActiveJob instrumentation')
|
15
|
+
NewRelic::Agent.logger.info('Installing base ActiveJob instrumentation')
|
16
16
|
|
17
17
|
ActiveSupport.on_load(:active_job) do
|
18
18
|
ActiveJob::Base.around_enqueue do |job, block|
|
@@ -26,6 +26,19 @@ DependencyDetection.defer do
|
|
26
26
|
NewRelic::Agent::PrependSupportability.record_metrics_for(ActiveJob::Base)
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
executes do
|
31
|
+
if defined?(ActiveSupport) &&
|
32
|
+
ActiveJob.respond_to?(:gem_version) &&
|
33
|
+
ActiveJob.gem_version >= Gem::Version.new('6.0.0') &&
|
34
|
+
!NewRelic::Agent.config[:disable_activejob] &&
|
35
|
+
!NewRelic::Agent::Instrumentation::ActiveJobSubscriber.subscribed?
|
36
|
+
NewRelic::Agent.logger.info('Installing notifications based ActiveJob instrumentation')
|
37
|
+
|
38
|
+
ActiveSupport::Notifications.subscribe(/\A[^\.]+\.active_job\z/,
|
39
|
+
NewRelic::Agent::Instrumentation::ActiveJobSubscriber.new)
|
40
|
+
end
|
41
|
+
end
|
29
42
|
end
|
30
43
|
|
31
44
|
module NewRelic
|
@@ -44,7 +57,7 @@ module NewRelic
|
|
44
57
|
|
45
58
|
# Don't nest transactions if we're already in a web transaction.
|
46
59
|
# Probably inline processing the job if that happens, so just trace.
|
47
|
-
if txn
|
60
|
+
if txn&.recording_web_transaction?
|
48
61
|
run_in_trace(job, block, :Consume)
|
49
62
|
elsif txn && !txn.recording_web_transaction?
|
50
63
|
::NewRelic::Agent::Transaction.set_default_transaction_name(
|
@@ -58,7 +71,7 @@ module NewRelic
|
|
58
71
|
end
|
59
72
|
|
60
73
|
def self.run_in_trace(job, block, event)
|
61
|
-
trace_execution_scoped("
|
74
|
+
trace_execution_scoped("ActiveJob/#{adapter.sub(/^ActiveJob::/, '')}/Queue/#{event}/Named/#{job.queue_name}",
|
62
75
|
code_information: code_information_for_job(job)) do
|
63
76
|
block.call
|
64
77
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'new_relic/agent/instrumentation/notifications_subscriber'
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
module Agent
|
9
|
+
module Instrumentation
|
10
|
+
class ActiveJobSubscriber < NotificationsSubscriber
|
11
|
+
PAYLOAD_KEYS = %i[adapter db_runtime error job wait]
|
12
|
+
|
13
|
+
def add_segment_params(segment, payload)
|
14
|
+
PAYLOAD_KEYS.each do |key|
|
15
|
+
segment.params[key] = payload[key] if payload.key?(key)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def metric_name(name, payload)
|
20
|
+
queue = payload[:job].queue_name
|
21
|
+
method = method_from_name(name)
|
22
|
+
"Ruby/ActiveJob/#{queue}/#{method}"
|
23
|
+
end
|
24
|
+
|
25
|
+
PATTERN = /\A([^\.]+)\.active_job\z/
|
26
|
+
|
27
|
+
METHOD_NAME_MAPPING = Hash.new do |h, k|
|
28
|
+
if PATTERN =~ k
|
29
|
+
h[k] = $1
|
30
|
+
else
|
31
|
+
h[k] = NewRelic::UNKNOWN
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def method_from_name(name)
|
36
|
+
METHOD_NAME_MAPPING[name]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -27,9 +27,9 @@ DependencyDetection.defer do
|
|
27
27
|
actions = [:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update]
|
28
28
|
actions.each do |operation|
|
29
29
|
if implemented_methods.include?(operation)
|
30
|
-
add_method_tracer operation, [->
|
31
|
-
->
|
32
|
-
->
|
30
|
+
add_method_tracer operation, [->(*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
|
31
|
+
->(*) { "ActiveMerchant/gateway/#{gateway_name}" },
|
32
|
+
->(*) { "ActiveMerchant/operation/#{operation}" }]
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -13,7 +13,8 @@ module NewRelic
|
|
13
13
|
::ActiveRecord::Base.send("#{statement.config[:adapter]}_connection",
|
14
14
|
statement.config)
|
15
15
|
end
|
16
|
-
|
16
|
+
# the following line needs else branch coverage
|
17
|
+
if connection && connection.respond_to?(:execute) # rubocop:disable Style/SafeNavigation
|
17
18
|
return connection.execute("EXPLAIN #{statement.sql}")
|
18
19
|
end
|
19
20
|
end
|
@@ -43,7 +44,7 @@ module NewRelic
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
if RUBY_VERSION <
|
47
|
+
if RUBY_VERSION < '2.7.0'
|
47
48
|
def log_with_newrelic_instrumentation(*args, &block)
|
48
49
|
state = NewRelic::Agent::Tracer.state
|
49
50
|
|
@@ -147,7 +148,7 @@ DependencyDetection.defer do
|
|
147
148
|
end
|
148
149
|
|
149
150
|
depends_on do
|
150
|
-
!NewRelic::Agent.config[:
|
151
|
+
!NewRelic::Agent.config[:disable_active_record_instrumentation]
|
151
152
|
end
|
152
153
|
|
153
154
|
executes do
|
@@ -49,7 +49,7 @@ module NewRelic
|
|
49
49
|
|
50
50
|
alias_method(:delete_all_without_newrelic, :delete_all)
|
51
51
|
|
52
|
-
if RUBY_VERSION <
|
52
|
+
if RUBY_VERSION < '2.7.0'
|
53
53
|
def delete_all(*args, &blk)
|
54
54
|
::NewRelic::Agent.with_database_metric_name(self.name, nil, ACTIVE_RECORD) do
|
55
55
|
delete_all_without_newrelic(*args, &blk)
|
@@ -92,9 +92,9 @@ module NewRelic
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
ACTIVE_RECORD =
|
96
|
-
OTHER =
|
97
|
-
MAKARA_SUFFIX =
|
95
|
+
ACTIVE_RECORD = 'ActiveRecord'.freeze
|
96
|
+
OTHER = 'other'.freeze
|
97
|
+
MAKARA_SUFFIX = '_makara'.freeze
|
98
98
|
|
99
99
|
# convert vendor (makara, etc.) wrapper names to their bare names
|
100
100
|
# ex: postgresql_makara -> postgresql
|
@@ -102,7 +102,7 @@ module NewRelic
|
|
102
102
|
# TODO: OLD RUBIES - RUBY_VERSION < 2.5
|
103
103
|
# With Ruby 2.5+ we could use #delete_suffix instead of #chomp for a
|
104
104
|
# potential speed boost
|
105
|
-
return adapter_name.chomp(MAKARA_SUFFIX) if adapter_name
|
105
|
+
return adapter_name.chomp(MAKARA_SUFFIX) if adapter_name&.end_with?(MAKARA_SUFFIX)
|
106
106
|
|
107
107
|
adapter_name
|
108
108
|
end
|
@@ -118,7 +118,7 @@ module NewRelic
|
|
118
118
|
SPACE = ' '.freeze
|
119
119
|
|
120
120
|
def split_name(name)
|
121
|
-
if name
|
121
|
+
if name&.respond_to?(:split)
|
122
122
|
name.split(SPACE)
|
123
123
|
else
|
124
124
|
NewRelic::EMPTY_ARRAY
|
@@ -163,47 +163,50 @@ module NewRelic
|
|
163
163
|
end
|
164
164
|
|
165
165
|
PRODUCT_NAMES = {
|
166
|
-
|
167
|
-
|
166
|
+
'mysql' => 'MySQL',
|
167
|
+
'mysql2' => 'MySQL',
|
168
168
|
|
169
|
-
|
169
|
+
'postgresql' => 'Postgres',
|
170
170
|
|
171
|
-
|
171
|
+
'sqlite3' => 'SQLite',
|
172
172
|
|
173
173
|
# https://rubygems.org/gems/activerecord-jdbcpostgresql-adapter
|
174
|
-
|
174
|
+
'jdbcmysql' => 'MySQL',
|
175
175
|
|
176
176
|
# https://rubygems.org/gems/activerecord-jdbcpostgresql-adapter
|
177
|
-
|
177
|
+
'jdbcpostgresql' => 'Postgres',
|
178
178
|
|
179
179
|
# https://rubygems.org/gems/activerecord-postgis-adapter
|
180
|
-
|
180
|
+
'postgis' => 'Postgres',
|
181
181
|
|
182
182
|
# https://rubygems.org/gems/activerecord-jdbcsqlite3-adapter
|
183
|
-
|
183
|
+
'jdbcsqlite3' => 'SQLite',
|
184
184
|
|
185
185
|
# https://rubygems.org/gems/activerecord-jdbcderby-adapter
|
186
|
-
|
187
|
-
|
186
|
+
'derby' => 'Derby',
|
187
|
+
'jdbcderby' => 'Derby',
|
188
188
|
|
189
189
|
# https://rubygems.org/gems/activerecord-jdbc-adapter
|
190
|
-
|
190
|
+
'jdbc' => 'JDBC',
|
191
191
|
|
192
192
|
# https://rubygems.org/gems/activerecord-jdbcmssql-adapter
|
193
|
-
|
194
|
-
|
193
|
+
'jdbcmssql' => 'MSSQL',
|
194
|
+
'mssql' => 'MSSQL',
|
195
195
|
|
196
196
|
# https://rubygems.org/gems/activerecord-sqlserver-adapter
|
197
|
-
|
197
|
+
'sqlserver' => 'MSSQL',
|
198
198
|
|
199
199
|
# https://rubygems.org/gems/activerecord-odbc-adapter
|
200
|
-
|
200
|
+
'odbc' => 'ODBC',
|
201
201
|
|
202
202
|
# https://rubygems.org/gems/activerecord-oracle_enhanced-adapter
|
203
|
-
|
203
|
+
'oracle_enhanced' => 'Oracle',
|
204
|
+
|
205
|
+
# https://rubygems.org/gems/activerecord-amazon-timestream-adapter
|
206
|
+
'amazon_timestream' => 'Timestream'
|
204
207
|
}.freeze
|
205
208
|
|
206
|
-
ACTIVE_RECORD_DEFAULT_PRODUCT_NAME =
|
209
|
+
ACTIVE_RECORD_DEFAULT_PRODUCT_NAME = 'ActiveRecord'.freeze
|
207
210
|
|
208
211
|
def map_product(adapter_name)
|
209
212
|
PRODUCT_NAMES.fetch(adapter_name, ACTIVE_RECORD_DEFAULT_PRODUCT_NAME)
|
@@ -213,24 +216,23 @@ module NewRelic
|
|
213
216
|
extend self
|
214
217
|
|
215
218
|
PRODUCT_SYMBOLS = {
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
+
'mysql' => :mysql,
|
220
|
+
'mysql2' => :mysql,
|
221
|
+
'jdbcmysql' => :mysql,
|
219
222
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
+
'postgresql' => :postgres,
|
224
|
+
'jdbcpostgresql' => :postgres,
|
225
|
+
'postgis' => :postgres
|
223
226
|
}.freeze
|
224
227
|
|
225
228
|
DATASTORE_DEFAULT_PORTS = {
|
226
|
-
:mysql =>
|
227
|
-
:postgres =>
|
229
|
+
:mysql => '3306',
|
230
|
+
:postgres => '5432'
|
228
231
|
}.freeze
|
229
232
|
|
230
|
-
DEFAULT =
|
231
|
-
UNKNOWN =
|
232
|
-
|
233
|
-
LOCALHOST = "localhost".freeze
|
233
|
+
DEFAULT = 'default'.freeze
|
234
|
+
UNKNOWN = 'unknown'.freeze
|
235
|
+
LOCALHOST = 'localhost'.freeze
|
234
236
|
|
235
237
|
def adapter_from_config(config)
|
236
238
|
bare_name = NewRelic::Agent::Instrumentation::ActiveRecordHelper.bare_adapter_name(config[:adapter])
|
@@ -285,7 +287,7 @@ module NewRelic
|
|
285
287
|
private
|
286
288
|
|
287
289
|
def postgres_unix_domain_socket_case?(host, adapter)
|
288
|
-
adapter == :postgres && host && host.start_with?(SLASH)
|
290
|
+
adapter == :postgres && host && host.start_with?(NewRelic::SLASH)
|
289
291
|
end
|
290
292
|
|
291
293
|
def mysql_default_case?(config, adapter)
|
@@ -16,7 +16,7 @@ module NewRelic
|
|
16
16
|
|
17
17
|
module BaseExtensions4x
|
18
18
|
# https://github.com/rails/rails/blob/4-1-stable/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L371
|
19
|
-
def log(sql, name =
|
19
|
+
def log(sql, name = 'SQL', binds = [], statement_name = nil)
|
20
20
|
@instrumenter.instrument(
|
21
21
|
SQL_ACTIVE_RECORD,
|
22
22
|
:sql => sql,
|
@@ -38,7 +38,7 @@ module NewRelic
|
|
38
38
|
|
39
39
|
module BaseExtensions50
|
40
40
|
# https://github.com/rails/rails/blob/5-0-stable/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L582
|
41
|
-
def log(sql, name =
|
41
|
+
def log(sql, name = 'SQL', binds = [], type_casted_binds = [], statement_name = nil)
|
42
42
|
@instrumenter.instrument(
|
43
43
|
SQL_ACTIVE_RECORD,
|
44
44
|
sql: sql,
|
@@ -56,7 +56,7 @@ module NewRelic
|
|
56
56
|
|
57
57
|
module BaseExtensions51
|
58
58
|
# https://github.com/rails/rails/blob/5-1-stable/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L603
|
59
|
-
def log(sql, name =
|
59
|
+
def log(sql, name = 'SQL', binds = [], type_casted_binds = [], statement_name = nil) # :doc:
|
60
60
|
@instrumenter.instrument(
|
61
61
|
SQL_ACTIVE_RECORD,
|
62
62
|
sql: sql,
|
@@ -90,7 +90,8 @@ DependencyDetection.defer do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
depends_on do
|
93
|
-
!NewRelic::Agent.config[:
|
93
|
+
!NewRelic::Agent.config[:disable_active_record_instrumentation] &&
|
94
|
+
!NewRelic::Agent.config[:disable_active_record_notifications] &&
|
94
95
|
!NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.subscribed?
|
95
96
|
end
|
96
97
|
|
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
ACTIVE_RECORD = 'ActiveRecord'.freeze
|
12
12
|
|
13
13
|
module BaseExtensions
|
14
|
-
if RUBY_VERSION <
|
14
|
+
if RUBY_VERSION < '2.7.0'
|
15
15
|
def save(*args, &blk)
|
16
16
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
17
17
|
super
|
@@ -46,7 +46,7 @@ module NewRelic
|
|
46
46
|
# Starting in v5.1.6, this call no longer happens. We'll
|
47
47
|
# have to set the database metrics explicitly now.
|
48
48
|
#
|
49
|
-
if RUBY_VERSION <
|
49
|
+
if RUBY_VERSION < '2.7.0'
|
50
50
|
def touch(*args, **kwargs, &blk)
|
51
51
|
::NewRelic::Agent.with_database_metric_name(self.class.name, nil, ACTIVE_RECORD) do
|
52
52
|
super
|
@@ -33,7 +33,7 @@ module NewRelic
|
|
33
33
|
# defensive.
|
34
34
|
return if defined?(cached?)
|
35
35
|
|
36
|
-
if defined?(::ActiveRecord) && ::ActiveRecord::VERSION::STRING >=
|
36
|
+
if defined?(::ActiveRecord) && ::ActiveRecord::VERSION::STRING >= '5.1.0'
|
37
37
|
def cached?(payload)
|
38
38
|
payload.fetch(:cached, false)
|
39
39
|
end
|
@@ -74,7 +74,8 @@ module NewRelic
|
|
74
74
|
::ActiveRecord::Base.send("#{statement.config[:adapter]}_connection",
|
75
75
|
statement.config)
|
76
76
|
end
|
77
|
-
|
77
|
+
# the following line needs else branch coverage
|
78
|
+
if connection && connection.respond_to?(:exec_query) # rubocop:disable Style/SafeNavigation
|
78
79
|
return connection.exec_query("EXPLAIN #{statement.sql}",
|
79
80
|
"Explain #{statement.name}",
|
80
81
|
statement.binds)
|
@@ -7,6 +7,10 @@ require 'new_relic/agent/instrumentation/active_storage_subscriber'
|
|
7
7
|
DependencyDetection.defer do
|
8
8
|
named :active_storage
|
9
9
|
|
10
|
+
depends_on do
|
11
|
+
!NewRelic::Agent.config[:disable_active_storage]
|
12
|
+
end
|
13
|
+
|
10
14
|
depends_on do
|
11
15
|
defined?(ActiveStorage) &&
|
12
16
|
!NewRelic::Agent::Instrumentation::ActiveStorageSubscriber.subscribed?
|
@@ -8,36 +8,9 @@ module NewRelic
|
|
8
8
|
module Agent
|
9
9
|
module Instrumentation
|
10
10
|
class ActiveStorageSubscriber < NotificationsSubscriber
|
11
|
-
def
|
12
|
-
return unless state.is_execution_traced?
|
13
|
-
|
14
|
-
start_segment(name, id, payload)
|
15
|
-
rescue => e
|
16
|
-
log_notification_error(e, name, 'start')
|
17
|
-
end
|
18
|
-
|
19
|
-
def finish(name, id, payload)
|
20
|
-
return unless state.is_execution_traced?
|
21
|
-
|
22
|
-
finish_segment(id, payload)
|
23
|
-
rescue => e
|
24
|
-
log_notification_error(e, name, 'finish')
|
25
|
-
end
|
26
|
-
|
27
|
-
def start_segment(name, id, payload)
|
28
|
-
segment = Tracer.start_segment(name: metric_name(name, payload))
|
11
|
+
def add_segment_params(segment, payload)
|
29
12
|
segment.params[:key] = payload[:key]
|
30
13
|
segment.params[:exist] = payload[:exist] if payload.key?(:exist)
|
31
|
-
push_segment(id, segment)
|
32
|
-
end
|
33
|
-
|
34
|
-
def finish_segment(id, payload)
|
35
|
-
if segment = pop_segment(id)
|
36
|
-
if exception = exception_object(payload)
|
37
|
-
segment.notice_error(exception)
|
38
|
-
end
|
39
|
-
segment.finish
|
40
|
-
end
|
41
14
|
end
|
42
15
|
|
43
16
|
def metric_name(name, payload)
|
@@ -47,13 +20,12 @@ module NewRelic
|
|
47
20
|
end
|
48
21
|
|
49
22
|
PATTERN = /\Aservice_([^\.]*)\.active_storage\z/
|
50
|
-
UNKNOWN = "unknown".freeze
|
51
23
|
|
52
24
|
METHOD_NAME_MAPPING = Hash.new do |h, k|
|
53
25
|
if PATTERN =~ k
|
54
26
|
h[k] = $1
|
55
27
|
else
|
56
|
-
h[k] = UNKNOWN
|
28
|
+
h[k] = NewRelic::UNKNOWN
|
57
29
|
end
|
58
30
|
end
|
59
31
|
|
@@ -2,11 +2,26 @@
|
|
2
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
3
|
# frozen_string_literal: true
|
4
4
|
|
5
|
-
|
6
|
-
# to still leverage all ActiveSupport based instrumentation functionality
|
7
|
-
# offered by the agent that would otherwise be gated by the detection of Rails.
|
5
|
+
require 'new_relic/agent/instrumentation/active_support_subscriber'
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
DependencyDetection.defer do
|
8
|
+
named :active_support
|
9
|
+
|
10
|
+
depends_on do
|
11
|
+
!NewRelic::Agent.config[:disable_active_support]
|
12
|
+
end
|
13
|
+
|
14
|
+
depends_on do
|
15
|
+
defined?(ActiveSupport) &&
|
16
|
+
!NewRelic::Agent::Instrumentation::ActiveSupportSubscriber.subscribed?
|
17
|
+
end
|
18
|
+
|
19
|
+
executes do
|
20
|
+
NewRelic::Agent.logger.info('Installing ActiveSupport instrumentation')
|
21
|
+
end
|
22
|
+
|
23
|
+
executes do
|
24
|
+
ActiveSupport::Notifications.subscribe(/\.active_support$/,
|
25
|
+
NewRelic::Agent::Instrumentation::ActiveSupportSubscriber.new)
|
26
|
+
end
|
12
27
|
end
|