newrelic_rpm 5.7.0.350 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -1
- data/.rubocop.yml +1919 -0
- data/.rubocop_todo.yml +100 -0
- data/.simplecov +15 -0
- data/.snyk +11 -0
- data/.yardopts +2 -0
- data/Brewfile +12 -0
- data/CHANGELOG.md +4056 -2339
- data/CONTRIBUTING.md +132 -19
- data/DOCKER.md +167 -0
- data/Dockerfile +10 -0
- data/Gemfile +5 -2
- data/Guardfile +22 -4
- data/LICENSE +202 -38
- data/README.md +87 -87
- data/Rakefile +27 -27
- data/THIRD_PARTY_NOTICES.md +28 -0
- data/Thorfile +5 -0
- data/bin/newrelic +3 -2
- data/bin/newrelic_cmd +1 -0
- data/bin/nrdebug +77 -54
- data/config.dot +5 -5
- data/docker-compose.yml +107 -0
- data/init.rb +5 -7
- data/install.rb +3 -3
- data/lefthook.yml +9 -0
- data/lib/new_relic/agent/adaptive_sampler.rb +14 -10
- data/lib/new_relic/agent/agent.rb +125 -969
- data/lib/new_relic/agent/agent_helpers/connect.rb +227 -0
- data/lib/new_relic/agent/agent_helpers/harvest.rb +153 -0
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +72 -0
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +74 -0
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +167 -0
- data/lib/new_relic/agent/agent_helpers/startup.rb +202 -0
- data/lib/new_relic/agent/agent_helpers/transmit.rb +76 -0
- data/lib/new_relic/agent/agent_logger.rb +26 -18
- data/lib/new_relic/agent/attribute_filter.rb +69 -52
- data/lib/new_relic/agent/attribute_processing.rb +8 -8
- data/lib/new_relic/agent/attributes.rb +153 -0
- data/lib/new_relic/agent/audit_logger.rb +19 -4
- data/lib/new_relic/agent/autostart.rb +34 -28
- data/lib/new_relic/agent/chained_call.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command.rb +4 -4
- data/lib/new_relic/agent/commands/agent_command_router.rb +15 -33
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +13 -11
- data/lib/new_relic/agent/configuration/default_source.rb +1480 -1053
- data/lib/new_relic/agent/configuration/dotted_hash.rb +7 -6
- data/lib/new_relic/agent/configuration/environment_source.rb +15 -11
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +68 -0
- data/lib/new_relic/agent/configuration/high_security_source.rb +9 -9
- data/lib/new_relic/agent/configuration/manager.rb +96 -79
- data/lib/new_relic/agent/configuration/manual_source.rb +2 -2
- data/lib/new_relic/agent/configuration/mask_defaults.rb +4 -4
- data/lib/new_relic/agent/configuration/security_policy_source.rb +83 -86
- data/lib/new_relic/agent/configuration/server_source.rb +49 -12
- data/lib/new_relic/agent/configuration/yaml_source.rb +42 -13
- data/lib/new_relic/agent/configuration.rb +2 -2
- data/lib/new_relic/agent/connect/request_builder.rb +61 -0
- data/lib/new_relic/agent/connect/response_handler.rb +58 -0
- data/lib/new_relic/agent/custom_event_aggregator.rb +15 -15
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +5 -6
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +16 -15
- data/lib/new_relic/agent/database/obfuscator.rb +3 -3
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +4 -4
- data/lib/new_relic/agent/database.rb +44 -53
- data/lib/new_relic/agent/database_adapter.rb +35 -0
- data/lib/new_relic/agent/datastores/metric_helper.rb +18 -20
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +9 -8
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +7 -11
- data/lib/new_relic/agent/datastores/mongo.rb +7 -12
- data/lib/new_relic/agent/datastores/nosql_obfuscator.rb +41 -0
- data/lib/new_relic/agent/datastores/redis.rb +6 -12
- data/lib/new_relic/agent/datastores.rb +19 -23
- data/lib/new_relic/agent/deprecator.rb +2 -2
- data/lib/new_relic/agent/{cross_app_payload.rb → distributed_tracing/cross_app_payload.rb} +13 -12
- data/lib/new_relic/agent/{cross_app_tracing.rb → distributed_tracing/cross_app_tracing.rb} +87 -66
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +84 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +75 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +163 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +38 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +245 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +127 -0
- data/lib/new_relic/agent/distributed_tracing.rb +113 -32
- data/lib/new_relic/agent/encoding_normalizer.rb +5 -3
- data/lib/new_relic/agent/error_collector.rb +99 -63
- data/lib/new_relic/agent/error_event_aggregator.rb +10 -8
- data/lib/new_relic/agent/error_filter.rb +174 -0
- data/lib/new_relic/agent/error_trace_aggregator.rb +6 -4
- data/lib/new_relic/agent/event_aggregator.rb +43 -48
- data/lib/new_relic/agent/event_buffer.rb +8 -9
- data/lib/new_relic/agent/event_listener.rb +2 -3
- data/lib/new_relic/agent/event_loop.rb +27 -25
- data/lib/new_relic/agent/external.rb +20 -51
- data/lib/new_relic/agent/guid_generator.rb +30 -0
- data/lib/new_relic/agent/harvester.rb +5 -6
- data/lib/new_relic/agent/heap.rb +8 -10
- data/lib/new_relic/agent/hostname.rb +26 -5
- data/lib/new_relic/agent/http_clients/abstract.rb +81 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +26 -26
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +31 -17
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +18 -23
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +12 -15
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +24 -8
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +9 -12
- data/lib/new_relic/agent/http_clients/uri_util.rb +12 -13
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +22 -52
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +39 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +59 -72
- data/lib/new_relic/agent/instrumentation/action_dispatch.rb +31 -0
- data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +64 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox_subscriber.rb +33 -0
- data/lib/new_relic/agent/instrumentation/action_mailer.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb +85 -0
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +86 -62
- data/lib/new_relic/agent/instrumentation/active_job.rb +38 -19
- data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +21 -7
- data/lib/new_relic/agent/instrumentation/active_record.rb +95 -46
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +82 -61
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +155 -0
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +36 -12
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +69 -64
- data/lib/new_relic/agent/instrumentation/active_storage.rb +8 -4
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +11 -32
- data/lib/new_relic/agent/instrumentation/active_support.rb +27 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/chain.rb +23 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +20 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +24 -0
- data/lib/new_relic/agent/instrumentation/active_support_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +150 -0
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/bunny.rb +14 -134
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +36 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +21 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +27 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +31 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +77 -61
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +91 -0
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +221 -0
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +61 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +15 -187
- data/lib/new_relic/agent/instrumentation/custom_events.rb +12 -0
- data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +37 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +35 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +48 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +30 -52
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +29 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +31 -0
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +8 -7
- data/lib/new_relic/agent/instrumentation/excon.rb +29 -31
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +24 -0
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +18 -0
- data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/grape.rb +16 -121
- 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 +24 -0
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httpclient.rb +12 -32
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +5 -6
- data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +26 -0
- data/lib/new_relic/agent/instrumentation/memcache/chain.rb +15 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +58 -125
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +59 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +90 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +101 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +57 -71
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +15 -14
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +21 -14
- data/lib/new_relic/agent/instrumentation/mongo.rb +7 -132
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +49 -13
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +40 -0
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
- data/lib/new_relic/agent/instrumentation/net_http.rb +44 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +142 -0
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +38 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +28 -0
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +22 -58
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +7 -7
- data/lib/new_relic/agent/instrumentation/queue_time.rb +9 -10
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +66 -0
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +33 -0
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +75 -0
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +43 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +33 -141
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +19 -55
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +36 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +45 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +30 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb +30 -0
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +142 -0
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/rake.rb +18 -159
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +45 -0
- data/lib/new_relic/agent/instrumentation/redis/constants.rb +17 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +93 -0
- data/lib/new_relic/agent/instrumentation/redis/middleware.rb +16 -0
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +29 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +20 -103
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +34 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +33 -41
- data/lib/new_relic/agent/instrumentation/sequel.rb +17 -20
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +20 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +30 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +37 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +29 -46
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +31 -37
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +125 -0
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sinatra.rb +35 -165
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +28 -0
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +22 -0
- data/lib/new_relic/agent/instrumentation/thread.rb +20 -0
- data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +41 -0
- data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +80 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +14 -76
- data/lib/new_relic/agent/instrumentation.rb +2 -2
- data/lib/new_relic/agent/internal_agent_error.rb +3 -3
- data/lib/new_relic/agent/javascript_instrumentor.rb +51 -45
- data/lib/new_relic/agent/linking_metadata.rb +44 -0
- data/lib/new_relic/agent/local_log_decorator.rb +37 -0
- data/lib/new_relic/agent/log_event_aggregator.rb +235 -0
- data/lib/new_relic/agent/log_once.rb +2 -2
- data/lib/new_relic/agent/log_priority.rb +20 -0
- data/lib/new_relic/agent/logging.rb +142 -0
- data/lib/new_relic/agent/memory_logger.rb +3 -3
- data/lib/new_relic/agent/messaging.rb +81 -164
- data/lib/new_relic/agent/method_tracer.rb +152 -145
- data/lib/new_relic/agent/method_tracer_helpers.rb +90 -13
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +117 -0
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +28 -0
- data/lib/new_relic/agent/{inbound_request_monitor.rb → monitors/inbound_request_monitor.rb} +5 -6
- data/lib/new_relic/agent/{synthetics_monitor.rb → monitors/synthetics_monitor.rb} +9 -15
- data/lib/new_relic/agent/monitors.rb +26 -0
- data/lib/new_relic/agent/new_relic_service/encoders.rb +7 -7
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +6 -7
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +8 -29
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +5 -5
- data/lib/new_relic/agent/new_relic_service.rb +282 -166
- data/lib/new_relic/agent/noticeable_error.rb +19 -0
- data/lib/new_relic/agent/null_logger.rb +8 -4
- data/lib/new_relic/agent/obfuscator.rb +9 -11
- data/lib/new_relic/agent/parameter_filtering.rb +35 -8
- data/lib/new_relic/agent/payload_metric_mapping.rb +10 -11
- data/lib/new_relic/agent/pipe_channel_manager.rb +28 -18
- data/lib/new_relic/agent/pipe_service.rb +9 -6
- data/lib/new_relic/agent/prepend_supportability.rb +3 -3
- data/lib/new_relic/agent/priority_sampled_buffer.rb +16 -14
- data/lib/new_relic/agent/range_extensions.rb +9 -29
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +12 -12
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +13 -14
- data/lib/new_relic/agent/rules_engine.rb +6 -5
- data/lib/new_relic/agent/sampler.rb +4 -5
- data/lib/new_relic/agent/sampler_collection.rb +4 -5
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +4 -3
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +14 -11
- data/lib/new_relic/agent/samplers/memory_sampler.rb +26 -15
- data/lib/new_relic/agent/samplers/object_sampler.rb +2 -2
- data/lib/new_relic/agent/samplers/vm_sampler.rb +22 -20
- data/lib/new_relic/agent/span_event_aggregator.rb +14 -16
- data/lib/new_relic/agent/span_event_primitive.rb +118 -58
- data/lib/new_relic/agent/sql_sampler.rb +25 -25
- data/lib/new_relic/agent/stats.rb +79 -42
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +11 -13
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +13 -14
- data/lib/new_relic/agent/stats_engine.rb +11 -11
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +8 -9
- data/lib/new_relic/agent/system_info.rb +100 -66
- data/lib/new_relic/agent/threading/agent_thread.rb +20 -16
- data/lib/new_relic/agent/threading/backtrace_node.rb +13 -14
- data/lib/new_relic/agent/threading/backtrace_service.rb +18 -18
- data/lib/new_relic/agent/threading/thread_profile.rb +31 -45
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +2 -2
- data/lib/new_relic/agent/tracer.rb +513 -0
- data/lib/new_relic/agent/transaction/abstract_segment.rb +131 -41
- data/lib/new_relic/agent/transaction/datastore_segment.rb +22 -18
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +184 -0
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +72 -163
- data/lib/new_relic/agent/transaction/external_request_segment.rb +66 -63
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +34 -46
- data/lib/new_relic/agent/transaction/request_attributes.rb +36 -36
- data/lib/new_relic/agent/transaction/segment.rb +46 -10
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +2 -4
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +2 -2
- data/lib/new_relic/agent/transaction/trace.rb +21 -24
- data/lib/new_relic/agent/transaction/trace_builder.rb +11 -12
- data/lib/new_relic/agent/transaction/trace_context.rb +168 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +31 -28
- data/lib/new_relic/agent/transaction/tracing.rb +15 -111
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +6 -6
- data/lib/new_relic/agent/transaction.rb +252 -259
- data/lib/new_relic/agent/transaction_error_primitive.rb +34 -37
- data/lib/new_relic/agent/transaction_event_aggregator.rb +13 -13
- data/lib/new_relic/agent/transaction_event_primitive.rb +44 -56
- data/lib/new_relic/agent/transaction_event_recorder.rb +17 -16
- data/lib/new_relic/agent/transaction_metrics.rb +11 -10
- data/lib/new_relic/agent/transaction_sampler.rb +7 -12
- data/lib/new_relic/agent/transaction_time_aggregator.rb +41 -26
- data/lib/new_relic/agent/utilization/aws.rb +34 -4
- data/lib/new_relic/agent/utilization/azure.rb +4 -4
- data/lib/new_relic/agent/utilization/gcp.rb +8 -8
- data/lib/new_relic/agent/utilization/pcf.rb +6 -5
- data/lib/new_relic/agent/utilization/vendor.rb +44 -29
- data/lib/new_relic/agent/utilization_data.rb +43 -6
- data/lib/new_relic/agent/vm/jruby_vm.rb +2 -2
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +3 -3
- data/lib/new_relic/agent/vm/mri_vm.rb +46 -19
- data/lib/new_relic/agent/vm/snapshot.rb +6 -6
- data/lib/new_relic/agent/vm.rb +2 -2
- data/lib/new_relic/agent/worker_loop.rb +11 -13
- data/lib/new_relic/agent.rb +151 -79
- data/lib/new_relic/cli/command.rb +21 -23
- data/lib/new_relic/cli/commands/deployments.rb +94 -45
- data/lib/new_relic/cli/commands/install.rb +24 -26
- data/lib/new_relic/coerce.rb +42 -15
- data/lib/new_relic/collection_helper.rb +51 -49
- data/lib/new_relic/constants.rb +39 -0
- data/lib/new_relic/control/class_methods.rb +11 -5
- data/lib/new_relic/control/frameworks/external.rb +3 -3
- data/lib/new_relic/control/frameworks/rails.rb +24 -18
- data/lib/new_relic/control/frameworks/rails3.rb +4 -5
- data/lib/new_relic/control/frameworks/rails4.rb +2 -2
- data/lib/new_relic/control/frameworks/rails_notifications.rb +14 -0
- data/lib/new_relic/control/frameworks/ruby.rb +4 -4
- data/lib/new_relic/control/frameworks/sinatra.rb +8 -2
- data/lib/new_relic/control/frameworks.rb +2 -2
- data/lib/new_relic/control/instance_methods.rb +33 -42
- data/lib/new_relic/control/instrumentation.rb +40 -12
- data/lib/new_relic/control/private_instance_methods.rb +48 -0
- data/lib/new_relic/control/server_methods.rb +4 -5
- data/lib/new_relic/control.rb +2 -3
- data/lib/new_relic/delayed_job_injection.rb +2 -2
- data/lib/new_relic/dependency_detection.rb +129 -18
- data/lib/new_relic/environment_report.rb +41 -35
- data/lib/new_relic/helper.rb +49 -8
- data/lib/new_relic/language_support.rb +30 -6
- data/lib/new_relic/latest_changes.rb +9 -8
- data/lib/new_relic/local_environment.rb +23 -27
- data/lib/new_relic/metric_data.rb +32 -27
- data/lib/new_relic/metric_spec.rb +9 -7
- data/lib/new_relic/noticed_error.rb +46 -33
- data/lib/new_relic/rack/agent_hooks.rb +2 -2
- data/lib/new_relic/rack/agent_middleware.rb +7 -5
- data/lib/new_relic/rack/browser_monitoring.rb +134 -117
- data/lib/new_relic/rack.rb +2 -2
- data/lib/new_relic/recipes/capistrano3.rb +4 -62
- data/lib/new_relic/recipes/capistrano_legacy.rb +24 -27
- data/lib/new_relic/recipes/helpers/send_deployment.rb +70 -0
- data/lib/new_relic/recipes.rb +2 -2
- data/lib/new_relic/supportability_helper.rb +21 -7
- data/lib/new_relic/traced_thread.rb +39 -0
- data/lib/new_relic/version.rb +7 -18
- data/lib/newrelic_rpm.rb +20 -33
- data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +16 -19
- data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +9 -15
- data/lib/tasks/all.rb +4 -4
- data/lib/tasks/config.rake +22 -118
- data/lib/tasks/coverage_report.rake +28 -0
- data/lib/tasks/helpers/config.html.erb +21 -0
- data/lib/tasks/helpers/format.rb +123 -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 +121 -0
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +9 -0
- data/lib/tasks/instrumentation_generator/templates/chain.tt +22 -0
- data/lib/tasks/instrumentation_generator/templates/chain_method.tt +8 -0
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +29 -0
- data/lib/tasks/instrumentation_generator/templates/instrumentation.tt +13 -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 +12 -5
- data/lib/tasks/newrelic.rb +2 -2
- data/lib/tasks/tests.rake +14 -14
- data/newrelic.yml +672 -3
- data/newrelic_rpm.gemspec +40 -31
- data/recipes/newrelic.rb +3 -3
- data/test/agent_helper.rb +419 -98
- metadata +238 -127
- data/.travis.yml +0 -228
- data/bin/mongrel_rpm +0 -33
- data/cert/cacert.pem +0 -1177
- data/lib/new_relic/agent/commands/xray_session.rb +0 -55
- data/lib/new_relic/agent/commands/xray_session_collection.rb +0 -161
- data/lib/new_relic/agent/cross_app_monitor.rb +0 -110
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +0 -44
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
- data/lib/new_relic/agent/distributed_trace_monitor.rb +0 -41
- data/lib/new_relic/agent/distributed_trace_payload.rb +0 -246
- data/lib/new_relic/agent/http_clients/abstract_request.rb +0 -31
- data/lib/new_relic/agent/instrumentation/active_record_4.rb +0 -42
- data/lib/new_relic/agent/instrumentation/active_record_5.rb +0 -41
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -74
- data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -25
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -202
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +0 -104
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -46
- data/lib/new_relic/agent/instrumentation/http.rb +0 -46
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
- data/lib/new_relic/agent/instrumentation/net.rb +0 -50
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -32
- data/lib/new_relic/agent/instrumentation/rails4/action_view.rb +0 -27
- data/lib/new_relic/agent/instrumentation/rails5/action_cable.rb +0 -36
- data/lib/new_relic/agent/instrumentation/rails5/action_controller.rb +0 -33
- data/lib/new_relic/agent/instrumentation/rails5/action_view.rb +0 -27
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -26
- data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -33
- data/lib/new_relic/agent/supported_versions.rb +0 -275
- data/lib/new_relic/agent/transaction/attributes.rb +0 -154
- data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +0 -64
- data/lib/new_relic/agent/transaction_state.rb +0 -186
- data/lib/new_relic/build.rb +0 -2
- data/lib/new_relic/control/frameworks/merb.rb +0 -29
- data/lib/new_relic/control/frameworks/rails5.rb +0 -14
- data/lib/new_relic/metrics.rb +0 -13
- data/lib/tasks/config.html.erb +0 -32
- data/lib/tasks/versions.html.erb +0 -28
- data/lib/tasks/versions.postface.html +0 -8
- data/lib/tasks/versions.preface.html +0 -9
- data/lib/tasks/versions.rake +0 -65
- data/lib/tasks/versions.txt.erb +0 -14
- /data/lib/tasks/{config.text.erb → helpers/config.text.erb} +0 -0
@@ -1,18 +1,18 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/
|
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 VM
|
8
8
|
class Snapshot
|
9
9
|
attr_accessor :gc_total_time, :gc_runs, :major_gc_count, :minor_gc_count,
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
:total_allocated_object, :heap_live, :heap_free,
|
11
|
+
:method_cache_invalidations, :constant_cache_invalidations,
|
12
|
+
:constant_cache_misses, :thread_count, :taken_at
|
13
13
|
|
14
14
|
def initialize
|
15
|
-
@taken_at =
|
15
|
+
@taken_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/new_relic/agent/vm.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/
|
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/language_support'
|
6
6
|
require 'new_relic/agent/vm/mri_vm'
|
@@ -1,24 +1,22 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/
|
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 'thread'
|
6
6
|
|
7
7
|
module NewRelic
|
8
8
|
module Agent
|
9
|
-
|
10
9
|
# A worker loop executes a set of registered tasks on a single thread.
|
11
10
|
# A task is a proc or block with a specified call period in seconds.
|
12
11
|
class WorkerLoop
|
13
|
-
|
14
12
|
attr_accessor :period, :propagate_errors
|
15
13
|
attr_reader :iterations
|
16
14
|
|
17
15
|
# Optional argument :duration (in seconds) for how long the worker loop runs
|
18
16
|
# or :limit (integer) for max number of iterations
|
19
|
-
def initialize(opts={})
|
17
|
+
def initialize(opts = {})
|
20
18
|
@should_run = true
|
21
|
-
@next_invocation_time =
|
19
|
+
@next_invocation_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
22
20
|
@period = 60.0
|
23
21
|
@duration = opts[:duration]
|
24
22
|
@limit = opts[:limit]
|
@@ -34,7 +32,7 @@ module NewRelic
|
|
34
32
|
@should_run = true
|
35
33
|
@iterations = 0
|
36
34
|
|
37
|
-
now =
|
35
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
38
36
|
@deadline = now + @duration if @duration
|
39
37
|
@next_invocation_time = (now + @period)
|
40
38
|
end
|
@@ -42,9 +40,9 @@ module NewRelic
|
|
42
40
|
# Run infinitely, calling the registered tasks at their specified
|
43
41
|
# call periods. The caller is responsible for creating the thread
|
44
42
|
# that runs this worker loop. This will run the task immediately.
|
45
|
-
def run(period=nil, &block)
|
43
|
+
def run(period = nil, &block)
|
46
44
|
setup(period, block)
|
47
|
-
while keep_running?
|
45
|
+
while keep_running?
|
48
46
|
sleep_time = schedule_next_invocation
|
49
47
|
sleep(sleep_time) if sleep_time > 0
|
50
48
|
run_task if keep_running?
|
@@ -53,11 +51,11 @@ module NewRelic
|
|
53
51
|
end
|
54
52
|
|
55
53
|
def schedule_next_invocation
|
56
|
-
now =
|
54
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
57
55
|
while @next_invocation_time <= now && @period > 0
|
58
56
|
@next_invocation_time += @period
|
59
57
|
end
|
60
|
-
@next_invocation_time -
|
58
|
+
@next_invocation_time - Process.clock_gettime(Process::CLOCK_REALTIME)
|
61
59
|
end
|
62
60
|
|
63
61
|
# a simple accessor for @should_run
|
@@ -66,7 +64,7 @@ module NewRelic
|
|
66
64
|
end
|
67
65
|
|
68
66
|
def under_duration?
|
69
|
-
!@deadline ||
|
67
|
+
!@deadline || Process.clock_gettime(Process::CLOCK_REALTIME) < @deadline
|
70
68
|
end
|
71
69
|
|
72
70
|
def under_limit?
|
@@ -90,7 +88,7 @@ module NewRelic
|
|
90
88
|
raise
|
91
89
|
rescue => e
|
92
90
|
# Don't blow out the stack for anything that hasn't already propagated
|
93
|
-
::NewRelic::Agent.logger.error
|
91
|
+
::NewRelic::Agent.logger.error("Error running task in Agent Worker Loop:", e)
|
94
92
|
end
|
95
93
|
end
|
96
94
|
end
|
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
|
-
# See https://github.com/newrelic/
|
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
|
|
@@ -26,16 +26,15 @@ module NewRelic
|
|
26
26
|
|
27
27
|
require 'new_relic/version'
|
28
28
|
require 'new_relic/local_environment'
|
29
|
-
require 'new_relic/metrics'
|
30
29
|
require 'new_relic/metric_spec'
|
31
30
|
require 'new_relic/metric_data'
|
32
31
|
require 'new_relic/noticed_error'
|
32
|
+
require 'new_relic/agent/noticeable_error'
|
33
33
|
require 'new_relic/supportability_helper'
|
34
34
|
|
35
35
|
require 'new_relic/agent/encoding_normalizer'
|
36
36
|
require 'new_relic/agent/stats'
|
37
37
|
require 'new_relic/agent/chained_call'
|
38
|
-
require 'new_relic/agent/cross_app_monitor'
|
39
38
|
require 'new_relic/agent/agent'
|
40
39
|
require 'new_relic/agent/method_tracer'
|
41
40
|
require 'new_relic/agent/worker_loop'
|
@@ -45,8 +44,10 @@ module NewRelic
|
|
45
44
|
require 'new_relic/agent/sql_sampler'
|
46
45
|
require 'new_relic/agent/commands/thread_profiler_session'
|
47
46
|
require 'new_relic/agent/error_collector'
|
47
|
+
require 'new_relic/agent/error_filter'
|
48
48
|
require 'new_relic/agent/sampler'
|
49
49
|
require 'new_relic/agent/database'
|
50
|
+
require 'new_relic/agent/database_adapter'
|
50
51
|
require 'new_relic/agent/datastores'
|
51
52
|
require 'new_relic/agent/pipe_channel_manager'
|
52
53
|
require 'new_relic/agent/configuration'
|
@@ -55,6 +56,11 @@ module NewRelic
|
|
55
56
|
require 'new_relic/agent/system_info'
|
56
57
|
require 'new_relic/agent/external'
|
57
58
|
require 'new_relic/agent/deprecator'
|
59
|
+
require 'new_relic/agent/logging'
|
60
|
+
require 'new_relic/agent/distributed_tracing'
|
61
|
+
require 'new_relic/agent/attribute_processing'
|
62
|
+
require 'new_relic/agent/linking_metadata'
|
63
|
+
require 'new_relic/agent/local_log_decorator'
|
58
64
|
|
59
65
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
60
66
|
|
@@ -76,7 +82,11 @@ module NewRelic
|
|
76
82
|
class ForceDisconnectException < StandardError; end
|
77
83
|
|
78
84
|
# An exception that forces an agent to restart.
|
79
|
-
class ForceRestartException < StandardError
|
85
|
+
class ForceRestartException < StandardError
|
86
|
+
def message
|
87
|
+
"#{super}, restarting."
|
88
|
+
end
|
89
|
+
end
|
80
90
|
|
81
91
|
# Used to blow out of a periodic task without logging a an error, such as for routine
|
82
92
|
# failures.
|
@@ -92,8 +102,6 @@ module NewRelic
|
|
92
102
|
# An error while serializing data for the collector
|
93
103
|
class SerializationError < StandardError; end
|
94
104
|
|
95
|
-
class BackgroundLoadingError < StandardError; end
|
96
|
-
|
97
105
|
# placeholder name used when we cannot determine a transaction's name
|
98
106
|
UNKNOWN_METRIC = '(unknown)'.freeze
|
99
107
|
|
@@ -101,21 +109,23 @@ module NewRelic
|
|
101
109
|
@logger = nil
|
102
110
|
@tracer_lock = Mutex.new
|
103
111
|
@tracer_queue = []
|
112
|
+
@metrics_already_recorded = Set.new
|
104
113
|
|
105
114
|
# The singleton Agent instance. Used internally.
|
106
|
-
def agent
|
115
|
+
def agent # :nodoc:
|
107
116
|
return @agent if @agent
|
117
|
+
|
108
118
|
NewRelic::Agent.logger.warn("Agent unavailable as it hasn't been started.")
|
109
119
|
NewRelic::Agent.logger.warn(caller.join("\n"))
|
110
120
|
nil
|
111
121
|
end
|
112
122
|
|
113
|
-
def agent=(new_instance)
|
123
|
+
def agent=(new_instance) # :nodoc:
|
114
124
|
@agent = new_instance
|
115
125
|
add_deferred_method_tracers_now
|
116
126
|
end
|
117
127
|
|
118
|
-
alias instance agent
|
128
|
+
alias instance agent # :nodoc:
|
119
129
|
|
120
130
|
# Primary interface to logging is fronted by this accessor
|
121
131
|
# Access via ::NewRelic::Agent.logger
|
@@ -131,20 +141,22 @@ module NewRelic
|
|
131
141
|
# is initialized; these methods enable us to defer these calls
|
132
142
|
# until we have started up and can process them.
|
133
143
|
#
|
134
|
-
def add_or_defer_method_tracer(receiver, method_name,
|
144
|
+
def add_or_defer_method_tracer(receiver, method_name, metric_name, options)
|
135
145
|
@tracer_lock.synchronize do
|
146
|
+
options[:code_information] = NewRelic::Agent::MethodTracerHelpers.code_information(receiver, method_name)
|
147
|
+
|
136
148
|
if @agent
|
137
|
-
receiver.send(:
|
149
|
+
receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
|
138
150
|
else
|
139
|
-
@tracer_queue << [receiver, method_name,
|
151
|
+
@tracer_queue << [receiver, method_name, metric_name, options]
|
140
152
|
end
|
141
153
|
end
|
142
154
|
end
|
143
155
|
|
144
156
|
def add_deferred_method_tracers_now
|
145
157
|
@tracer_lock.synchronize do
|
146
|
-
@tracer_queue.each do |receiver, method_name,
|
147
|
-
receiver.send(:
|
158
|
+
@tracer_queue.each do |receiver, method_name, metric_name, options|
|
159
|
+
receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
|
148
160
|
end
|
149
161
|
|
150
162
|
@tracer_queue = []
|
@@ -179,25 +191,25 @@ module NewRelic
|
|
179
191
|
# This method is safe to use from any thread.
|
180
192
|
#
|
181
193
|
# @api public
|
182
|
-
def record_metric(metric_name, value) #THREAD_LOCAL_ACCESS
|
194
|
+
def record_metric(metric_name, value) # THREAD_LOCAL_ACCESS
|
183
195
|
record_api_supportability_metric(:record_metric)
|
184
196
|
|
185
197
|
return unless agent
|
186
198
|
|
187
199
|
if value.is_a?(Hash)
|
188
200
|
stats = NewRelic::Agent::Stats.new
|
189
|
-
|
190
|
-
stats.call_count = value[:count] if value[:count]
|
191
|
-
stats.total_call_time = value[:total] if value[:total]
|
192
|
-
stats.total_exclusive_time = value[:total] if value[:total]
|
193
|
-
stats.min_call_time = value[:min] if value[:min]
|
194
|
-
stats.max_call_time = value[:max] if value[:max]
|
195
|
-
stats.sum_of_squares = value[:sum_of_squares] if value[:sum_of_squares]
|
196
|
-
value = stats
|
201
|
+
value = stats.hash_merge(value)
|
197
202
|
end
|
203
|
+
|
198
204
|
agent.stats_engine.tl_record_unscoped_metrics(metric_name, value)
|
199
205
|
end
|
200
206
|
|
207
|
+
def record_metric_once(metric_name, value = 0.0)
|
208
|
+
return unless @metrics_already_recorded.add?(metric_name)
|
209
|
+
|
210
|
+
record_metric(metric_name, value)
|
211
|
+
end
|
212
|
+
|
201
213
|
# Increment a simple counter metric.
|
202
214
|
#
|
203
215
|
# +metric_name+ should follow a slash separated path convention. Application
|
@@ -209,14 +221,15 @@ module NewRelic
|
|
209
221
|
|
210
222
|
SUPPORTABILITY_INCREMENT_METRIC = 'Supportability/API/increment_metric'.freeze
|
211
223
|
|
212
|
-
def increment_metric(metric_name, amount=1) #THREAD_LOCAL_ACCESS
|
224
|
+
def increment_metric(metric_name, amount = 1) # THREAD_LOCAL_ACCESS
|
213
225
|
return unless agent
|
226
|
+
|
214
227
|
if amount == 1
|
215
228
|
metrics = [metric_name, SUPPORTABILITY_INCREMENT_METRIC]
|
216
|
-
agent.stats_engine.tl_record_unscoped_metrics(metrics) {|stats| stats.increment_count}
|
229
|
+
agent.stats_engine.tl_record_unscoped_metrics(metrics) { |stats| stats.increment_count }
|
217
230
|
else
|
218
|
-
agent.stats_engine.tl_record_unscoped_metrics(metric_name) {|stats| stats.increment_count(amount)}
|
219
|
-
agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) {|stats| stats.increment_count}
|
231
|
+
agent.stats_engine.tl_record_unscoped_metrics(metric_name) { |stats| stats.increment_count(amount) }
|
232
|
+
agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) { |stats| stats.increment_count }
|
220
233
|
end
|
221
234
|
end
|
222
235
|
|
@@ -225,7 +238,7 @@ module NewRelic
|
|
225
238
|
# @!group Recording custom errors
|
226
239
|
|
227
240
|
# Set a filter to be applied to errors that the Ruby Agent will
|
228
|
-
# track. The block should
|
241
|
+
# track. The block should evaluate to the exception to track
|
229
242
|
# (which could be different from the original exception) or nil to
|
230
243
|
# ignore this exception.
|
231
244
|
#
|
@@ -273,17 +286,11 @@ module NewRelic
|
|
273
286
|
#
|
274
287
|
# @api public
|
275
288
|
#
|
276
|
-
def notice_error(exception, options={})
|
289
|
+
def notice_error(exception, options = {})
|
277
290
|
record_api_supportability_metric(:notice_error)
|
278
291
|
|
279
|
-
if options.has_key?(:trace_only)
|
280
|
-
NewRelic::Agent.logger.log_once(:warn, :trace_only_deprecated,
|
281
|
-
'Passing the :trace_only option to NewRelic::Agent.notice_error is deprecated. Please use :expected instead.')
|
282
|
-
options[:expected] = options.delete(:trace_only)
|
283
|
-
end
|
284
|
-
|
285
292
|
Transaction.notice_error(exception, options)
|
286
|
-
nil # don't return a noticed error
|
293
|
+
nil # don't return a noticed error data structure. it can only hurt.
|
287
294
|
end
|
288
295
|
|
289
296
|
# @!endgroup
|
@@ -345,11 +352,11 @@ module NewRelic
|
|
345
352
|
#
|
346
353
|
# @api public
|
347
354
|
#
|
348
|
-
def manual_start(options={})
|
349
|
-
record_api_supportability_metric(:manual_start)
|
350
|
-
|
355
|
+
def manual_start(options = {})
|
351
356
|
raise "Options must be a hash" unless Hash === options
|
352
|
-
|
357
|
+
|
358
|
+
NewRelic::Control.instance.init_plugin({:agent_enabled => true, :sync_startup => true}.merge(options))
|
359
|
+
record_api_supportability_metric(:manual_start)
|
353
360
|
end
|
354
361
|
|
355
362
|
# Register this method as a callback for processes that fork
|
@@ -364,7 +371,7 @@ module NewRelic
|
|
364
371
|
# jobs or other work. If you are doing this with a web dispatcher
|
365
372
|
# that forks worker processes then you will need to force the
|
366
373
|
# agent to reconnect, which it won't do by default. Passenger and
|
367
|
-
#
|
374
|
+
# Unicorn are already handled, nothing special needed for them.
|
368
375
|
#
|
369
376
|
# Options:
|
370
377
|
# * <tt>:force_reconnect => true</tt> to force the spawned process to
|
@@ -377,7 +384,7 @@ module NewRelic
|
|
377
384
|
#
|
378
385
|
# @api public
|
379
386
|
#
|
380
|
-
def after_fork(options={})
|
387
|
+
def after_fork(options = {})
|
381
388
|
record_api_supportability_metric(:after_fork)
|
382
389
|
agent.after_fork(options) if agent
|
383
390
|
end
|
@@ -389,7 +396,7 @@ module NewRelic
|
|
389
396
|
#
|
390
397
|
# @api public
|
391
398
|
#
|
392
|
-
def shutdown(options={})
|
399
|
+
def shutdown(options = {})
|
393
400
|
record_api_supportability_metric(:shutdown)
|
394
401
|
agent.shutdown if agent
|
395
402
|
end
|
@@ -414,7 +421,7 @@ module NewRelic
|
|
414
421
|
#
|
415
422
|
def add_instrumentation(file_pattern)
|
416
423
|
record_api_supportability_metric(:add_instrumentation)
|
417
|
-
NewRelic::Control.instance.add_instrumentation
|
424
|
+
NewRelic::Control.instance.add_instrumentation(file_pattern)
|
418
425
|
end
|
419
426
|
|
420
427
|
# Require agent testing helper methods
|
@@ -487,7 +494,7 @@ module NewRelic
|
|
487
494
|
# Yield to the block without collecting any metrics or traces in
|
488
495
|
# any of the subsequent calls. If executed recursively, will keep
|
489
496
|
# track of the first entry point and turn on tracing again after
|
490
|
-
# leaving that block. This uses the thread local
|
497
|
+
# leaving that block. This uses the thread local Tracer::State.
|
491
498
|
#
|
492
499
|
# @api public
|
493
500
|
#
|
@@ -504,18 +511,6 @@ module NewRelic
|
|
504
511
|
end
|
505
512
|
end
|
506
513
|
|
507
|
-
# This method disables the recording of transaction traces in the given
|
508
|
-
# block. See also #disable_all_tracing
|
509
|
-
#
|
510
|
-
# @api public
|
511
|
-
#
|
512
|
-
def disable_transaction_tracing
|
513
|
-
Deprecator.deprecate :disable_transaction_tracing,
|
514
|
-
'disable_all_tracing or ignore_transaction'
|
515
|
-
record_api_supportability_metric(:disable_transaction_tracing)
|
516
|
-
yield
|
517
|
-
end
|
518
|
-
|
519
514
|
# This method sets the state of sql recording in the transaction
|
520
515
|
# sampler feature. Within the given block, no sql will be recorded
|
521
516
|
#
|
@@ -544,13 +539,7 @@ module NewRelic
|
|
544
539
|
|
545
540
|
# Check to see if we are capturing metrics currently on this thread.
|
546
541
|
def tl_is_execution_traced?
|
547
|
-
NewRelic::Agent::
|
548
|
-
end
|
549
|
-
|
550
|
-
# helper method to check the thread local to determine whether sql
|
551
|
-
# is being recorded or not
|
552
|
-
def tl_is_sql_recorded?
|
553
|
-
NewRelic::Agent::TransactionState.tl_get.is_sql_recorded?
|
542
|
+
NewRelic::Agent::Tracer.state.is_execution_traced?
|
554
543
|
end
|
555
544
|
|
556
545
|
# @!group Adding custom attributes to traces
|
@@ -563,19 +552,61 @@ module NewRelic
|
|
563
552
|
# these custom attributes will also be present in the script injected into
|
564
553
|
# the response body, making them available on Insights PageView events.
|
565
554
|
#
|
555
|
+
#
|
556
|
+
# @param [Hash] params A Hash of attributes to be attached to the transaction event.
|
557
|
+
# Keys should be strings or symbols, and values
|
558
|
+
# may be strings, symbols, numeric values or
|
559
|
+
# booleans.
|
560
|
+
#
|
566
561
|
# @api public
|
567
562
|
#
|
568
|
-
def add_custom_attributes(params) #THREAD_LOCAL_ACCESS
|
563
|
+
def add_custom_attributes(params) # THREAD_LOCAL_ACCESS
|
569
564
|
record_api_supportability_metric(:add_custom_attributes)
|
570
565
|
|
571
|
-
if params.is_a?
|
566
|
+
if params.is_a?(Hash)
|
572
567
|
txn = Transaction.tl_current
|
573
568
|
txn.add_custom_attributes(params) if txn
|
569
|
+
|
570
|
+
segment = ::NewRelic::Agent::Tracer.current_segment
|
571
|
+
if segment
|
572
|
+
add_new_segment_attributes(params, segment)
|
573
|
+
end
|
574
574
|
else
|
575
575
|
::NewRelic::Agent.logger.warn("Bad argument passed to #add_custom_attributes. Expected Hash but got #{params.class}")
|
576
576
|
end
|
577
577
|
end
|
578
578
|
|
579
|
+
def add_new_segment_attributes(params, segment)
|
580
|
+
# Make sure not to override existing segment-level custom attributes
|
581
|
+
segment_custom_keys = segment.attributes.custom_attributes.keys.map(&:to_sym)
|
582
|
+
segment.add_custom_attributes(params.reject { |k, _v| segment_custom_keys.include?(k.to_sym) })
|
583
|
+
end
|
584
|
+
|
585
|
+
# Add custom attributes to the span event for the current span. Attributes will be visible on spans in the
|
586
|
+
# New Relic Distributed Tracing UI and on span events in New Relic Insights.
|
587
|
+
#
|
588
|
+
# Custom attributes will not be transmitted when +high_security+ setting is enabled or
|
589
|
+
# +custom_attributes+ setting is disabled.
|
590
|
+
#
|
591
|
+
# @param [Hash] params A Hash of attributes to be attached to the span event.
|
592
|
+
# Keys should be strings or symbols, and values
|
593
|
+
# may be strings, symbols, numeric values or
|
594
|
+
# booleans.
|
595
|
+
#
|
596
|
+
# @see https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/glossary#span
|
597
|
+
# @api public
|
598
|
+
def add_custom_span_attributes(params)
|
599
|
+
record_api_supportability_metric(:add_custom_span_attributes)
|
600
|
+
|
601
|
+
if params.is_a?(Hash)
|
602
|
+
if segment = NewRelic::Agent::Tracer.current_segment
|
603
|
+
segment.add_custom_attributes(params)
|
604
|
+
end
|
605
|
+
else
|
606
|
+
::NewRelic::Agent.logger.warn("Bad argument passed to #add_custom_span_attributes. Expected Hash but got #{params.class}")
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
579
610
|
# @!endgroup
|
580
611
|
|
581
612
|
# @!group Transaction naming
|
@@ -584,7 +615,9 @@ module NewRelic
|
|
584
615
|
# apply a reasonable default based on framework routing, but in
|
585
616
|
# cases where this is insufficient, this can be used to manually
|
586
617
|
# control the name of the transaction.
|
587
|
-
#
|
618
|
+
#
|
619
|
+
# The category of transaction can be specified via the +:category+ option.
|
620
|
+
# The following are the only valid categories:
|
588
621
|
#
|
589
622
|
# * <tt>:category => :controller</tt> indicates that this is a
|
590
623
|
# controller action and will appear with all the other actions.
|
@@ -603,7 +636,7 @@ module NewRelic
|
|
603
636
|
#
|
604
637
|
# @api public
|
605
638
|
#
|
606
|
-
def set_transaction_name(name, options={})
|
639
|
+
def set_transaction_name(name, options = {})
|
607
640
|
record_api_supportability_metric(:set_transaction_name)
|
608
641
|
Transaction.set_overriding_transaction_name(name, options[:category])
|
609
642
|
end
|
@@ -613,7 +646,7 @@ module NewRelic
|
|
613
646
|
#
|
614
647
|
# @api public
|
615
648
|
#
|
616
|
-
def get_transaction_name #THREAD_LOCAL_ACCESS
|
649
|
+
def get_transaction_name # THREAD_LOCAL_ACCESS
|
617
650
|
record_api_supportability_metric(:get_transaction_name)
|
618
651
|
|
619
652
|
txn = Transaction.tl_current
|
@@ -627,15 +660,15 @@ module NewRelic
|
|
627
660
|
|
628
661
|
# Yield to a block that is run with a database metric name context. This means
|
629
662
|
# the Database instrumentation will use this for the metric name if it does not
|
630
|
-
# otherwise know about a model. This is
|
663
|
+
# otherwise know about a model. This is reentrant.
|
631
664
|
#
|
632
665
|
# @param [String,Class,#to_s] model the DB model class
|
633
666
|
#
|
634
667
|
# @param [String] method the name of the finder method or other method to
|
635
668
|
# identify the operation with.
|
636
669
|
#
|
637
|
-
def with_database_metric_name(model, method = nil, product = nil, &block)
|
638
|
-
if txn =
|
670
|
+
def with_database_metric_name(model, method = nil, product = nil, &block)
|
671
|
+
if txn = Tracer.current_transaction
|
639
672
|
txn.with_database_metric_name(model, method, product, &block)
|
640
673
|
else
|
641
674
|
yield
|
@@ -645,17 +678,53 @@ module NewRelic
|
|
645
678
|
# Subscribe to events of +event_type+, calling the given +handler+
|
646
679
|
# when one is sent.
|
647
680
|
def subscribe(event_type, &handler)
|
648
|
-
agent.events.subscribe(
|
681
|
+
agent.events.subscribe(event_type, &handler)
|
649
682
|
end
|
650
683
|
|
651
684
|
# Fire an event of the specified +event_type+, passing it an the given +args+
|
652
685
|
# to any registered handlers.
|
653
686
|
def notify(event_type, *args)
|
654
|
-
agent.events.notify(
|
687
|
+
agent.events.notify(event_type, *args)
|
655
688
|
rescue
|
656
|
-
NewRelic::Agent.logger.debug
|
689
|
+
NewRelic::Agent.logger.debug("Ignoring exception during %p event notification" % [event_type])
|
690
|
+
end
|
691
|
+
|
692
|
+
# @!group Trace and Entity metadata
|
693
|
+
|
694
|
+
TRACE_ID_KEY = 'trace.id'.freeze
|
695
|
+
SPAN_ID_KEY = 'span.id'.freeze
|
696
|
+
ENTITY_NAME_KEY = 'entity.name'.freeze
|
697
|
+
ENTITY_TYPE_KEY = 'entity.type'.freeze
|
698
|
+
ENTITY_GUID_KEY = 'entity.guid'.freeze
|
699
|
+
HOSTNAME_KEY = 'hostname'.freeze
|
700
|
+
|
701
|
+
ENTITY_TYPE = 'SERVICE'.freeze
|
702
|
+
|
703
|
+
# Returns a new hash containing trace and entity metadata that can be used
|
704
|
+
# to relate data to a trace or to an entity in APM.
|
705
|
+
#
|
706
|
+
# This hash includes:
|
707
|
+
# * trace.id - The current trace id, if there is a current trace id. This
|
708
|
+
# value may be omitted.
|
709
|
+
# * span.id - The current span id, if there is a current span. This
|
710
|
+
# value may be omitted.
|
711
|
+
# * entity.name - The name of the current application. This is read from
|
712
|
+
# the +app_name+ key in your config. If there are multiple application
|
713
|
+
# names, the first one is used.
|
714
|
+
# * entity.type - The entity type is hardcoded to the string +'SERVICE'+.
|
715
|
+
# * entity.guid - The guid of the current entity.
|
716
|
+
# * hostname - The fully qualified hostname.
|
717
|
+
#
|
718
|
+
# @api public
|
719
|
+
def linking_metadata
|
720
|
+
metadata = Hash.new
|
721
|
+
LinkingMetadata.append_service_linking_metadata(metadata)
|
722
|
+
LinkingMetadata.append_trace_linking_metadata(metadata)
|
723
|
+
metadata
|
657
724
|
end
|
658
725
|
|
726
|
+
# @!endgroup
|
727
|
+
|
659
728
|
# @!group Manual browser monitoring configuration
|
660
729
|
|
661
730
|
# This method returns a string suitable for inclusion in a page - known as
|
@@ -670,13 +739,16 @@ module NewRelic
|
|
670
739
|
# In previous agents there was a corresponding footer required, but all the
|
671
740
|
# work is now done by this single method.
|
672
741
|
#
|
742
|
+
# @param [String] nonce The nonce to use in the javascript tag for browser instrumentation
|
743
|
+
#
|
673
744
|
# @api public
|
674
745
|
#
|
675
|
-
def browser_timing_header
|
746
|
+
def browser_timing_header(nonce = nil)
|
676
747
|
record_api_supportability_metric(:browser_timing_header)
|
677
748
|
|
678
|
-
return
|
679
|
-
|
749
|
+
return EMPTY_STR unless agent
|
750
|
+
|
751
|
+
agent.javascript_instrumentor.browser_timing_header(nonce)
|
680
752
|
end
|
681
753
|
|
682
754
|
# @!endgroup
|