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
data/lib/new_relic/recipes.rb
CHANGED
@@ -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
|
# When installed as a plugin, this is loaded automatically.
|
6
6
|
#
|
@@ -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
|
6
6
|
module SupportabilityHelper
|
@@ -62,21 +62,21 @@ module NewRelic
|
|
62
62
|
def record_api_supportability_metric(method_name)
|
63
63
|
agent = NewRelic::Agent.agent or return
|
64
64
|
if metric = API_SUPPORTABILITY_METRICS[method_name]
|
65
|
-
agent.stats_engine.tl_record_unscoped_metrics
|
65
|
+
agent.stats_engine.tl_record_unscoped_metrics(metric, &:increment_count)
|
66
66
|
else
|
67
|
-
NewRelic::Agent.logger.debug
|
67
|
+
NewRelic::Agent.logger.debug("API supportability metric not found for :#{method_name}")
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def valid_api_argument_class?
|
71
|
+
def valid_api_argument_class?(arg, name, klass)
|
72
72
|
return true if arg.is_a?(klass)
|
73
73
|
|
74
|
-
caller_location = caller_locations.first.label
|
74
|
+
caller_location = caller_locations(1..1).first.label
|
75
75
|
|
76
76
|
message = "Bad argument passed to ##{caller_location}. " \
|
77
77
|
"Expected #{klass} for `#{name}` but got #{arg.class}"
|
78
78
|
|
79
|
-
NewRelic::Agent.logger.warn
|
79
|
+
NewRelic::Agent.logger.warn(message)
|
80
80
|
nil
|
81
81
|
end
|
82
82
|
end
|
@@ -1,4 +1,3 @@
|
|
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.
|
4
3
|
# frozen_string_literal: true
|
@@ -7,19 +6,18 @@ module NewRelic
|
|
7
6
|
#
|
8
7
|
# This class allows the current transaction to be passed to a Thread so that nested segments can be created from the operations performed within the Thread's block.
|
9
8
|
# To have the New Relic Ruby agent automatically trace all of your applications threads,
|
10
|
-
# enable the
|
9
|
+
# enable the +instrumentation.thread.tracing+ configuration option in your newrelic.yml.
|
11
10
|
#
|
12
|
-
# Note: disabling the configuration option
|
11
|
+
# Note: disabling the configuration option +instrumentation.thread+ while using this class can cause incorrectly nested spans.
|
13
12
|
#
|
14
13
|
# @api public
|
15
14
|
class TracedThread < Thread
|
16
15
|
#
|
17
16
|
# Creates a new Thread whose work will be traced by New Relic.
|
18
17
|
# Use this class as a replacement for the native Thread class.
|
19
|
-
# Example: Instead of using
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# ```
|
18
|
+
# Example: Instead of using +Thread.new+, use:
|
19
|
+
#
|
20
|
+
# NewRelic::TracedThread.new { execute_some_code }
|
23
21
|
#
|
24
22
|
# @api public
|
25
23
|
def initialize(*args, &block)
|
data/lib/new_relic/version.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
|
-
# encoding: utf-8
|
3
2
|
# This file is distributed under New Relic's license terms.
|
4
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
5
|
|
6
6
|
module NewRelic
|
7
7
|
module VERSION # :nodoc:
|
8
8
|
MAJOR = 8
|
9
|
-
MINOR =
|
9
|
+
MINOR = 11
|
10
10
|
TINY = 0
|
11
11
|
|
12
12
|
STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
|
data/lib/newrelic_rpm.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
# encoding: utf-8
|
3
2
|
# This file is distributed under New Relic's license terms.
|
4
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
5
|
|
6
6
|
require 'sequel' unless defined?(Sequel)
|
7
7
|
require 'newrelic_rpm' unless defined?(NewRelic)
|
@@ -62,18 +62,18 @@ module Sequel
|
|
62
62
|
# block in the sequel Plugin instrumentation. A simple ORM operation from the Plugin
|
63
63
|
# instrumentation may trigger a number of calls to this method. We want to append
|
64
64
|
# the statements that come from the disable_all_tracing block into this node's
|
65
|
-
# statement, otherwise we would end up
|
65
|
+
# statement, otherwise we would end up overwriting the sql statement with the
|
66
66
|
# last one executed.
|
67
|
-
def notice_sql
|
67
|
+
def notice_sql(sql)
|
68
68
|
return unless txn = NewRelic::Agent::Tracer.current_transaction
|
69
69
|
|
70
70
|
current_segment = txn.current_segment
|
71
71
|
return unless current_segment.is_a?(NewRelic::Agent::Transaction::DatastoreSegment)
|
72
72
|
|
73
73
|
if current_segment.sql_statement
|
74
|
-
current_segment.sql_statement.append_sql
|
74
|
+
current_segment.sql_statement.append_sql(sql)
|
75
75
|
else
|
76
|
-
current_segment._notice_sql
|
76
|
+
current_segment._notice_sql(sql, self.opts, explainer_for(sql))
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -81,8 +81,8 @@ module Sequel
|
|
81
81
|
(defined?(::Sequel::ThreadedConnectionPool) && ::Sequel::ThreadedConnectionPool)
|
82
82
|
].freeze
|
83
83
|
|
84
|
-
def explainer_for
|
85
|
-
|
84
|
+
def explainer_for(sql)
|
85
|
+
proc do |*|
|
86
86
|
if THREAD_SAFE_CONNECTION_POOL_CLASSES.include?(self.pool.class)
|
87
87
|
self[sql].explain
|
88
88
|
else
|
@@ -93,6 +93,6 @@ module Sequel
|
|
93
93
|
end
|
94
94
|
end # module NewRelicInstrumentation
|
95
95
|
|
96
|
-
NewRelic::Agent.logger.debug
|
96
|
+
NewRelic::Agent.logger.debug("Registering the :newrelic_instrumentation extension.")
|
97
97
|
Database.register_extension(:newrelic_instrumentation, NewRelicInstrumentation)
|
98
98
|
end # module Sequel
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
# encoding: utf-8
|
3
2
|
# This file is distributed under New Relic's license terms.
|
4
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
5
|
|
6
6
|
require 'sequel' unless defined?(Sequel)
|
7
7
|
require 'newrelic_rpm' unless defined?(NewRelic)
|
data/lib/tasks/all.rb
CHANGED
@@ -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
|
# This is required to load in task definitions
|
6
6
|
Dir.glob(File.join(File.dirname(__FILE__), '*.rake')) do |file|
|
data/lib/tasks/config.rake
CHANGED
@@ -1,7 +1,12 @@
|
|
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_relative 'helpers/format'
|
6
|
+
include Format
|
7
|
+
|
1
8
|
namespace :newrelic do
|
2
9
|
namespace :config do
|
3
|
-
desc "Describe available New Relic configuration settings."
|
4
|
-
|
5
10
|
GENERAL = "general"
|
6
11
|
DISABLING = "disabling"
|
7
12
|
ATTRIBUTES = "attributes"
|
@@ -24,116 +29,7 @@ namespace :newrelic do
|
|
24
29
|
"custom_insights_events" => "Custom Events"
|
25
30
|
}
|
26
31
|
|
27
|
-
|
28
|
-
config_hash = build_config_hash
|
29
|
-
sections = flatten_config_hash(config_hash)
|
30
|
-
|
31
|
-
puts build_erb(format).result(binding).split("\n").map(&:rstrip).join("\n").gsub('. ', '. ')
|
32
|
-
sections # silences unused warning to return this
|
33
|
-
end
|
34
|
-
|
35
|
-
def build_config_hash
|
36
|
-
sections = Hash.new { |hash, key| hash[key] = [] }
|
37
|
-
NewRelic::Agent::Configuration::DEFAULTS.each do |key, value|
|
38
|
-
next unless value[:public]
|
39
|
-
|
40
|
-
section_key = GENERAL
|
41
|
-
key = key.to_s
|
42
|
-
components = key.split(".")
|
43
|
-
|
44
|
-
if key.match(/^disable_/) # "disable_httpclient"
|
45
|
-
section_key = DISABLING
|
46
|
-
elsif components.length >= 2 && !(components[1] == "attributes") # "analytics_events.enabled"
|
47
|
-
section_key = components.first
|
48
|
-
elsif components[1] == "attributes" # "transaction_tracer.attributes.enabled"
|
49
|
-
section_key = ATTRIBUTES
|
50
|
-
end
|
51
|
-
|
52
|
-
sections[section_key] << {
|
53
|
-
:key => key,
|
54
|
-
:type => format_type(value[:type]),
|
55
|
-
:description => format_description(value),
|
56
|
-
:default => format_default_value(value),
|
57
|
-
:env_var => format_env_var(key)
|
58
|
-
}
|
59
|
-
end
|
60
|
-
sections
|
61
|
-
end
|
62
|
-
|
63
|
-
def flatten_config_hash(config_hash)
|
64
|
-
sections = []
|
65
|
-
sections << pluck(GENERAL, config_hash)
|
66
|
-
sections << pluck("transaction_tracer", config_hash)
|
67
|
-
sections << pluck("error_collector", config_hash)
|
68
|
-
sections << pluck("browser_monitoring", config_hash)
|
69
|
-
sections << pluck("analytics_events", config_hash)
|
70
|
-
sections << pluck("transaction_events", config_hash)
|
71
|
-
sections << pluck("application_logging", config_hash)
|
72
|
-
sections.concat(config_hash.to_a.sort_by { |a| a.first })
|
73
|
-
|
74
|
-
add_data_to_sections(sections)
|
75
|
-
|
76
|
-
sections
|
77
|
-
end
|
78
|
-
|
79
|
-
def add_data_to_sections(sections)
|
80
|
-
sections.each do |section|
|
81
|
-
section_key = section[0]
|
82
|
-
section.insert(1, format_name(section_key))
|
83
|
-
section.insert(2, SECTION_DESCRIPTIONS[section_key])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def format_name(key)
|
88
|
-
name = NAME_OVERRIDES[key]
|
89
|
-
return name if name
|
90
|
-
|
91
|
-
key.split("_")
|
92
|
-
.each { |fragment| fragment[0] = fragment[0].upcase }
|
93
|
-
.join(" ")
|
94
|
-
end
|
95
|
-
|
96
|
-
def format_type(type)
|
97
|
-
if type == NewRelic::Agent::Configuration::Boolean
|
98
|
-
"Boolean"
|
99
|
-
else
|
100
|
-
type
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def format_description(value)
|
105
|
-
description = ''
|
106
|
-
description += "<b>DEPRECATED</b> " if value[:deprecated]
|
107
|
-
description += value[:description]
|
108
|
-
description
|
109
|
-
end
|
110
|
-
|
111
|
-
def format_default_value(spec)
|
112
|
-
return spec[:documentation_default] if !spec[:documentation_default].nil?
|
113
|
-
if spec[:default].is_a?(Proc)
|
114
|
-
'(Dynamic)'
|
115
|
-
else
|
116
|
-
"#{spec[:default].inspect}"
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def format_env_var(key)
|
121
|
-
return "None" if NON_ENV_CONFIGS.include? key
|
122
|
-
"NEW_RELIC_#{key.gsub(".", "_").upcase}"
|
123
|
-
end
|
124
|
-
|
125
|
-
def pluck(key, config_hash)
|
126
|
-
value = config_hash.delete(key)
|
127
|
-
[key, value]
|
128
|
-
end
|
129
|
-
|
130
|
-
def build_erb(format)
|
131
|
-
require 'erb'
|
132
|
-
path = File.join(File.dirname(__FILE__), "config.#{format}.erb")
|
133
|
-
template = File.read(File.expand_path(path))
|
134
|
-
ERB.new(template)
|
135
|
-
end
|
136
|
-
|
32
|
+
desc "Describe available New Relic configuration settings"
|
137
33
|
task :docs, [:format] => [] do |t, args|
|
138
34
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "new_relic", "agent", "configuration", "default_source.rb"))
|
139
35
|
format = args[:format] || "text"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
|
5
|
+
if ENV['CI']
|
6
|
+
namespace :coverage do
|
7
|
+
desc "Collates all result sets generated by the different test runners"
|
8
|
+
task :report do
|
9
|
+
require 'simplecov'
|
10
|
+
require 'fileutils'
|
11
|
+
|
12
|
+
SimpleCov.coverage_dir('coverage_results')
|
13
|
+
|
14
|
+
SimpleCov.collate(Dir['*/coverage_*/.resultset.json']) do
|
15
|
+
formatter SimpleCov::Formatter::HTMLFormatter
|
16
|
+
refuse_coverage_drop
|
17
|
+
end
|
18
|
+
|
19
|
+
Dir['lib/coverage_{[!r][!e][!s][!u][!l][!t][!s]}*'].each { |dir| FileUtils.rm_rf(dir) }
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Removes all coverage_* directories"
|
23
|
+
task :clear do
|
24
|
+
require 'fileutils'
|
25
|
+
Dir["lib/coverage_*"].each { |dir| FileUtils.rm_rf(dir) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,120 @@
|
|
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
|
+
module Format
|
6
|
+
def output(format)
|
7
|
+
config_hash = build_config_hash
|
8
|
+
sections = flatten_config_hash(config_hash)
|
9
|
+
|
10
|
+
puts build_erb(format).result(binding).split("\n").map(&:rstrip).join("\n").gsub('. ', '. ')
|
11
|
+
sections # silences unused warning to return this
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def add_data_to_sections(sections)
|
17
|
+
sections.each do |section|
|
18
|
+
section_key = section[0]
|
19
|
+
section.insert(1, format_name(section_key))
|
20
|
+
section.insert(2, SECTION_DESCRIPTIONS[section_key])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_config_hash
|
25
|
+
sections = Hash.new { |hash, key| hash[key] = [] }
|
26
|
+
NewRelic::Agent::Configuration::DEFAULTS.each do |key, value|
|
27
|
+
next unless value[:public]
|
28
|
+
key = key.to_s
|
29
|
+
section_key = section_key(key, key.split('.'))
|
30
|
+
sections[section_key] << format_sections(key, value)
|
31
|
+
end
|
32
|
+
sections
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_erb(format)
|
36
|
+
require 'erb'
|
37
|
+
path = File.join(File.dirname(__FILE__), "config.#{format}.erb")
|
38
|
+
template = File.read(File.expand_path(path))
|
39
|
+
ERB.new(template)
|
40
|
+
end
|
41
|
+
|
42
|
+
def flatten_config_hash(config_hash)
|
43
|
+
sections = []
|
44
|
+
config = [GENERAL, 'transaction_tracer', 'error_collector',
|
45
|
+
'browser_monitoring', 'analytics_events', 'transaction_events',
|
46
|
+
'application_logging']
|
47
|
+
|
48
|
+
config.each { |config| sections << pluck(config, config_hash) }
|
49
|
+
|
50
|
+
sections.concat(config_hash.to_a.sort_by { |a| a.first })
|
51
|
+
add_data_to_sections(sections)
|
52
|
+
|
53
|
+
sections
|
54
|
+
end
|
55
|
+
|
56
|
+
def format_default_value(spec)
|
57
|
+
return spec[:documentation_default] if !spec[:documentation_default].nil?
|
58
|
+
if spec[:default].is_a?(Proc)
|
59
|
+
'(Dynamic)'
|
60
|
+
else
|
61
|
+
"#{spec[:default].inspect}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def format_description(value)
|
66
|
+
description = ''
|
67
|
+
description += "<b>DEPRECATED</b> " if value[:deprecated]
|
68
|
+
description += value[:description]
|
69
|
+
description
|
70
|
+
end
|
71
|
+
|
72
|
+
def format_env_var(key)
|
73
|
+
return "None" if NON_ENV_CONFIGS.include?(key)
|
74
|
+
"NEW_RELIC_#{key.tr(".", "_").upcase}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def format_name(key)
|
78
|
+
name = NAME_OVERRIDES[key]
|
79
|
+
return name if name
|
80
|
+
|
81
|
+
key.split("_")
|
82
|
+
.each { |fragment| fragment[0] = fragment[0].upcase }
|
83
|
+
.join(" ")
|
84
|
+
end
|
85
|
+
|
86
|
+
def format_sections(key, value)
|
87
|
+
{
|
88
|
+
:key => key,
|
89
|
+
:type => format_type(value[:type]),
|
90
|
+
:description => format_description(value),
|
91
|
+
:default => format_default_value(value),
|
92
|
+
:env_var => format_env_var(key)
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
def format_type(type)
|
97
|
+
if type == NewRelic::Agent::Configuration::Boolean
|
98
|
+
"Boolean"
|
99
|
+
else
|
100
|
+
type
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def pluck(key, config_hash)
|
105
|
+
value = config_hash.delete(key)
|
106
|
+
[key, value]
|
107
|
+
end
|
108
|
+
|
109
|
+
def section_key(key, components)
|
110
|
+
if key =~ /^disable_/ # "disable_httpclient"
|
111
|
+
DISABLING
|
112
|
+
elsif components.length >= 2 && !(components[1] == "attributes") # "analytics_events.enabled"
|
113
|
+
components.first
|
114
|
+
elsif components[1] == "attributes" # "transaction_tracer.attributes.enabled"
|
115
|
+
ATTRIBUTES
|
116
|
+
else
|
117
|
+
GENERAL
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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
|
+
module Matches
|
6
|
+
def look_for_seed(tasks)
|
7
|
+
matches = tasks.map { |t| /(seed=.*?)[,\]]/.match(t) }.compact
|
8
|
+
if matches.any?
|
9
|
+
matches.first[1]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
module Prompt
|
6
|
+
def prompt_to_continue(command, destination = 'local')
|
7
|
+
puts "The following rsync command will be executed to update the #{destination} copy of the specs:"
|
8
|
+
puts
|
9
|
+
puts command
|
10
|
+
puts
|
11
|
+
puts "CAUTION: Any unsaved changes that exist within the #{destination} content will be OVERWRITTEN!"
|
12
|
+
if destination.eql?('local')
|
13
|
+
puts 'CAUTION 2: Before continuing, make sure your local repo is on the correct, synced branch!'
|
14
|
+
end
|
15
|
+
puts
|
16
|
+
print "Do you wish to continue? ('y' to continue, return to cancel) [n] "
|
17
|
+
continue = STDIN.gets.chomp
|
18
|
+
if continue.casecmp('y').zero?
|
19
|
+
system(command)
|
20
|
+
else
|
21
|
+
puts 'Cancelled'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
module Removers
|
6
|
+
def remove_local_multiverse_databases
|
7
|
+
list_databases_command = %(echo "show databases" | mysql -u root)
|
8
|
+
databases = `#{list_databases_command}`.chomp!.split("\n").select { |s| s.include?('multiverse') }
|
9
|
+
databases.each do |database|
|
10
|
+
puts "Dropping #{database}"
|
11
|
+
`echo "drop database #{database}" | mysql -u root`
|
12
|
+
end
|
13
|
+
rescue => error
|
14
|
+
puts "ERROR: Cannot get MySQL databases..."
|
15
|
+
puts error.message
|
16
|
+
end
|
17
|
+
|
18
|
+
def remove_generated_gemfiles
|
19
|
+
file_path = File.expand_path("test/multiverse/suites")
|
20
|
+
Dir.glob(File.join(file_path, "**", "Gemfile*")).each do |fn|
|
21
|
+
puts "Removing #{fn.gsub(file_path, '.../suites')}"
|
22
|
+
FileUtils.rm(fn)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def remove_generated_gemfile_lockfiles
|
27
|
+
file_path = File.expand_path("test/environments")
|
28
|
+
Dir.glob(File.join(file_path, "**", "Gemfile.lock")).each do |fn|
|
29
|
+
puts "Removing #{fn.gsub(file_path, '.../environments')}"
|
30
|
+
FileUtils.rm(fn)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/tasks/install.rake
CHANGED
@@ -1,3 +1,7 @@
|
|
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
|
+
|
1
5
|
namespace :newrelic do
|
2
6
|
desc "Install a default config/newrelic.yml file"
|
3
7
|
task :install do
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Instrumentation Generator
|
2
|
+
|
3
|
+
## Usage
|
4
|
+
|
5
|
+
`thor list` can be passed to get a list of all available thor commands
|
6
|
+
|
7
|
+
### instrumentation:scaffold
|
8
|
+
|
9
|
+
This task requires one parameter by default: the name of the library or class you are instrumenting. This task generates the basic file structure needed to add new instrumentation to the Ruby agent.
|
10
|
+
|
11
|
+
Run it using:
|
12
|
+
|
13
|
+
`thor instrumentation:scaffold gem_name`
|
14
|
+
|
15
|
+
It accepts two optional parameters:
|
16
|
+
|
17
|
+
- `--method`: the name of a method to instrument. Only one method can be accepted at this time. Defaults to `method_to_instrument`
|
18
|
+
- `--args`: the arguments for the instrumented method. A comma-separated list can be given if there are multiple arguments. Defaults to `*args`.
|
19
|
+
|
20
|
+
With the optional parameters, the task can be run like so:
|
21
|
+
|
22
|
+
`thor instrumentation:scaffold gem_name --method=method_to_instrument --args=arg1,arg2,arg3`
|
23
|
+
|
24
|
+
### WIP: instrumentation:add_new_method
|
25
|
+
|
26
|
+
Are you trying add instrumentation for a method within library we already instrument? This task is for you! Instead of building the entire scaffold, this task inserts only the changes needed within the `instrumentation.rb` and test files to instrument the new method. It requires one argument, the name of the existing instrumentation to add the method to. If the instrumented library does not already exist, it will create a new scaffold for that library.
|
27
|
+
|
28
|
+
Run it using:
|
29
|
+
|
30
|
+
`thor instrumentation:scaffold gem_name`
|
31
|
+
|
32
|
+
It accepts two optional parameters:
|
33
|
+
|
34
|
+
- `--method`: the name of a method to instrument. Only one method can be accepted at this time. Defaults to `method_to_instrument`
|
35
|
+
- `--args`: the arguments for the instrumented method. A comma-separated list can be given if there are multiple arguments. Defaults to `*args`.
|
36
|
+
|
37
|
+
With the optional parameters, the task can be run like so:
|
38
|
+
|
39
|
+
`thor instrumentation:add_new_method gem_name --method=method_to_instrument --args=arg1,arg2,arg3`
|
40
|
+
|
41
|
+
## Idea
|
42
|
+
|
43
|
+
Create a CLI, similar to Rails’ generators and scaffold scripts, to create the required files and basic classes for instrumenting new libraries. The hope is that the parts of adding new instrumentation that is repetitive can be eliminated and/or reduced so that it takes less time to add new instrumentation and we can spend development time considering the best attributes to collect and interactions to measure. I also hope this project will reduce the overall toil related to adding new instrumentation.
|
44
|
+
|
45
|
+
The files we create with little variation besides library and method names are:
|
46
|
+
|
47
|
+
- Lib
|
48
|
+
- Dependency detection
|
49
|
+
- Chain
|
50
|
+
- Prepend
|
51
|
+
- Instrumentation
|
52
|
+
- Tests
|
53
|
+
- configuration/newrelic.yml
|
54
|
+
- Envfile
|
55
|
+
- Test file
|
56
|
+
|
57
|
+
Furthermore, we also create very similar snippets inside the default source configuration file that could be generated by this project as well.
|
58
|
+
|
59
|
+
## Outcome
|
60
|
+
|
61
|
+
A prototype outside the agent has been created that generates the required files to create new instrumentation. This prototype accepts three arguments: name (name of the library), method (method to instrument), args (arguments for the method).
|
62
|
+
|
63
|
+
The Ruby gem Thor, a toolkit for building powerful command-line interfaces used in Bundler, Vagrant, Rails and others powers this CLI.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
# - [X] Create instrumentation file
|
4
|
+
|
5
|
+
# - [X] Create chain file
|
6
|
+
|
7
|
+
# - [X] Create prepend file
|
8
|
+
|
9
|
+
# - [X] Create dependency detection file
|
10
|
+
|
11
|
+
# - [X] Add config to default source
|
12
|
+
|
13
|
+
# - [X] Create multiverse suite
|
14
|
+
|
15
|
+
# - [X] Create Envfile
|
16
|
+
|
17
|
+
# - [X] Create test file with examples
|
18
|
+
|
19
|
+
# - [X] Create option for method names to instrument
|
20
|
+
|
21
|
+
# - [X] Add entry to newrelic.yml
|
22
|
+
|
23
|
+
# - [ ] Append a new method to instrument to an existing instrumentation class (with tests?)
|
24
|
+
|
25
|
+
# - [ ] Documentation: examples of what to add in each gap
|
26
|
+
|
27
|
+
# - [ ] Good examples of tests, instrumentation, etc. as comments
|
28
|
+
|
29
|
+
# - [ ] Handle multi-word gem names (camel case for classes, handle hyphens, concurrent-ruby as example)
|
30
|
+
|
31
|
+
# - [ ] Make sure multiple arguments can be passed to the command line
|
32
|
+
|
33
|
+
# - [ ] Add tests
|