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
|
# This module is intended to provide access to information about the host OS and
|
6
6
|
# [virtual] machine. It intentionally does no caching and maintains no state -
|
@@ -39,54 +39,69 @@ module NewRelic
|
|
39
39
|
@processor_info = nil
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.
|
43
|
-
if @processor_info
|
44
|
-
if darwin?
|
45
|
-
@processor_info = {
|
46
|
-
:num_physical_packages => sysctl_value('hw.packages').to_i,
|
47
|
-
:num_physical_cores => sysctl_value('hw.physicalcpu_max').to_i,
|
48
|
-
:num_logical_processors => sysctl_value('hw.logicalcpu_max').to_i
|
49
|
-
}
|
50
|
-
# in case those don't work, try backup values
|
51
|
-
if @processor_info[:num_physical_cores] <= 0
|
52
|
-
@processor_info[:num_physical_cores] = sysctl_value('hw.physicalcpu').to_i
|
53
|
-
end
|
54
|
-
if @processor_info[:num_logical_processors] <= 0
|
55
|
-
@processor_info[:num_logical_processors] = sysctl_value('hw.logicalcpu').to_i
|
56
|
-
end
|
57
|
-
if @processor_info[:num_logical_processors] <= 0
|
58
|
-
@processor_info[:num_logical_processors] = sysctl_value('hw.ncpu').to_i
|
59
|
-
end
|
60
|
-
|
61
|
-
elsif linux?
|
62
|
-
cpuinfo = proc_try_read('/proc/cpuinfo')
|
63
|
-
@processor_info = cpuinfo ? parse_cpuinfo(cpuinfo) : {}
|
42
|
+
def self.processor_info
|
43
|
+
return @processor_info if @processor_info
|
64
44
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# give nils for obviously wrong values
|
74
|
-
@processor_info.keys.each do |key|
|
75
|
-
value = @processor_info[key]
|
76
|
-
if value.is_a?(Numeric) && value <= 0
|
77
|
-
@processor_info[key] = nil
|
78
|
-
end
|
79
|
-
end
|
45
|
+
if darwin?
|
46
|
+
processor_info_darwin
|
47
|
+
elsif linux?
|
48
|
+
processor_info_linux
|
49
|
+
elsif bsd?
|
50
|
+
processor_info_bsd
|
51
|
+
else
|
52
|
+
raise "Couldn't determine OS"
|
80
53
|
end
|
54
|
+
remove_bad_values
|
81
55
|
|
82
56
|
@processor_info
|
83
57
|
rescue
|
84
|
-
|
58
|
+
@processor_info = NewRelic::EMPTY_HASH
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.processor_info_darwin
|
62
|
+
@processor_info = {
|
63
|
+
num_physical_packages: sysctl_value('hw.packages'),
|
64
|
+
num_physical_cores: sysctl_value('hw.physicalcpu_max'),
|
65
|
+
num_logical_processors: sysctl_value('hw.logicalcpu_max')
|
66
|
+
}
|
67
|
+
# in case those don't work, try backup values
|
68
|
+
if @processor_info[:num_physical_cores] <= 0
|
69
|
+
@processor_info[:num_physical_cores] = sysctl_value('hw.physicalcpu')
|
70
|
+
end
|
71
|
+
if @processor_info[:num_logical_processors] <= 0
|
72
|
+
@processor_info[:num_logical_processors] = sysctl_value('hw.logicalcpu')
|
73
|
+
end
|
74
|
+
if @processor_info[:num_logical_processors] <= 0
|
75
|
+
@processor_info[:num_logical_processors] = sysctl_value('hw.ncpu')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.processor_info_linux
|
80
|
+
cpuinfo = proc_try_read('/proc/cpuinfo')
|
81
|
+
@processor_info = cpuinfo ? parse_cpuinfo(cpuinfo) : NewRelic::EMPTY_HASH
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.processor_info_bsd
|
85
|
+
@processor_info = {
|
86
|
+
num_physical_packages: nil,
|
87
|
+
num_physical_cores: nil,
|
88
|
+
num_logical_processors: sysctl_value('hw.ncpu')
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.remove_bad_values
|
93
|
+
# give nils for obviously wrong values
|
94
|
+
@processor_info.keys.each do |key|
|
95
|
+
value = @processor_info[key]
|
96
|
+
if value.is_a?(Numeric) && value <= 0
|
97
|
+
@processor_info[key] = nil
|
98
|
+
end
|
99
|
+
end
|
85
100
|
end
|
86
101
|
|
87
102
|
def self.sysctl_value(name)
|
88
103
|
# make sure to redirect stderr so we don't spew if the name is unknown
|
89
|
-
`sysctl -n #{name} 2>/dev/null
|
104
|
+
`sysctl -n #{name} 2>/dev/null`.to_i
|
90
105
|
end
|
91
106
|
|
92
107
|
def self.parse_cpuinfo(cpuinfo)
|
@@ -143,11 +158,11 @@ module NewRelic
|
|
143
158
|
}
|
144
159
|
end
|
145
160
|
|
146
|
-
def self.num_physical_packages;
|
161
|
+
def self.num_physical_packages; processor_info[:num_physical_packages] end
|
147
162
|
|
148
|
-
def self.num_physical_cores;
|
163
|
+
def self.num_physical_cores; processor_info[:num_physical_cores] end
|
149
164
|
|
150
|
-
def self.num_logical_processors;
|
165
|
+
def self.num_logical_processors; processor_info[:num_logical_processors] end
|
151
166
|
|
152
167
|
def self.processor_arch
|
153
168
|
RbConfig::CONFIG['target_cpu']
|
@@ -158,7 +173,7 @@ module NewRelic
|
|
158
173
|
end
|
159
174
|
|
160
175
|
def self.docker_container_id
|
161
|
-
return unless ruby_os_identifier
|
176
|
+
return unless ruby_os_identifier.include?('linux')
|
162
177
|
|
163
178
|
cgroup_info = proc_try_read('/proc/self/cgroup')
|
164
179
|
return unless cgroup_info
|
@@ -187,7 +202,7 @@ module NewRelic
|
|
187
202
|
return
|
188
203
|
when /docker/
|
189
204
|
::NewRelic::Agent.logger.debug("Cgroup indicates docker but container_id unrecognized: '#{cpu_cgroup}'")
|
190
|
-
::NewRelic::Agent.increment_metric
|
205
|
+
::NewRelic::Agent.increment_metric("Supportability/utilization/docker/error")
|
191
206
|
return
|
192
207
|
else
|
193
208
|
::NewRelic::Agent.logger.debug("Ignoring unrecognized cgroup ID format: '#{cpu_cgroup}'")
|
@@ -196,7 +211,7 @@ module NewRelic
|
|
196
211
|
|
197
212
|
if container_id && container_id.size != 64
|
198
213
|
::NewRelic::Agent.logger.debug("Found docker container_id with invalid length: #{container_id}")
|
199
|
-
::NewRelic::Agent.increment_metric
|
214
|
+
::NewRelic::Agent.increment_metric("Supportability/utilization/docker/error")
|
200
215
|
nil
|
201
216
|
else
|
202
217
|
container_id
|
@@ -225,7 +240,7 @@ module NewRelic
|
|
225
240
|
# for details on why we do it this way.
|
226
241
|
def self.proc_try_read(path)
|
227
242
|
return nil unless File.exist?(path)
|
228
|
-
content = ''
|
243
|
+
content = String.new('')
|
229
244
|
File.open(path) do |f|
|
230
245
|
loop do
|
231
246
|
begin
|
@@ -243,12 +258,12 @@ module NewRelic
|
|
243
258
|
|
244
259
|
def self.ram_in_mib
|
245
260
|
if darwin?
|
246
|
-
(sysctl_value('hw.memsize')
|
261
|
+
(sysctl_value('hw.memsize') / (1024**2))
|
247
262
|
elsif linux?
|
248
263
|
meminfo = proc_try_read('/proc/meminfo')
|
249
264
|
parse_linux_meminfo_in_mib(meminfo)
|
250
265
|
elsif bsd?
|
251
|
-
(sysctl_value('hw.realmem')
|
266
|
+
(sysctl_value('hw.realmem') / (1024**2))
|
252
267
|
else
|
253
268
|
::NewRelic::Agent.logger.debug("Unable to determine ram_in_mib for host os: #{ruby_os_identifier}")
|
254
269
|
nil
|
@@ -272,7 +287,7 @@ module NewRelic
|
|
272
287
|
if bid.ascii_only?
|
273
288
|
if bid.empty?
|
274
289
|
::NewRelic::Agent.logger.debug("boot_id not found in /proc/sys/kernel/random/boot_id")
|
275
|
-
::NewRelic::Agent.increment_metric
|
290
|
+
::NewRelic::Agent.increment_metric("Supportability/utilization/boot_id/error")
|
276
291
|
nil
|
277
292
|
|
278
293
|
elsif bid.bytesize == 36
|
@@ -280,19 +295,19 @@ module NewRelic
|
|
280
295
|
|
281
296
|
else
|
282
297
|
::NewRelic::Agent.logger.debug("Found boot_id with invalid length: #{bid}")
|
283
|
-
::NewRelic::Agent.increment_metric
|
298
|
+
::NewRelic::Agent.increment_metric("Supportability/utilization/boot_id/error")
|
284
299
|
bid[0, 128]
|
285
300
|
|
286
301
|
end
|
287
302
|
else
|
288
303
|
::NewRelic::Agent.logger.debug("Found boot_id with non-ASCII characters: #{bid}")
|
289
|
-
::NewRelic::Agent.increment_metric
|
304
|
+
::NewRelic::Agent.increment_metric("Supportability/utilization/boot_id/error")
|
290
305
|
nil
|
291
306
|
|
292
307
|
end
|
293
308
|
else
|
294
309
|
::NewRelic::Agent.logger.debug("boot_id not found in /proc/sys/kernel/random/boot_id")
|
295
|
-
::NewRelic::Agent.increment_metric
|
310
|
+
::NewRelic::Agent.increment_metric("Supportability/utilization/boot_id/error")
|
296
311
|
nil
|
297
312
|
|
298
313
|
end
|
@@ -1,27 +1,31 @@
|
|
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 Agent
|
7
7
|
module Threading
|
8
8
|
class AgentThread
|
9
9
|
def self.create(label, &blk)
|
10
|
-
::NewRelic::Agent.logger.debug("Creating
|
11
|
-
wrapped_blk =
|
10
|
+
::NewRelic::Agent.logger.debug("Creating AgentThread: #{label}")
|
11
|
+
wrapped_blk = proc do
|
12
|
+
if ::Thread.current[:newrelic_tracer_state] && Thread.current[:newrelic_tracer_state].current_transaction
|
13
|
+
txn = ::Thread.current[:newrelic_tracer_state].current_transaction
|
14
|
+
::NewRelic::Agent.logger.warn("AgentThread created with current transaction #{txn.best_name}")
|
15
|
+
end
|
12
16
|
begin
|
13
|
-
|
17
|
+
yield
|
14
18
|
rescue => e
|
15
|
-
::NewRelic::Agent.logger.error("
|
19
|
+
::NewRelic::Agent.logger.error("AgentThread #{label} exited with error", e)
|
16
20
|
rescue Exception => e
|
17
|
-
::NewRelic::Agent.logger.error("
|
21
|
+
::NewRelic::Agent.logger.error("AgentThread #{label} exited with exception. Re-raising in case of interrupt.", e)
|
18
22
|
raise
|
19
23
|
ensure
|
20
|
-
::NewRelic::Agent.logger.debug("Exiting
|
24
|
+
::NewRelic::Agent.logger.debug("Exiting AgentThread: #{label}")
|
21
25
|
end
|
22
26
|
end
|
23
|
-
|
24
|
-
thread = backing_thread_class.new(&wrapped_blk)
|
27
|
+
thread = nil
|
28
|
+
NewRelic::Agent.disable_all_tracing { thread = backing_thread_class.new(&wrapped_blk) }
|
25
29
|
thread[:newrelic_label] = label
|
26
30
|
thread
|
27
31
|
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 Agent
|
@@ -18,7 +18,7 @@ module NewRelic
|
|
18
18
|
|
19
19
|
def add_child_unless_present(child)
|
20
20
|
child.depth = @depth + 1
|
21
|
-
@children << child unless @children.include?
|
21
|
+
@children << child unless @children.include?(child)
|
22
22
|
end
|
23
23
|
|
24
24
|
def add_child(child)
|
@@ -70,7 +70,7 @@ module NewRelic
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def dump_string
|
73
|
-
result = "#<BacktraceRoot:#{object_id}>"
|
73
|
+
result = String.new("#<BacktraceRoot:#{object_id}>")
|
74
74
|
child_results = @children.map { |c| c.dump_string(2) }.join("\n")
|
75
75
|
result << "\n" unless child_results.empty?
|
76
76
|
result << child_results
|
@@ -115,7 +115,9 @@ module NewRelic
|
|
115
115
|
|
116
116
|
def dump_string(indent = 0)
|
117
117
|
@file, @method, @line_no = parse_backtrace_frame(@raw_line)
|
118
|
-
|
118
|
+
indentation = ' ' * indent
|
119
|
+
result = String.new("#{indentation}#<BacktraceNode:#{object_id} ) + \
|
120
|
+
[#{@runnable_count}] #{@file}:#{@line_no} in #{@method}>")
|
119
121
|
child_results = @children.map { |c| c.dump_string(indent + 2) }.join("\n")
|
120
122
|
result << "\n" unless child_results.empty?
|
121
123
|
result << child_results
|
@@ -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 'set'
|
6
6
|
require 'new_relic/agent/worker_loop'
|
@@ -78,7 +78,7 @@ module NewRelic
|
|
78
78
|
comparison = b.runnable_count <=> a.runnable_count
|
79
79
|
# we secondarily prefer lower depth
|
80
80
|
comparison = a.depth <=> b.depth if comparison == 0
|
81
|
-
# it is thus impossible for any child to
|
81
|
+
# it is thus impossible for any child to precede their parent
|
82
82
|
comparison
|
83
83
|
end
|
84
84
|
|
@@ -122,8 +122,8 @@ module NewRelic
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def to_log_description
|
125
|
-
"#<ThreadProfile:#{object_id} "\
|
126
|
-
"@profile_id: #{profile_id} "\
|
125
|
+
"#<ThreadProfile:#{object_id} " \
|
126
|
+
"@profile_id: #{profile_id} " \
|
127
127
|
"@command_arguments=#{@command_arguments.inspect}>"
|
128
128
|
end
|
129
129
|
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'
|
6
6
|
require 'new_relic/agent/transaction/segment'
|
@@ -234,8 +234,8 @@ module NewRelic
|
|
234
234
|
start_time: nil,
|
235
235
|
parent: nil)
|
236
236
|
|
237
|
-
segment = Transaction::Segment.new
|
238
|
-
start_and_add_segment
|
237
|
+
segment = Transaction::Segment.new(name, unscoped_metrics, start_time)
|
238
|
+
start_and_add_segment(segment, parent)
|
239
239
|
rescue ArgumentError
|
240
240
|
raise
|
241
241
|
rescue => exception
|
@@ -292,8 +292,8 @@ module NewRelic
|
|
292
292
|
product ||= UNKNOWN
|
293
293
|
operation ||= OTHER
|
294
294
|
|
295
|
-
segment = Transaction::DatastoreSegment.new
|
296
|
-
start_and_add_segment
|
295
|
+
segment = Transaction::DatastoreSegment.new(product, operation, collection, host, port_path_or_id, database_name)
|
296
|
+
start_and_add_segment(segment, parent)
|
297
297
|
rescue ArgumentError
|
298
298
|
raise
|
299
299
|
rescue => exception
|
@@ -333,8 +333,8 @@ module NewRelic
|
|
333
333
|
start_time: nil,
|
334
334
|
parent: nil)
|
335
335
|
|
336
|
-
segment = Transaction::ExternalRequestSegment.new
|
337
|
-
start_and_add_segment
|
336
|
+
segment = Transaction::ExternalRequestSegment.new(library, uri, procedure, start_time)
|
337
|
+
start_and_add_segment(segment, parent)
|
338
338
|
rescue ArgumentError
|
339
339
|
raise
|
340
340
|
rescue => exception
|
@@ -346,12 +346,12 @@ module NewRelic
|
|
346
346
|
# if passed +segment+ is something that doesn't
|
347
347
|
# respond to +notice_segment_error+ then this method
|
348
348
|
# is effectively just a yield to the given &block
|
349
|
-
def capture_segment_error
|
349
|
+
def capture_segment_error(segment)
|
350
350
|
return unless block_given?
|
351
351
|
yield
|
352
352
|
rescue => exception
|
353
353
|
if segment && segment.is_a?(Transaction::AbstractSegment)
|
354
|
-
segment.notice_error
|
354
|
+
segment.notice_error(exception)
|
355
355
|
end
|
356
356
|
raise
|
357
357
|
end
|
@@ -375,7 +375,7 @@ module NewRelic
|
|
375
375
|
parameters: parameters,
|
376
376
|
start_time: start_time
|
377
377
|
)
|
378
|
-
start_and_add_segment
|
378
|
+
start_and_add_segment(segment, parent)
|
379
379
|
rescue ArgumentError
|
380
380
|
raise
|
381
381
|
rescue => exception
|
@@ -406,12 +406,14 @@ module NewRelic
|
|
406
406
|
alias_method :tl_clear, :clear_state
|
407
407
|
|
408
408
|
def thread_block_with_current_transaction(*args, &block)
|
409
|
-
current_txn = ::Thread.current[:newrelic_tracer_state].current_transaction if ::Thread.current[:newrelic_tracer_state]
|
410
|
-
|
409
|
+
current_txn = ::Thread.current[:newrelic_tracer_state].current_transaction if ::Thread.current[:newrelic_tracer_state] && ::Thread.current[:newrelic_tracer_state].is_execution_traced?
|
410
|
+
proc do
|
411
411
|
begin
|
412
|
-
|
413
|
-
|
414
|
-
|
412
|
+
if current_txn
|
413
|
+
NewRelic::Agent::Tracer.state.current_transaction = current_txn
|
414
|
+
segment = NewRelic::Agent::Tracer.start_segment(name: "Ruby/Thread/#{::Thread.current.object_id}")
|
415
|
+
end
|
416
|
+
yield(*args) if block.respond_to?(:call)
|
415
417
|
ensure
|
416
418
|
segment.finish if segment
|
417
419
|
end
|
@@ -420,11 +422,11 @@ module NewRelic
|
|
420
422
|
|
421
423
|
private
|
422
424
|
|
423
|
-
def start_and_add_segment
|
425
|
+
def start_and_add_segment(segment, parent = nil)
|
424
426
|
tracer_state = state
|
425
427
|
if (txn = tracer_state.current_transaction) &&
|
426
428
|
tracer_state.tracing_enabled?
|
427
|
-
txn.add_segment
|
429
|
+
txn.add_segment(segment, parent)
|
428
430
|
else
|
429
431
|
segment.record_metrics = false
|
430
432
|
end
|