newrelic_rpm 8.7.0 → 8.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rubocop.yml +68 -189
- data/.rubocop_todo.yml +52 -0
- data/.simplecov +15 -0
- data/.snyk +11 -0
- data/.yardopts +1 -0
- data/Brewfile +1 -0
- data/CHANGELOG.md +181 -23
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +0 -1
- data/Guardfile +1 -0
- data/README.md +1 -1
- data/Rakefile +13 -20
- data/Thorfile +5 -0
- data/bin/newrelic +2 -1
- data/bin/newrelic_cmd +1 -0
- data/bin/nrdebug +66 -45
- data/config.dot +5 -5
- data/init.rb +4 -4
- data/install.rb +2 -2
- data/lib/new_relic/agent/adaptive_sampler.rb +4 -4
- data/lib/new_relic/agent/agent/shutdown.rb +34 -0
- data/lib/new_relic/agent/agent/special_startup.rb +70 -0
- data/lib/new_relic/agent/agent/start_worker_thread.rb +163 -0
- data/lib/new_relic/agent/agent/startup.rb +196 -0
- data/lib/new_relic/agent/agent.rb +134 -534
- data/lib/new_relic/agent/agent_logger.rb +8 -10
- data/lib/new_relic/agent/attribute_filter.rb +40 -21
- data/lib/new_relic/agent/attribute_processing.rb +7 -7
- data/lib/new_relic/agent/attributes.rb +2 -2
- data/lib/new_relic/agent/audit_logger.rb +3 -3
- data/lib/new_relic/agent/autostart.rb +2 -2
- data/lib/new_relic/agent/chained_call.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command_router.rb +8 -8
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +1 -1
- data/lib/new_relic/agent/configuration/default_source.rb +105 -41
- data/lib/new_relic/agent/configuration/dotted_hash.rb +2 -2
- data/lib/new_relic/agent/configuration/environment_source.rb +5 -5
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +1 -1
- data/lib/new_relic/agent/configuration/high_security_source.rb +1 -1
- data/lib/new_relic/agent/configuration/manager.rb +5 -5
- data/lib/new_relic/agent/configuration/manual_source.rb +1 -1
- data/lib/new_relic/agent/configuration/mask_defaults.rb +3 -3
- data/lib/new_relic/agent/configuration/security_policy_source.rb +7 -4
- data/lib/new_relic/agent/configuration/server_source.rb +7 -7
- data/lib/new_relic/agent/configuration/yaml_source.rb +6 -4
- data/lib/new_relic/agent/configuration.rb +1 -1
- data/lib/new_relic/agent/connect/request_builder.rb +3 -3
- data/lib/new_relic/agent/connect/response_handler.rb +5 -5
- data/lib/new_relic/agent/custom_event_aggregator.rb +5 -5
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +1 -1
- data/lib/new_relic/agent/database/obfuscator.rb +2 -2
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +1 -1
- data/lib/new_relic/agent/database.rb +21 -21
- data/lib/new_relic/agent/database_adapter.rb +1 -1
- data/lib/new_relic/agent/datastores/metric_helper.rb +12 -13
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +4 -3
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +2 -4
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +2 -2
- data/lib/new_relic/agent/datastores/mongo.rb +1 -1
- data/lib/new_relic/agent/datastores/redis.rb +3 -3
- data/lib/new_relic/agent/datastores.rb +4 -4
- data/lib/new_relic/agent/deprecator.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +16 -17
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +9 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +18 -19
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +8 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +2 -3
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +40 -40
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +16 -15
- data/lib/new_relic/agent/distributed_tracing.rb +17 -18
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +6 -5
- data/lib/new_relic/agent/error_event_aggregator.rb +3 -4
- data/lib/new_relic/agent/error_filter.rb +5 -5
- data/lib/new_relic/agent/error_trace_aggregator.rb +3 -3
- data/lib/new_relic/agent/event_aggregator.rb +20 -20
- data/lib/new_relic/agent/event_buffer.rb +1 -1
- data/lib/new_relic/agent/event_listener.rb +1 -1
- data/lib/new_relic/agent/event_loop.rb +9 -9
- data/lib/new_relic/agent/external.rb +10 -10
- data/lib/new_relic/agent/guid_generator.rb +2 -2
- data/lib/new_relic/agent/harvester.rb +1 -1
- data/lib/new_relic/agent/heap.rb +5 -5
- data/lib/new_relic/agent/hostname.rb +4 -3
- data/lib/new_relic/agent/http_clients/abstract.rb +1 -2
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +5 -6
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -5
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +0 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/uri_util.rb +1 -2
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +6 -5
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +31 -23
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +7 -6
- data/lib/new_relic/agent/instrumentation/active_job.rb +11 -4
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +4 -3
- data/lib/new_relic/agent/instrumentation/active_record.rb +9 -9
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +37 -21
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +21 -11
- data/lib/new_relic/agent/instrumentation/active_storage.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +16 -15
- data/lib/new_relic/agent/instrumentation/active_support_logger/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +2 -2
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +2 -2
- data/lib/new_relic/agent/instrumentation/authlogic.rb +2 -2
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +10 -10
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +10 -11
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/bunny.rb +1 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +25 -17
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +21 -22
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +19 -16
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +2 -3
- data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +44 -44
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -2
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +2 -3
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +1 -2
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -3
- data/lib/new_relic/agent/instrumentation/excon.rb +2 -2
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +6 -6
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +97 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +89 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +111 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +30 -0
- data/lib/new_relic/agent/instrumentation/grpc/helper.rb +32 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/chain.rb +69 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +134 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/rpc_desc_prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/rpc_server_prepend.rb +26 -0
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +23 -0
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +25 -0
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httprb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -2
- data/lib/new_relic/agent/instrumentation/logger/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/logger/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/logger.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +24 -17
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +8 -9
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +17 -15
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +21 -15
- data/lib/new_relic/agent/instrumentation/memcache.rb +5 -6
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +0 -1
- data/lib/new_relic/agent/instrumentation/mongo.rb +2 -2
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +15 -14
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net_http.rb +2 -2
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +6 -6
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino.rb +2 -2
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -2
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +12 -12
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +7 -7
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -2
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rake.rb +3 -3
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +3 -4
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +5 -6
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +3 -4
- data/lib/new_relic/agent/instrumentation/redis.rb +2 -2
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sequel.rb +8 -8
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -5
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sunspot.rb +4 -4
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread.rb +2 -2
- data/lib/new_relic/agent/instrumentation/tilt/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +8 -8
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
- data/lib/new_relic/agent/instrumentation.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +8 -8
- data/lib/new_relic/agent/linking_metadata.rb +2 -3
- data/lib/new_relic/agent/local_log_decorator.rb +0 -1
- data/lib/new_relic/agent/log_event_aggregator.rb +7 -7
- data/lib/new_relic/agent/log_once.rb +1 -1
- data/lib/new_relic/agent/log_priority.rb +1 -1
- data/lib/new_relic/agent/logging.rb +13 -13
- data/lib/new_relic/agent/memory_logger.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +19 -20
- data/lib/new_relic/agent/method_tracer.rb +15 -10
- data/lib/new_relic/agent/method_tracer_helpers.rb +83 -1
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -4
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +3 -3
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +1 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +2 -2
- data/lib/new_relic/agent/monitors.rb +5 -5
- data/lib/new_relic/agent/new_relic_service/encoders.rb +2 -2
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +4 -4
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +1 -1
- data/lib/new_relic/agent/new_relic_service.rb +214 -166
- data/lib/new_relic/agent/{noticible_error.rb → noticeable_error.rb} +2 -3
- data/lib/new_relic/agent/null_logger.rb +1 -1
- data/lib/new_relic/agent/obfuscator.rb +3 -3
- data/lib/new_relic/agent/parameter_filtering.rb +1 -1
- data/lib/new_relic/agent/payload_metric_mapping.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +10 -5
- data/lib/new_relic/agent/pipe_service.rb +2 -2
- data/lib/new_relic/agent/prepend_supportability.rb +2 -2
- data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -4
- data/lib/new_relic/agent/range_extensions.rb +8 -28
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +2 -2
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -1
- data/lib/new_relic/agent/rules_engine.rb +2 -2
- data/lib/new_relic/agent/sampler.rb +1 -1
- data/lib/new_relic/agent/sampler_collection.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -2
- data/lib/new_relic/agent/samplers/memory_sampler.rb +10 -10
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/vm_sampler.rb +3 -1
- data/lib/new_relic/agent/span_event_aggregator.rb +2 -2
- data/lib/new_relic/agent/span_event_primitive.rb +24 -19
- data/lib/new_relic/agent/sql_sampler.rb +8 -8
- data/lib/new_relic/agent/stats.rb +15 -4
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -2
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -4
- data/lib/new_relic/agent/stats_engine.rb +1 -1
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +6 -6
- data/lib/new_relic/agent/system_info.rb +68 -53
- data/lib/new_relic/agent/threading/agent_thread.rb +13 -9
- data/lib/new_relic/agent/threading/backtrace_node.rb +6 -4
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
- data/lib/new_relic/agent/threading/thread_profile.rb +4 -4
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +19 -17
- data/lib/new_relic/agent/transaction/abstract_segment.rb +93 -34
- data/lib/new_relic/agent/transaction/datastore_segment.rb +12 -12
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +52 -48
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
- data/lib/new_relic/agent/transaction/external_request_segment.rb +37 -29
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +6 -6
- data/lib/new_relic/agent/transaction/request_attributes.rb +29 -29
- data/lib/new_relic/agent/transaction/segment.rb +8 -8
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/trace.rb +3 -3
- data/lib/new_relic/agent/transaction/trace_builder.rb +10 -10
- data/lib/new_relic/agent/transaction/trace_context.rb +22 -20
- data/lib/new_relic/agent/transaction/trace_node.rb +9 -9
- data/lib/new_relic/agent/transaction/tracing.rb +7 -7
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
- data/lib/new_relic/agent/transaction.rb +35 -31
- data/lib/new_relic/agent/transaction_error_primitive.rb +9 -9
- data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -5
- data/lib/new_relic/agent/transaction_event_primitive.rb +3 -4
- data/lib/new_relic/agent/transaction_event_recorder.rb +15 -14
- data/lib/new_relic/agent/transaction_metrics.rb +4 -4
- data/lib/new_relic/agent/transaction_sampler.rb +5 -5
- data/lib/new_relic/agent/transaction_time_aggregator.rb +14 -14
- data/lib/new_relic/agent/utilization/aws.rb +4 -4
- data/lib/new_relic/agent/utilization/azure.rb +2 -2
- data/lib/new_relic/agent/utilization/gcp.rb +7 -7
- data/lib/new_relic/agent/utilization/pcf.rb +4 -4
- data/lib/new_relic/agent/utilization/vendor.rb +28 -28
- data/lib/new_relic/agent/utilization_data.rb +1 -1
- data/lib/new_relic/agent/vm/jruby_vm.rb +1 -1
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +36 -23
- data/lib/new_relic/agent/vm/snapshot.rb +2 -2
- data/lib/new_relic/agent/vm.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +2 -2
- data/lib/new_relic/agent.rb +27 -27
- data/lib/new_relic/cli/command.rb +6 -6
- data/lib/new_relic/cli/commands/deployments.rb +81 -29
- data/lib/new_relic/cli/commands/install.rb +6 -6
- data/lib/new_relic/coerce.rb +5 -6
- data/lib/new_relic/collection_helper.rb +4 -4
- data/lib/new_relic/constants.rb +0 -1
- data/lib/new_relic/control/class_methods.rb +1 -1
- data/lib/new_relic/control/frameworks/external.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +3 -3
- data/lib/new_relic/control/frameworks/rails3.rb +1 -1
- data/lib/new_relic/control/frameworks/rails4.rb +1 -1
- data/lib/new_relic/control/frameworks/rails_notifications.rb +1 -1
- data/lib/new_relic/control/frameworks/ruby.rb +1 -1
- data/lib/new_relic/control/frameworks/sinatra.rb +1 -1
- data/lib/new_relic/control/frameworks.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +20 -42
- data/lib/new_relic/control/instrumentation.rb +7 -7
- data/lib/new_relic/control/private_instance_methods.rb +48 -0
- data/lib/new_relic/control/server_methods.rb +2 -2
- data/lib/new_relic/control.rb +1 -1
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +23 -22
- data/lib/new_relic/environment_report.rb +24 -14
- data/lib/new_relic/helper.rb +5 -5
- data/lib/new_relic/language_support.rb +8 -3
- data/lib/new_relic/latest_changes.rb +4 -4
- data/lib/new_relic/local_environment.rb +9 -11
- data/lib/new_relic/metric_data.rb +30 -24
- data/lib/new_relic/metric_spec.rb +3 -3
- data/lib/new_relic/noticed_error.rb +3 -6
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +1 -1
- data/lib/new_relic/rack/browser_monitoring.rb +132 -123
- data/lib/new_relic/rack.rb +1 -1
- data/lib/new_relic/recipes/capistrano3.rb +3 -59
- data/lib/new_relic/recipes/capistrano_legacy.rb +13 -13
- data/lib/new_relic/recipes/helpers/send_deployment.rb +69 -0
- data/lib/new_relic/recipes.rb +1 -1
- data/lib/new_relic/supportability_helper.rb +6 -6
- data/lib/new_relic/traced_thread.rb +5 -7
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +8 -8
- data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
- data/lib/tasks/all.rb +1 -1
- data/lib/tasks/config.rake +8 -112
- data/lib/tasks/coverage_report.rake +28 -0
- data/lib/tasks/{config.html.erb → helpers/config.html.erb} +0 -0
- data/lib/tasks/{config.text.erb → helpers/config.text.erb} +0 -0
- data/lib/tasks/helpers/format.rb +120 -0
- data/lib/tasks/helpers/matches.rb +12 -0
- data/lib/tasks/helpers/prompt.rb +24 -0
- data/lib/tasks/helpers/removers.rb +33 -0
- data/lib/tasks/install.rake +4 -0
- data/lib/tasks/instrumentation_generator/README.md +63 -0
- data/lib/tasks/instrumentation_generator/TODO.md +33 -0
- data/lib/tasks/instrumentation_generator/instrumentation.thor +102 -0
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +9 -0
- data/lib/tasks/instrumentation_generator/templates/chain.tt +21 -0
- data/lib/tasks/instrumentation_generator/templates/chain_method.tt +7 -0
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +29 -0
- data/lib/tasks/instrumentation_generator/templates/instrumentation.tt +12 -0
- data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +3 -0
- data/lib/tasks/instrumentation_generator/templates/newrelic.yml.tt +19 -0
- data/lib/tasks/instrumentation_generator/templates/prepend.tt +13 -0
- data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +3 -0
- data/lib/tasks/instrumentation_generator/templates/test.tt +15 -0
- data/lib/tasks/multiverse.rake +4 -0
- data/lib/tasks/multiverse.rb +5 -30
- data/lib/tasks/newrelic.rb +1 -1
- data/lib/tasks/tests.rake +7 -8
- data/newrelic.yml +514 -483
- data/newrelic_rpm.gemspec +16 -21
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +125 -147
- metadata +82 -90
- data/bin/mongrel_rpm +0 -32
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/range_extensions'
|
6
6
|
require 'new_relic/agent/guid_generator'
|
@@ -9,9 +9,9 @@ module NewRelic
|
|
9
9
|
module Agent
|
10
10
|
class Transaction
|
11
11
|
class AbstractSegment
|
12
|
-
# This class is the base class for all segments. It is
|
12
|
+
# This class is the base class for all segments. It is responsible for
|
13
13
|
# timing, naming, and defining lifecycle callbacks. One of the more
|
14
|
-
# complex
|
14
|
+
# complex responsibilities of this class is computing exclusive duration.
|
15
15
|
# One of the reasons for this complexity is that exclusive time will be
|
16
16
|
# computed using time ranges or by recording an aggregate value for
|
17
17
|
# a segments children time. The reason for this is that computing
|
@@ -25,7 +25,7 @@ module NewRelic
|
|
25
25
|
attr_writer :record_metrics, :record_scoped_metric, :record_on_finish
|
26
26
|
attr_reader :noticed_error
|
27
27
|
|
28
|
-
def initialize
|
28
|
+
def initialize(name = nil, start_time = nil)
|
29
29
|
@name = name
|
30
30
|
@starting_thread_id = ::Thread.current.object_id
|
31
31
|
@transaction_name = nil
|
@@ -37,8 +37,8 @@ module NewRelic
|
|
37
37
|
@end_time = nil
|
38
38
|
@duration = 0.0
|
39
39
|
@exclusive_duration = 0.0
|
40
|
+
@children_timings = []
|
40
41
|
@children_time = 0.0
|
41
|
-
@children_time_ranges = nil
|
42
42
|
@active_children = 0
|
43
43
|
@range_recorded = false
|
44
44
|
@concurrent_children = false
|
@@ -46,22 +46,27 @@ module NewRelic
|
|
46
46
|
@record_scoped_metric = true
|
47
47
|
@record_on_finish = false
|
48
48
|
@noticed_error = nil
|
49
|
+
@code_filepath = nil
|
50
|
+
@code_function = nil
|
51
|
+
@code_lineno = nil
|
52
|
+
@code_namespace = nil
|
49
53
|
end
|
50
54
|
|
51
55
|
def start
|
52
56
|
@start_time ||= Process.clock_gettime(Process::CLOCK_REALTIME)
|
53
57
|
return unless transaction
|
54
|
-
parent.child_start
|
58
|
+
parent.child_start(self) if parent
|
55
59
|
end
|
56
60
|
|
57
61
|
def finish
|
58
62
|
@end_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
59
63
|
@duration = end_time - start_time
|
64
|
+
|
60
65
|
return unless transaction
|
61
66
|
run_complete_callbacks
|
62
67
|
finalize if record_on_finish?
|
63
68
|
rescue => e
|
64
|
-
NewRelic::Agent.logger.error
|
69
|
+
NewRelic::Agent.logger.error("Exception finishing segment: #{name}", e)
|
65
70
|
end
|
66
71
|
|
67
72
|
def finished?
|
@@ -98,18 +103,68 @@ module NewRelic
|
|
98
103
|
@start_time.to_f..@end_time.to_f
|
99
104
|
end
|
100
105
|
|
106
|
+
def timings_overlap?(timing1, timing2)
|
107
|
+
(timing1.first >= timing2.first && timing1.first <= timing2.last) ||
|
108
|
+
(timing2.first >= timing1.first && timing2.first <= timing1.last)
|
109
|
+
end
|
110
|
+
|
111
|
+
def merge_timings(timing1, timing2)
|
112
|
+
[(timing1.first < timing2.first ? timing1.first : timing2.first),
|
113
|
+
(timing1.last > timing2.last ? timing1.last : timing2.last)]
|
114
|
+
end
|
115
|
+
|
116
|
+
# @children_timings is an array of array, with each inner array
|
117
|
+
# holding exactly 2 values, a child segment's start time and finish
|
118
|
+
# time (in that order). When it's time to record, these timings are
|
119
|
+
# converted into an array of range objects (using the same start and
|
120
|
+
# end values as the original array). Any two range objects that
|
121
|
+
# intersect and merged into a larger range. This checking for a
|
122
|
+
# intersections and merging of ranges is expensive, so the operation
|
123
|
+
# is only done at recording time.
|
101
124
|
def children_time_ranges
|
102
|
-
@children_time_ranges ||=
|
125
|
+
@children_time_ranges ||= begin
|
126
|
+
overlapped = @children_timings.each_with_object([]) do |timing, timings|
|
127
|
+
i = timings.index { |t| timings_overlap?(t, timing) }
|
128
|
+
if i
|
129
|
+
timings[i] = merge_timings(timing, timings[i])
|
130
|
+
else
|
131
|
+
timings << timing
|
132
|
+
end
|
133
|
+
end
|
134
|
+
overlapped.map { |t| Range.new(t.first, t.last) }
|
135
|
+
end
|
103
136
|
end
|
104
137
|
|
105
138
|
def children_time_ranges?
|
106
|
-
|
139
|
+
!@children_timings.empty?
|
107
140
|
end
|
108
141
|
|
109
142
|
def concurrent_children?
|
110
143
|
@concurrent_children
|
111
144
|
end
|
112
145
|
|
146
|
+
def code_information=(info = {})
|
147
|
+
return unless info[:filepath]
|
148
|
+
|
149
|
+
@code_filepath = info[:filepath]
|
150
|
+
@code_function = info[:function]
|
151
|
+
@code_lineno = info[:lineno]
|
152
|
+
@code_namespace = info[:namespace]
|
153
|
+
end
|
154
|
+
|
155
|
+
def all_code_information_present?
|
156
|
+
@code_filepath && @code_function && @code_lineno && @code_namespace
|
157
|
+
end
|
158
|
+
|
159
|
+
def code_attributes
|
160
|
+
return ::NewRelic::EMPTY_HASH unless all_code_information_present?
|
161
|
+
|
162
|
+
@code_attributes ||= {'code.filepath' => @code_filepath,
|
163
|
+
'code.function' => @code_function,
|
164
|
+
'code.lineno' => @code_lineno,
|
165
|
+
'code.namespace' => @code_namespace}
|
166
|
+
end
|
167
|
+
|
113
168
|
INSPECT_IGNORE = [:@transaction, :@transaction_state].freeze
|
114
169
|
|
115
170
|
def inspect
|
@@ -123,22 +178,24 @@ module NewRelic
|
|
123
178
|
def transaction_assigned
|
124
179
|
end
|
125
180
|
|
126
|
-
def set_noticed_error
|
181
|
+
def set_noticed_error(noticed_error)
|
127
182
|
if @noticed_error
|
128
|
-
NewRelic::Agent.logger.debug \
|
183
|
+
NewRelic::Agent.logger.debug( \
|
129
184
|
"Segment: #{name} overwriting previously noticed " \
|
130
185
|
"error: #{@noticed_error.inspect} with: #{noticed_error.inspect}"
|
186
|
+
)
|
131
187
|
end
|
132
188
|
@noticed_error = noticed_error
|
133
189
|
end
|
134
190
|
|
135
|
-
def notice_error
|
191
|
+
def notice_error(exception, options = {})
|
136
192
|
if Agent.config[:high_security]
|
137
|
-
NewRelic::Agent.logger.debug \
|
193
|
+
NewRelic::Agent.logger.debug( \
|
138
194
|
"Segment: #{name} ignores notice_error for " \
|
139
195
|
"error: #{exception.inspect} because :high_security is enabled"
|
196
|
+
)
|
140
197
|
else
|
141
|
-
NewRelic::Agent.instance.error_collector.notice_segment_error
|
198
|
+
NewRelic::Agent.instance.error_collector.notice_segment_error(self, exception, options)
|
142
199
|
end
|
143
200
|
end
|
144
201
|
|
@@ -155,16 +212,16 @@ module NewRelic
|
|
155
212
|
@range_recorded
|
156
213
|
end
|
157
214
|
|
158
|
-
def child_start
|
215
|
+
def child_start(segment)
|
159
216
|
@active_children += 1
|
160
217
|
@concurrent_children ||= @active_children > 1
|
161
218
|
|
162
219
|
transaction.async = true if @concurrent_children
|
163
220
|
end
|
164
221
|
|
165
|
-
def child_complete
|
222
|
+
def child_complete(segment)
|
166
223
|
@active_children -= 1
|
167
|
-
record_child_time
|
224
|
+
record_child_time(segment)
|
168
225
|
|
169
226
|
if finished?
|
170
227
|
transaction.async = true
|
@@ -178,36 +235,39 @@ module NewRelic
|
|
178
235
|
# an ancestor whose end time is greater than or equal to the descendant's
|
179
236
|
# we can stop the propagation. We pass along the direct child so we can
|
180
237
|
# make any corrections needed for exclusive time calculation.
|
238
|
+
def descendant_complete(child, descendant)
|
239
|
+
add_child_timing(descendant)
|
181
240
|
|
182
|
-
def descendant_complete child, descendant
|
183
|
-
RangeExtensions.merge_or_append descendant.time_range,
|
184
|
-
children_time_ranges
|
185
241
|
# If this child's time was previously added to this segment's
|
186
242
|
# aggregate children time, we need to re-record it using a time range
|
187
243
|
# for proper exclusive time calculation
|
188
244
|
unless child.range_recorded?
|
189
245
|
self.children_time -= child.duration
|
190
|
-
record_child_time_as_range
|
246
|
+
record_child_time_as_range(child)
|
191
247
|
end
|
192
248
|
|
193
249
|
if parent && finished? && descendant.end_time >= end_time
|
194
|
-
parent.descendant_complete
|
250
|
+
parent.descendant_complete(self, descendant)
|
195
251
|
end
|
196
252
|
end
|
197
253
|
|
198
254
|
private
|
199
255
|
|
256
|
+
def add_child_timing(segment)
|
257
|
+
@children_timings << [segment.start_time, segment.end_time]
|
258
|
+
end
|
259
|
+
|
200
260
|
def force_finish
|
201
261
|
finish
|
202
|
-
NewRelic::Agent.logger.warn
|
262
|
+
NewRelic::Agent.logger.warn("Segment: #{name} was unfinished at " \
|
203
263
|
"the end of transaction. Timing information for this segment's" \
|
204
|
-
"parent #{parent.name} in #{transaction.best_name} may be inaccurate."
|
264
|
+
"parent #{parent.name} in #{transaction.best_name} may be inaccurate.")
|
205
265
|
end
|
206
266
|
|
207
267
|
def run_complete_callbacks
|
208
268
|
segment_complete
|
209
|
-
parent.child_complete
|
210
|
-
transaction.segment_complete
|
269
|
+
parent.child_complete(self) if parent
|
270
|
+
transaction.segment_complete(self)
|
211
271
|
end
|
212
272
|
|
213
273
|
def record_metrics
|
@@ -218,27 +278,26 @@ module NewRelic
|
|
218
278
|
def segment_complete
|
219
279
|
end
|
220
280
|
|
221
|
-
def record_child_time
|
281
|
+
def record_child_time(child)
|
222
282
|
if concurrent_children? || finished? && end_time < child.end_time
|
223
|
-
record_child_time_as_range
|
283
|
+
record_child_time_as_range(child)
|
224
284
|
else
|
225
|
-
record_child_time_as_number
|
285
|
+
record_child_time_as_number(child)
|
226
286
|
end
|
227
287
|
end
|
228
288
|
|
229
|
-
def record_child_time_as_range
|
230
|
-
|
231
|
-
children_time_ranges
|
289
|
+
def record_child_time_as_range(child)
|
290
|
+
add_child_timing(child)
|
232
291
|
child.range_recorded = true
|
233
292
|
end
|
234
293
|
|
235
|
-
def record_child_time_as_number
|
294
|
+
def record_child_time_as_number(child)
|
236
295
|
self.children_time += child.duration
|
237
296
|
end
|
238
297
|
|
239
298
|
def record_exclusive_duration
|
240
299
|
overlapping_duration = if children_time_ranges?
|
241
|
-
RangeExtensions.compute_overlap
|
300
|
+
RangeExtensions.compute_overlap(time_range, children_time_ranges)
|
242
301
|
else
|
243
302
|
0.0
|
244
303
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/transaction/segment'
|
6
6
|
require 'new_relic/agent/datastores/metric_helper'
|
@@ -16,26 +16,26 @@ module NewRelic
|
|
16
16
|
attr_reader :product, :operation, :collection, :sql_statement, :nosql_statement, :host, :port_path_or_id
|
17
17
|
attr_accessor :database_name, :record_sql
|
18
18
|
|
19
|
-
def initialize
|
19
|
+
def initialize(product, operation, collection = nil, host = nil, port_path_or_id = nil, database_name = nil, start_time = nil)
|
20
20
|
@product = product
|
21
21
|
@operation = operation
|
22
22
|
@collection = collection
|
23
23
|
@sql_statement = nil
|
24
24
|
@nosql_statement = nil
|
25
25
|
@record_sql = true
|
26
|
-
set_instance_info
|
26
|
+
set_instance_info(host, port_path_or_id)
|
27
27
|
@database_name = database_name ? database_name.to_s : nil
|
28
|
-
super
|
28
|
+
super(Datastores::MetricHelper.scoped_metric_for(product, operation, collection),
|
29
29
|
nil,
|
30
|
-
start_time
|
30
|
+
start_time)
|
31
31
|
end
|
32
32
|
|
33
|
-
def set_instance_info
|
33
|
+
def set_instance_info(host = nil, port_path_or_id = nil)
|
34
34
|
port_path_or_id = port_path_or_id.to_s if port_path_or_id
|
35
35
|
host_present = host && !host.empty?
|
36
36
|
ppi_present = port_path_or_id && !port_path_or_id.empty?
|
37
37
|
|
38
|
-
host = NewRelic::Agent::Hostname.get_external
|
38
|
+
host = NewRelic::Agent::Hostname.get_external(host) if host_present
|
39
39
|
|
40
40
|
case
|
41
41
|
when host_present && ppi_present
|
@@ -55,15 +55,15 @@ module NewRelic
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def notice_sql
|
59
|
-
_notice_sql
|
58
|
+
def notice_sql(sql)
|
59
|
+
_notice_sql(sql)
|
60
60
|
nil
|
61
61
|
end
|
62
62
|
|
63
63
|
# @api private
|
64
|
-
def _notice_sql
|
64
|
+
def _notice_sql(sql, config = nil, explainer = nil, binds = nil, name = nil)
|
65
65
|
return unless record_sql?
|
66
|
-
@sql_statement = Database::Statement.new
|
66
|
+
@sql_statement = Database::Statement.new(sql, config, explainer, binds, name, host, port_path_or_id, database_name)
|
67
67
|
end
|
68
68
|
|
69
69
|
# Method for simplifying attaching non-SQL data statements to a
|
@@ -83,7 +83,7 @@ module NewRelic
|
|
83
83
|
# please ensure all data passed to this method is safe to transmit to
|
84
84
|
# New Relic.
|
85
85
|
|
86
|
-
def notice_nosql_statement
|
86
|
+
def notice_nosql_statement(nosql_statement)
|
87
87
|
return unless record_sql?
|
88
88
|
@nosql_statement = Database.truncate_query(nosql_statement)
|
89
89
|
nil
|
@@ -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
|
@@ -26,12 +25,12 @@ module NewRelic
|
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
|
-
def accept_incoming_request
|
30
|
-
accept_incoming_transport_type
|
31
|
-
if trace_parent_header_present?
|
32
|
-
accept_trace_context_incoming_request
|
28
|
+
def accept_incoming_request(request, transport_type = nil)
|
29
|
+
accept_incoming_transport_type(request, transport_type)
|
30
|
+
if trace_parent_header_present?(request)
|
31
|
+
accept_trace_context_incoming_request(request)
|
33
32
|
else
|
34
|
-
accept_distributed_tracing_incoming_request
|
33
|
+
accept_distributed_tracing_incoming_request(request)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -39,84 +38,89 @@ module NewRelic
|
|
39
38
|
@caller_transport_type ||= "Unknown"
|
40
39
|
end
|
41
40
|
|
42
|
-
def accept_transport_type_from_api
|
43
|
-
@caller_transport_type = DistributedTraceTransportType.from
|
41
|
+
def accept_transport_type_from_api(value)
|
42
|
+
@caller_transport_type = DistributedTraceTransportType.from(value)
|
44
43
|
end
|
45
44
|
|
46
|
-
def accept_incoming_transport_type
|
45
|
+
def accept_incoming_transport_type(request, transport_type)
|
47
46
|
if transport_type.to_s == NewRelic::EMPTY_STR
|
48
|
-
@caller_transport_type = DistributedTraceTransportType.for_rack_request
|
47
|
+
@caller_transport_type = DistributedTraceTransportType.for_rack_request(request)
|
49
48
|
else
|
50
|
-
@caller_transport_type = DistributedTraceTransportType.from
|
49
|
+
@caller_transport_type = DistributedTraceTransportType.from(transport_type)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
|
-
def initialize
|
53
|
+
def initialize(transaction)
|
55
54
|
@transaction = transaction
|
56
55
|
end
|
57
56
|
|
58
57
|
def record_metrics
|
59
58
|
record_cross_app_metrics
|
60
|
-
DistributedTraceMetrics.record_metrics_for_transaction
|
59
|
+
DistributedTraceMetrics.record_metrics_for_transaction(transaction)
|
61
60
|
end
|
62
61
|
|
63
|
-
def append_payload
|
64
|
-
append_cat_info
|
65
|
-
DistributedTraceAttributes.copy_from_transaction \
|
62
|
+
def append_payload(payload)
|
63
|
+
append_cat_info(payload)
|
64
|
+
DistributedTraceAttributes.copy_from_transaction( \
|
66
65
|
transaction,
|
67
66
|
trace_state_payload || distributed_trace_payload,
|
68
67
|
payload
|
68
|
+
)
|
69
69
|
end
|
70
70
|
|
71
|
-
def log_request_headers
|
72
|
-
NewRelic::Agent.logger.debug
|
71
|
+
def log_request_headers(headers, direction = "OUTGOING")
|
72
|
+
NewRelic::Agent.logger.debug("#{direction} REQUEST HEADERS: #{headers}")
|
73
73
|
end
|
74
74
|
|
75
|
-
def insert_headers
|
75
|
+
def insert_headers(headers)
|
76
76
|
return unless NewRelic::Agent.agent.connected?
|
77
|
-
insert_trace_context_header
|
78
|
-
insert_distributed_trace_header
|
79
|
-
insert_cross_app_header
|
80
|
-
log_request_headers
|
77
|
+
insert_trace_context_header(headers)
|
78
|
+
insert_distributed_trace_header(headers)
|
79
|
+
insert_cross_app_header(headers)
|
80
|
+
log_request_headers(headers)
|
81
81
|
end
|
82
82
|
|
83
|
-
def consume_message_headers
|
84
|
-
log_request_headers
|
85
|
-
consume_message_distributed_tracing_headers
|
86
|
-
consume_message_cross_app_tracing_headers
|
87
|
-
consume_message_synthetics_headers
|
83
|
+
def consume_message_headers(headers, tracer_state, transport_type)
|
84
|
+
log_request_headers(headers, "INCOMING")
|
85
|
+
consume_message_distributed_tracing_headers(headers, transport_type)
|
86
|
+
consume_message_cross_app_tracing_headers(headers, tracer_state)
|
87
|
+
consume_message_synthetics_headers(headers)
|
88
88
|
rescue => e
|
89
|
-
NewRelic::Agent.logger.error
|
89
|
+
NewRelic::Agent.logger.error("Error in consume_message_headers", e)
|
90
90
|
end
|
91
91
|
|
92
92
|
def assign_intrinsics
|
93
|
-
if
|
94
|
-
DistributedTraceAttributes.copy_to_attributes
|
93
|
+
if dt_enabled?
|
94
|
+
DistributedTraceAttributes.copy_to_attributes(transaction.payload, transaction.attributes)
|
95
95
|
elsif is_cross_app?
|
96
96
|
assign_cross_app_intrinsics
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
def insert_distributed_trace_header
|
101
|
-
return unless
|
100
|
+
def insert_distributed_trace_header(headers)
|
101
|
+
return unless dt_enabled?
|
102
102
|
return if Agent.config[:'exclude_newrelic_header']
|
103
103
|
payload = create_distributed_trace_payload
|
104
104
|
headers[NewRelic::NEWRELIC_KEY] = payload.http_safe if payload
|
105
105
|
end
|
106
106
|
|
107
|
-
def insert_cat_headers
|
107
|
+
def insert_cat_headers(headers)
|
108
108
|
return unless CrossAppTracing.cross_app_enabled?
|
109
109
|
@is_cross_app_caller = true
|
110
|
-
insert_message_headers
|
110
|
+
insert_message_headers(headers,
|
111
111
|
transaction.guid,
|
112
112
|
cat_trip_id,
|
113
113
|
cat_path_hash,
|
114
|
-
transaction.raw_synthetics_header
|
114
|
+
transaction.raw_synthetics_header)
|
115
115
|
end
|
116
116
|
|
117
117
|
private
|
118
118
|
|
119
|
-
def
|
119
|
+
def dt_enabled?
|
120
|
+
Agent.config[:'distributed_tracing.enabled']
|
121
|
+
end
|
122
|
+
|
123
|
+
def consume_message_synthetics_headers(headers)
|
120
124
|
synthetics_header = headers[CrossAppTracing::NR_MESSAGE_BROKER_SYNTHETICS_HEADER]
|
121
125
|
if synthetics_header and
|
122
126
|
incoming_payload = ::JSON.load(deobfuscate(synthetics_header)) and
|
@@ -128,31 +132,31 @@ module NewRelic
|
|
128
132
|
transaction.synthetics_payload = incoming_payload
|
129
133
|
end
|
130
134
|
rescue => e
|
131
|
-
NewRelic::Agent.logger.error
|
135
|
+
NewRelic::Agent.logger.error("Error in consume_message_synthetics_header", e)
|
132
136
|
end
|
133
137
|
|
134
|
-
def consume_message_distributed_tracing_headers
|
135
|
-
return unless
|
138
|
+
def consume_message_distributed_tracing_headers(headers, transport_type)
|
139
|
+
return unless dt_enabled?
|
136
140
|
|
137
|
-
accept_incoming_transport_type
|
141
|
+
accept_incoming_transport_type(headers, transport_type)
|
138
142
|
|
139
143
|
newrelic_trace_key = NewRelic::CANDIDATE_NEWRELIC_KEYS.detect do |key|
|
140
144
|
headers.has_key?(key)
|
141
145
|
end
|
142
146
|
return unless newrelic_trace_key && (payload = headers[newrelic_trace_key])
|
143
147
|
|
144
|
-
accept_distributed_trace_payload
|
148
|
+
accept_distributed_trace_payload(payload)
|
145
149
|
end
|
146
150
|
|
147
|
-
def consume_message_cross_app_tracing_headers
|
151
|
+
def consume_message_cross_app_tracing_headers(headers, tracer_state)
|
148
152
|
return unless CrossAppTracing.cross_app_enabled?
|
149
153
|
return unless CrossAppTracing.message_has_crossapp_request_header?(headers)
|
150
154
|
|
151
|
-
accept_cross_app_payload
|
152
|
-
CrossAppTracing.assign_intrinsic_transaction_attributes
|
155
|
+
accept_cross_app_payload(headers, tracer_state)
|
156
|
+
CrossAppTracing.assign_intrinsic_transaction_attributes(tracer_state)
|
153
157
|
end
|
154
158
|
|
155
|
-
def accept_cross_app_payload
|
159
|
+
def accept_cross_app_payload(headers, tracer_state)
|
156
160
|
encoded_id = headers[CrossAppTracing::NR_MESSAGE_BROKER_ID_HEADER]
|
157
161
|
decoded_id = encoded_id.nil? ? EMPTY_STRING : deobfuscate(encoded_id)
|
158
162
|
|
@@ -167,8 +171,8 @@ module NewRelic
|
|
167
171
|
nil
|
168
172
|
end
|
169
173
|
|
170
|
-
def deobfuscate
|
171
|
-
CrossAppTracing.obfuscator.deobfuscate
|
174
|
+
def deobfuscate(message)
|
175
|
+
CrossAppTracing.obfuscator.deobfuscate(message)
|
172
176
|
end
|
173
177
|
end
|
174
178
|
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
|
@@ -36,11 +35,11 @@ module NewRelic
|
|
36
35
|
|
37
36
|
NEWRELIC_TRACE_KEY = "HTTP_NEWRELIC"
|
38
37
|
|
39
|
-
def accept_distributed_tracing_incoming_request
|
38
|
+
def accept_distributed_tracing_incoming_request(request)
|
40
39
|
return unless Agent.config[:'distributed_tracing.enabled']
|
41
40
|
return unless payload = request[NEWRELIC_TRACE_KEY]
|
42
41
|
|
43
|
-
accept_distributed_trace_payload
|
42
|
+
accept_distributed_trace_payload(payload)
|
44
43
|
end
|
45
44
|
|
46
45
|
def distributed_trace_payload_created?
|
@@ -51,16 +50,16 @@ module NewRelic
|
|
51
50
|
return unless Agent.config[:'distributed_tracing.enabled']
|
52
51
|
|
53
52
|
@distributed_trace_payload_created = true
|
54
|
-
payload = DistributedTracePayload.for_transaction
|
55
|
-
NewRelic::Agent.increment_metric
|
53
|
+
payload = DistributedTracePayload.for_transaction(transaction)
|
54
|
+
NewRelic::Agent.increment_metric(CREATE_SUCCESS_METRIC)
|
56
55
|
payload
|
57
56
|
rescue => e
|
58
|
-
NewRelic::Agent.increment_metric
|
59
|
-
NewRelic::Agent.logger.warn
|
57
|
+
NewRelic::Agent.increment_metric(CREATE_EXCEPTION_METRIC)
|
58
|
+
NewRelic::Agent.logger.warn("Failed to create distributed trace payload", e)
|
60
59
|
nil
|
61
60
|
end
|
62
61
|
|
63
|
-
def accept_distributed_trace_payload
|
62
|
+
def accept_distributed_trace_payload(payload)
|
64
63
|
return unless Agent.config[:'distributed_tracing.enabled']
|
65
64
|
|
66
65
|
return false if check_payload_ignored(payload)
|
@@ -72,11 +71,11 @@ module NewRelic
|
|
72
71
|
|
73
72
|
assign_payload_and_sampling_params(payload)
|
74
73
|
|
75
|
-
NewRelic::Agent.increment_metric
|
74
|
+
NewRelic::Agent.increment_metric(ACCEPT_SUCCESS_METRIC)
|
76
75
|
true
|
77
76
|
rescue => e
|
78
|
-
NewRelic::Agent.increment_metric
|
79
|
-
NewRelic::Agent.logger.warn
|
77
|
+
NewRelic::Agent.increment_metric(ACCEPT_EXCEPTION_METRIC)
|
78
|
+
NewRelic::Agent.logger.warn("Failed to accept distributed trace payload", e)
|
80
79
|
false
|
81
80
|
end
|
82
81
|
|
@@ -84,10 +83,10 @@ module NewRelic
|
|
84
83
|
|
85
84
|
def check_payload_ignored(payload)
|
86
85
|
if distributed_trace_payload
|
87
|
-
NewRelic::Agent.increment_metric
|
86
|
+
NewRelic::Agent.increment_metric(IGNORE_MULTIPLE_ACCEPT_METRIC)
|
88
87
|
return true
|
89
88
|
elsif distributed_trace_payload_created?
|
90
|
-
NewRelic::Agent.increment_metric
|
89
|
+
NewRelic::Agent.increment_metric(IGNORE_ACCEPT_AFTER_CREATE_METRIC)
|
91
90
|
return true
|
92
91
|
end
|
93
92
|
false
|
@@ -96,7 +95,7 @@ module NewRelic
|
|
96
95
|
def check_payload_present(payload)
|
97
96
|
# We might be passed a Ruby `nil` object _or_ the JSON "null"
|
98
97
|
if payload.nil? || payload == NULL_PAYLOAD
|
99
|
-
NewRelic::Agent.increment_metric
|
98
|
+
NewRelic::Agent.increment_metric(IGNORE_ACCEPT_NULL_METRIC)
|
100
99
|
return nil
|
101
100
|
end
|
102
101
|
|
@@ -104,18 +103,18 @@ module NewRelic
|
|
104
103
|
end
|
105
104
|
|
106
105
|
def decode_payload(payload)
|
107
|
-
decoded = if payload.start_with?
|
108
|
-
DistributedTracePayload.from_json
|
106
|
+
decoded = if payload.start_with?(LBRACE)
|
107
|
+
DistributedTracePayload.from_json(payload)
|
109
108
|
else
|
110
|
-
DistributedTracePayload.from_http_safe
|
109
|
+
DistributedTracePayload.from_http_safe(payload)
|
111
110
|
end
|
112
111
|
|
113
112
|
return nil unless check_payload_present(decoded)
|
114
113
|
|
115
114
|
decoded
|
116
115
|
rescue => e
|
117
|
-
NewRelic::Agent.increment_metric
|
118
|
-
NewRelic::Agent.logger.warn
|
116
|
+
NewRelic::Agent.increment_metric(ACCEPT_PARSE_EXCEPTION_METRIC)
|
117
|
+
NewRelic::Agent.logger.warn("Error parsing distributed trace payload", e)
|
119
118
|
nil
|
120
119
|
end
|
121
120
|
|
@@ -131,7 +130,7 @@ module NewRelic
|
|
131
130
|
|
132
131
|
true
|
133
132
|
else
|
134
|
-
NewRelic::Agent.increment_metric
|
133
|
+
NewRelic::Agent.increment_metric(ACCEPT_PARSE_EXCEPTION_METRIC)
|
135
134
|
false
|
136
135
|
end
|
137
136
|
end
|
@@ -140,7 +139,7 @@ module NewRelic
|
|
140
139
|
if DistributedTracePayload.major_version_matches?(payload)
|
141
140
|
true
|
142
141
|
else
|
143
|
-
NewRelic::Agent.increment_metric
|
142
|
+
NewRelic::Agent.increment_metric(IGNORE_ACCEPT_MAJOR_VERSION_METRIC)
|
144
143
|
false
|
145
144
|
end
|
146
145
|
end
|
@@ -148,7 +147,7 @@ module NewRelic
|
|
148
147
|
def check_trusted_account(payload)
|
149
148
|
compare_key = payload.trusted_account_key || payload.parent_account_id
|
150
149
|
unless compare_key == NewRelic::Agent.config[:trusted_account_key]
|
151
|
-
NewRelic::Agent.increment_metric
|
150
|
+
NewRelic::Agent.increment_metric(IGNORE_ACCEPT_UNTRUSTED_ACCOUNT_METRIC)
|
152
151
|
return false
|
153
152
|
end
|
154
153
|
true
|