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/agent.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
|
require 'forwardable'
|
6
6
|
|
@@ -29,7 +29,7 @@ module NewRelic
|
|
29
29
|
require 'new_relic/metric_spec'
|
30
30
|
require 'new_relic/metric_data'
|
31
31
|
require 'new_relic/noticed_error'
|
32
|
-
require 'new_relic/agent/
|
32
|
+
require 'new_relic/agent/noticeable_error'
|
33
33
|
require 'new_relic/supportability_helper'
|
34
34
|
|
35
35
|
require 'new_relic/agent/encoding_normalizer'
|
@@ -143,6 +143,8 @@ module NewRelic
|
|
143
143
|
#
|
144
144
|
def add_or_defer_method_tracer(receiver, method_name, metric_name, options)
|
145
145
|
@tracer_lock.synchronize do
|
146
|
+
options[:code_information] = NewRelic::Agent::MethodTracerHelpers.code_information(receiver, method_name)
|
147
|
+
|
146
148
|
if @agent
|
147
149
|
receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
|
148
150
|
else
|
@@ -196,15 +198,9 @@ module NewRelic
|
|
196
198
|
|
197
199
|
if value.is_a?(Hash)
|
198
200
|
stats = NewRelic::Agent::Stats.new
|
199
|
-
|
200
|
-
stats.call_count = value[:count] if value[:count]
|
201
|
-
stats.total_call_time = value[:total] if value[:total]
|
202
|
-
stats.total_exclusive_time = value[:total] if value[:total]
|
203
|
-
stats.min_call_time = value[:min] if value[:min]
|
204
|
-
stats.max_call_time = value[:max] if value[:max]
|
205
|
-
stats.sum_of_squares = value[:sum_of_squares] if value[:sum_of_squares]
|
206
|
-
value = stats
|
201
|
+
value = stats.hash_merge(value)
|
207
202
|
end
|
203
|
+
|
208
204
|
agent.stats_engine.tl_record_unscoped_metrics(metric_name, value)
|
209
205
|
end
|
210
206
|
|
@@ -235,7 +231,7 @@ module NewRelic
|
|
235
231
|
# @!group Recording custom errors
|
236
232
|
|
237
233
|
# Set a filter to be applied to errors that the Ruby Agent will
|
238
|
-
# track. The block should
|
234
|
+
# track. The block should evaluate to the exception to track
|
239
235
|
# (which could be different from the original exception) or nil to
|
240
236
|
# ignore this exception.
|
241
237
|
#
|
@@ -287,7 +283,7 @@ module NewRelic
|
|
287
283
|
record_api_supportability_metric(:notice_error)
|
288
284
|
|
289
285
|
Transaction.notice_error(exception, options)
|
290
|
-
nil # don't return a noticed error
|
286
|
+
nil # don't return a noticed error data structure. it can only hurt.
|
291
287
|
end
|
292
288
|
|
293
289
|
# @!endgroup
|
@@ -417,7 +413,7 @@ module NewRelic
|
|
417
413
|
#
|
418
414
|
def add_instrumentation(file_pattern)
|
419
415
|
record_api_supportability_metric(:add_instrumentation)
|
420
|
-
NewRelic::Control.instance.add_instrumentation
|
416
|
+
NewRelic::Control.instance.add_instrumentation(file_pattern)
|
421
417
|
end
|
422
418
|
|
423
419
|
# Require agent testing helper methods
|
@@ -513,8 +509,8 @@ module NewRelic
|
|
513
509
|
# @api public
|
514
510
|
#
|
515
511
|
def disable_transaction_tracing
|
516
|
-
Deprecator.deprecate
|
517
|
-
'disable_all_tracing or ignore_transaction'
|
512
|
+
Deprecator.deprecate(:disable_transaction_tracing,
|
513
|
+
'disable_all_tracing or ignore_transaction')
|
518
514
|
record_api_supportability_metric(:disable_transaction_tracing)
|
519
515
|
yield
|
520
516
|
end
|
@@ -577,21 +573,25 @@ module NewRelic
|
|
577
573
|
def add_custom_attributes(params) # THREAD_LOCAL_ACCESS
|
578
574
|
record_api_supportability_metric(:add_custom_attributes)
|
579
575
|
|
580
|
-
if params.is_a?
|
576
|
+
if params.is_a?(Hash)
|
581
577
|
txn = Transaction.tl_current
|
582
578
|
txn.add_custom_attributes(params) if txn
|
583
579
|
|
584
580
|
segment = ::NewRelic::Agent::Tracer.current_segment
|
585
581
|
if segment
|
586
|
-
|
587
|
-
segment_custom_keys = segment.attributes.custom_attributes.keys.map(&:to_sym)
|
588
|
-
segment.add_custom_attributes(params.reject { |k, _v| segment_custom_keys.include?(k.to_sym) })
|
582
|
+
add_new_segment_attributes(params, segment)
|
589
583
|
end
|
590
584
|
else
|
591
585
|
::NewRelic::Agent.logger.warn("Bad argument passed to #add_custom_attributes. Expected Hash but got #{params.class}")
|
592
586
|
end
|
593
587
|
end
|
594
588
|
|
589
|
+
def add_new_segment_attributes(params, segment)
|
590
|
+
# Make sure not to override existing segment-level custom attributes
|
591
|
+
segment_custom_keys = segment.attributes.custom_attributes.keys.map(&:to_sym)
|
592
|
+
segment.add_custom_attributes(params.reject { |k, _v| segment_custom_keys.include?(k.to_sym) })
|
593
|
+
end
|
594
|
+
|
595
595
|
# Add custom attributes to the span event for the current span. Attributes will be visible on spans in the
|
596
596
|
# New Relic Distributed Tracing UI and on span events in New Relic Insights.
|
597
597
|
#
|
@@ -605,15 +605,15 @@ module NewRelic
|
|
605
605
|
#
|
606
606
|
# @see https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/glossary#span
|
607
607
|
# @api public
|
608
|
-
def add_custom_span_attributes
|
609
|
-
record_api_supportability_metric
|
608
|
+
def add_custom_span_attributes(params)
|
609
|
+
record_api_supportability_metric(:add_custom_span_attributes)
|
610
610
|
|
611
|
-
if params.is_a?
|
611
|
+
if params.is_a?(Hash)
|
612
612
|
if segment = NewRelic::Agent::Tracer.current_segment
|
613
|
-
segment.add_custom_attributes
|
613
|
+
segment.add_custom_attributes(params)
|
614
614
|
end
|
615
615
|
else
|
616
|
-
::NewRelic::Agent.logger.warn
|
616
|
+
::NewRelic::Agent.logger.warn("Bad argument passed to #add_custom_span_attributes. Expected Hash but got #{params.class}")
|
617
617
|
end
|
618
618
|
end
|
619
619
|
|
@@ -670,7 +670,7 @@ module NewRelic
|
|
670
670
|
|
671
671
|
# Yield to a block that is run with a database metric name context. This means
|
672
672
|
# the Database instrumentation will use this for the metric name if it does not
|
673
|
-
# otherwise know about a model. This is
|
673
|
+
# otherwise know about a model. This is reentrant.
|
674
674
|
#
|
675
675
|
# @param [String,Class,#to_s] model the DB model class
|
676
676
|
#
|
@@ -696,7 +696,7 @@ module NewRelic
|
|
696
696
|
def notify(event_type, *args)
|
697
697
|
agent.events.notify(event_type, *args)
|
698
698
|
rescue
|
699
|
-
NewRelic::Agent.logger.debug
|
699
|
+
NewRelic::Agent.logger.debug("Ignoring exception during %p event notification" % [event_type])
|
700
700
|
end
|
701
701
|
|
702
702
|
# @!group Trace and Entity metadata
|
@@ -756,7 +756,7 @@ module NewRelic
|
|
756
756
|
def browser_timing_header(nonce = nil)
|
757
757
|
record_api_supportability_metric(:browser_timing_header)
|
758
758
|
|
759
|
-
return
|
759
|
+
return EMPTY_STR unless agent
|
760
760
|
agent.javascript_instrumentor.browser_timing_header(nonce)
|
761
761
|
end
|
762
762
|
|
@@ -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 'optparse'
|
6
6
|
|
@@ -15,8 +15,8 @@ module NewRelic
|
|
15
15
|
# Capture a failure to execute the command.
|
16
16
|
class CommandFailure < StandardError
|
17
17
|
attr_reader :options
|
18
|
-
def initialize
|
19
|
-
super
|
18
|
+
def initialize(message, opt_parser = nil)
|
19
|
+
super(message)
|
20
20
|
@options = opt_parser
|
21
21
|
end
|
22
22
|
end
|
@@ -33,7 +33,7 @@ module NewRelic
|
|
33
33
|
if Hash === command_line_args
|
34
34
|
# command line args is an options hash
|
35
35
|
command_line_args.each do |key, value|
|
36
|
-
instance_variable_set
|
36
|
+
instance_variable_set("@#{key}", value.to_s) if value
|
37
37
|
end
|
38
38
|
else
|
39
39
|
# parse command line args. Throw an exception on a bad arg.
|
@@ -65,13 +65,13 @@ module NewRelic
|
|
65
65
|
script_name = 'newrelic'
|
66
66
|
end
|
67
67
|
opts.banner = "Usage: #{script_name} [ #{@command_names.join(" | ")} ] [options]"
|
68
|
-
opts.separator
|
68
|
+
opts.separator("use '#{script_name} <command> -h' to see detailed command options")
|
69
69
|
opts
|
70
70
|
end
|
71
71
|
extra = options.order!
|
72
72
|
command = extra.shift
|
73
73
|
# just make it a little easier on them
|
74
|
-
command = 'deployments' if command
|
74
|
+
command = 'deployments' if command.include?('deploy')
|
75
75
|
if command.nil?
|
76
76
|
STDERR.puts options
|
77
77
|
elsif !@command_names.include?(command)
|
@@ -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 a class for executing commands related to deployment
|
6
6
|
# events. It runs without loading the rails environment
|
@@ -27,7 +27,7 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
27
27
|
#
|
28
28
|
# Will throw CommandFailed exception if there's any error.
|
29
29
|
#
|
30
|
-
def initialize
|
30
|
+
def initialize(command_line_args)
|
31
31
|
@control = NewRelic::Control.instance
|
32
32
|
@environment = nil
|
33
33
|
@changelog = nil
|
@@ -40,6 +40,7 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
40
40
|
load_yaml_from_env(control.env)
|
41
41
|
@appname ||= NewRelic::Agent.config[:app_name][0] || control.env || 'development'
|
42
42
|
@license_key ||= NewRelic::Agent.config[:license_key]
|
43
|
+
@api_key ||= NewRelic::Agent.config[:api_key]
|
43
44
|
|
44
45
|
setup_logging(control.env)
|
45
46
|
end
|
@@ -64,33 +65,32 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
64
65
|
def run
|
65
66
|
begin
|
66
67
|
@description = nil if @description && @description.strip.empty?
|
67
|
-
create_params = {}
|
68
|
-
{
|
69
|
-
:application_id => @appname,
|
70
|
-
:host => NewRelic::Agent::Hostname.get,
|
71
|
-
:description => @description,
|
72
|
-
:user => @user,
|
73
|
-
:revision => @revision,
|
74
|
-
:changelog => @changelog
|
75
|
-
}.each do |k, v|
|
76
|
-
create_params["deployment[#{k}]"] = v unless v.nil? || v == ''
|
77
|
-
end
|
78
|
-
http = ::NewRelic::Agent::NewRelicService.new(nil, control.api_server).http_connection
|
79
|
-
|
80
|
-
uri = "/deployments.xml"
|
81
68
|
|
82
69
|
if @license_key.nil? || @license_key.empty?
|
83
|
-
raise "license_key
|
70
|
+
raise "license_key not set in newrelic.yml for #{control.env}. api_key also required to use New Relic REST API v2"
|
71
|
+
end
|
72
|
+
|
73
|
+
if !api_v1? && (@revision.nil? || @revision.empty?)
|
74
|
+
raise "revision required when using New Relic REST API v2 with api_key. Pass in revision using: -r, --revision=REV"
|
84
75
|
end
|
85
|
-
request = Net::HTTP::Post.new(uri, {'x-license-key' => @license_key})
|
86
|
-
request.content_type = "application/octet-stream"
|
87
76
|
|
88
|
-
request
|
77
|
+
request = if api_v1?
|
78
|
+
uri = "/deployments.xml"
|
79
|
+
create_request(uri, {'x-license-key' => @license_key}, "application/octet-stream").tap do |req|
|
80
|
+
set_params_v1(req)
|
81
|
+
end
|
82
|
+
else
|
83
|
+
uri = "/v2/applications/#{application_id}/deployments.json"
|
84
|
+
create_request(uri, {"Api-Key" => @api_key}, "application/json").tap do |req|
|
85
|
+
set_params_v2(req)
|
86
|
+
end
|
87
|
+
end
|
89
88
|
|
89
|
+
http = ::NewRelic::Agent::NewRelicService.new(nil, control.api_server).http_connection
|
90
90
|
response = http.request(request)
|
91
91
|
|
92
|
-
if response.is_a?
|
93
|
-
info
|
92
|
+
if response.is_a?(Net::HTTPSuccess)
|
93
|
+
info("Recorded deployment to '#{@appname}' (#{@description || Time.now})")
|
94
94
|
else
|
95
95
|
err_string = REXML::Document.new(response.body).elements['errors/error'].map(&:to_s).join("; ") rescue response.message
|
96
96
|
raise NewRelic::Cli::Command::CommandFailure, "Deployment not recorded: #{err_string}"
|
@@ -102,20 +102,72 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
102
102
|
rescue NewRelic::Cli::Command::CommandFailure
|
103
103
|
raise
|
104
104
|
rescue => e
|
105
|
-
err
|
106
|
-
info
|
105
|
+
err("Unexpected error attempting to connect to #{control.api_server}")
|
106
|
+
info("#{e}: #{e.backtrace.join("\n ")}")
|
107
107
|
raise NewRelic::Cli::Command::CommandFailure.new(e.to_s)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
+
def api_v1?
|
112
|
+
@api_key.nil? || @api_key.empty?
|
113
|
+
end
|
114
|
+
|
111
115
|
private
|
112
116
|
|
117
|
+
def create_request(uri, headers, content_type)
|
118
|
+
Net::HTTP::Post.new(uri, headers).tap do |req|
|
119
|
+
req.content_type = content_type
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def application_id
|
124
|
+
return @application_id if @application_id
|
125
|
+
|
126
|
+
# Need to connect to collector to acquire application id from the connect response
|
127
|
+
# but set monitor_mode false because we don't want to actually report anything
|
128
|
+
begin
|
129
|
+
NewRelic::Agent.manual_start(monitor_mode: false)
|
130
|
+
NewRelic::Agent.agent.connect_to_server
|
131
|
+
@application_id = NewRelic::Agent.config[:primary_application_id]
|
132
|
+
ensure
|
133
|
+
NewRelic::Agent.shutdown
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def set_params_v1(request)
|
138
|
+
params = {
|
139
|
+
:application_id => @appname,
|
140
|
+
:host => NewRelic::Agent::Hostname.get,
|
141
|
+
:description => @description,
|
142
|
+
:user => @user,
|
143
|
+
:revision => @revision,
|
144
|
+
:changelog => @changelog
|
145
|
+
}.each_with_object({}) do |(k, v), h|
|
146
|
+
h["deployment[#{k}]"] = v unless v.nil? || v == ''
|
147
|
+
end
|
148
|
+
request.set_form_data(params)
|
149
|
+
end
|
150
|
+
|
151
|
+
def set_params_v2(request)
|
152
|
+
request.body = {
|
153
|
+
"deployment" => {
|
154
|
+
:description => @description,
|
155
|
+
:user => @user,
|
156
|
+
:revision => @revision,
|
157
|
+
:changelog => @changelog
|
158
|
+
}
|
159
|
+
}.to_json
|
160
|
+
end
|
161
|
+
|
113
162
|
def options
|
114
|
-
OptionParser.new
|
115
|
-
o.separator
|
163
|
+
OptionParser.new(%Q(Usage: #{$0} #{self.class.command} [OPTIONS] ["description"] ), 40) do |o|
|
164
|
+
o.separator("OPTIONS:")
|
116
165
|
o.on("-a", "--appname=NAME", String,
|
117
166
|
"Set the application name.",
|
118
|
-
"Default is app_name setting in newrelic.yml") { |e| @appname = e }
|
167
|
+
"Default is app_name setting in newrelic.yml. Available only when using API v1.") { |e| @appname = e }
|
168
|
+
o.on("-i", "--appid=ID", String,
|
169
|
+
"Set the application ID",
|
170
|
+
"If not provided, will connect to the New Relic collector to get it") { |i| @application_id = i }
|
119
171
|
o.on("-e", "--environment=name", String,
|
120
172
|
"Override the (RAILS|RUBY|RACK)_ENV setting",
|
121
173
|
"currently: #{control.env}") { |e| @environment = e }
|
@@ -123,12 +175,12 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
123
175
|
"Specify the user deploying, for information only",
|
124
176
|
"Default: #{@user || '<none>'}") { |u| @user = u }
|
125
177
|
o.on("-r", "--revision=REV", String,
|
126
|
-
"Specify the revision being deployed") { |r| @revision = r }
|
178
|
+
"Specify the revision being deployed. Required when using New Relic REST API v2") { |r| @revision = r }
|
127
179
|
o.on("-l", "--license-key=KEY", String,
|
128
180
|
"Specify the license key of the account for the app being deployed") { |l| @license_key = l }
|
129
181
|
o.on("-c", "--changes",
|
130
182
|
"Read in a change log from the standard input") { @changelog = STDIN.read }
|
131
|
-
yield
|
183
|
+
yield(o) if block_given?
|
132
184
|
end
|
133
185
|
end
|
134
186
|
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 'fileutils'
|
6
6
|
require 'new_relic/version'
|
@@ -20,12 +20,12 @@ class NewRelic::Cli::Install < NewRelic::Cli::Command
|
|
20
20
|
# Will throw CommandFailed exception if there's any error.
|
21
21
|
#
|
22
22
|
attr_reader :dest_dir, :license_key, :generated_for_user, :quiet, :src_file, :app_name
|
23
|
-
def initialize
|
23
|
+
def initialize(command_line_args = {})
|
24
24
|
@dest_dir = nil
|
25
|
-
super
|
25
|
+
super(command_line_args)
|
26
26
|
if @dest_dir.nil?
|
27
27
|
# Install a newrelic.yml file into the local config directory.
|
28
|
-
if File.directory?
|
28
|
+
if File.directory?("config")
|
29
29
|
@dest_dir = "config"
|
30
30
|
else
|
31
31
|
@dest_dir = "."
|
@@ -70,13 +70,13 @@ Visit support.newrelic.com if you are experiencing installation issues.
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def options
|
73
|
-
OptionParser.new
|
73
|
+
OptionParser.new("Usage: #{$0} #{self.class.command} [ OPTIONS] 'application name'", 40) do |o|
|
74
74
|
o.on("-f", "--force", "Overwrite newrelic.yml if it exists") { |e| @force = true }
|
75
75
|
o.on("-l", "--license_key=NAME", String,
|
76
76
|
"Use the given license key") { |e| @license_key = e }
|
77
77
|
o.on("-d", "--destdir=name", String,
|
78
78
|
"Write the newrelic.yml to the given directory, default is '.'") { |e| @dest_dir = e }
|
79
|
-
yield
|
79
|
+
yield(o) if block_given?
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
data/lib/new_relic/coerce.rb
CHANGED
@@ -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
|
@@ -43,7 +42,7 @@ module NewRelic
|
|
43
42
|
String(value)
|
44
43
|
rescue => error
|
45
44
|
log_failure(value.class, String, context, error)
|
46
|
-
|
45
|
+
EMPTY_STR
|
47
46
|
end
|
48
47
|
|
49
48
|
def scalar(val)
|
@@ -61,7 +60,7 @@ module NewRelic
|
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
|
-
def int!
|
63
|
+
def int!(value)
|
65
64
|
return nil unless value_or_nil(value)
|
66
65
|
Integer(value)
|
67
66
|
end
|
@@ -69,16 +68,16 @@ module NewRelic
|
|
69
68
|
# Use when you plan to perform a boolean check using the integer 1
|
70
69
|
# for true and the integer 0 for false
|
71
70
|
# String values will be converted to 0
|
72
|
-
def boolean_int!
|
71
|
+
def boolean_int!(value)
|
73
72
|
value.to_i
|
74
73
|
end
|
75
74
|
|
76
|
-
def float!
|
75
|
+
def float!(value, precision = NewRelic::PRIORITY_PRECISION)
|
77
76
|
return nil unless value_or_nil(value)
|
78
77
|
value.to_f.round(precision)
|
79
78
|
end
|
80
79
|
|
81
|
-
def value_or_nil
|
80
|
+
def value_or_nil(value)
|
82
81
|
return nil if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
83
82
|
value
|
84
83
|
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
|
6
6
|
module CollectionHelper
|
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
def normalize_params(params)
|
12
12
|
case params
|
13
13
|
when Hash
|
14
|
-
#
|
14
|
+
# Optimize for empty hash since that is often what this is called with.
|
15
15
|
return params if params.empty?
|
16
16
|
new_params = {}
|
17
17
|
params.each do |key, value|
|
@@ -39,14 +39,14 @@ module NewRelic
|
|
39
39
|
when nil then ''
|
40
40
|
when object.instance_of?(String) then object
|
41
41
|
when String then String.new(object) # convert string subclasses to strings
|
42
|
-
else "#<#{object.class
|
42
|
+
else String.new("#<#{object.class}>")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def truncate(string, len = DEFAULT_TRUNCATION_SIZE)
|
47
47
|
case string
|
48
48
|
when Symbol then string
|
49
|
-
when nil then
|
49
|
+
when nil then EMPTY_STR
|
50
50
|
when String
|
51
51
|
real_string = flatten(string)
|
52
52
|
if real_string.size > len
|
data/lib/new_relic/constants.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
|
require 'new_relic/control/frameworks/ruby'
|
6
6
|
module NewRelic
|
@@ -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/control/frameworks/ruby'
|
6
6
|
module NewRelic
|
@@ -73,7 +73,7 @@ module NewRelic
|
|
73
73
|
begin
|
74
74
|
require 'new_relic/rack/agent_hooks'
|
75
75
|
return unless NewRelic::Rack::AgentHooks.needed?
|
76
|
-
config.middleware.use
|
76
|
+
config.middleware.use(NewRelic::Rack::AgentHooks)
|
77
77
|
::NewRelic::Agent.logger.debug("Installed New Relic Agent Hooks middleware")
|
78
78
|
rescue => e
|
79
79
|
::NewRelic::Agent.logger.warn("Error installing New Relic Agent Hooks middleware", e)
|
@@ -87,7 +87,7 @@ module NewRelic
|
|
87
87
|
return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
|
88
88
|
begin
|
89
89
|
require 'new_relic/rack/browser_monitoring'
|
90
|
-
config.middleware.use
|
90
|
+
config.middleware.use(NewRelic::Rack::BrowserMonitoring)
|
91
91
|
::NewRelic::Agent.logger.debug("Installed New Relic Browser Monitoring middleware")
|
92
92
|
rescue => e
|
93
93
|
::NewRelic::Agent.logger.warn("Error installing New Relic Browser Monitoring middleware", e)
|
@@ -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/control/frameworks/ruby'
|
6
6
|
module NewRelic
|