newrelic_rpm 6.15.0 → 9.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.build_ignore +26 -0
- data/CHANGELOG.md +4176 -2789
- data/CONTRIBUTING.md +32 -13
- data/Gemfile +1 -2
- data/LICENSE +0 -6
- data/README.md +29 -22
- data/Rakefile +33 -35
- data/THIRD_PARTY_NOTICES.md +14 -199
- data/Thorfile +5 -0
- data/bin/newrelic +4 -9
- data/bin/newrelic_rpm +15 -0
- data/bin/nrdebug +85 -62
- data/init.rb +6 -8
- data/install.rb +2 -2
- data/lib/new_relic/agent/adaptive_sampler.rb +13 -9
- data/lib/new_relic/agent/agent.rb +99 -941
- data/lib/new_relic/agent/agent_helpers/connect.rb +222 -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 +175 -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 +27 -23
- data/lib/new_relic/agent/attribute_filter.rb +67 -50
- data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
- data/lib/new_relic/agent/attribute_processing.rb +9 -9
- data/lib/new_relic/agent/attributes.rb +5 -4
- data/lib/new_relic/agent/audit_logger.rb +13 -8
- data/lib/new_relic/agent/autostart.rb +21 -20
- data/lib/new_relic/agent/chained_call.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command.rb +4 -4
- data/lib/new_relic/agent/commands/agent_command_router.rb +15 -13
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +16 -14
- data/lib/new_relic/agent/configuration/default_source.rb +1608 -1182
- data/lib/new_relic/agent/configuration/dotted_hash.rb +6 -5
- data/lib/new_relic/agent/configuration/environment_source.rb +13 -11
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +40 -17
- data/lib/new_relic/agent/configuration/high_security_source.rb +11 -12
- data/lib/new_relic/agent/configuration/manager.rb +103 -75
- 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 +92 -95
- data/lib/new_relic/agent/configuration/server_source.rb +43 -41
- data/lib/new_relic/agent/configuration/yaml_source.rb +47 -10
- data/lib/new_relic/agent/configuration.rb +1 -1
- data/lib/new_relic/agent/connect/request_builder.rb +18 -18
- data/lib/new_relic/agent/connect/response_handler.rb +5 -8
- data/lib/new_relic/agent/custom_event_aggregator.rb +42 -16
- 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 +4 -4
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +3 -3
- data/lib/new_relic/agent/database.rb +45 -53
- data/lib/new_relic/agent/database_adapter.rb +3 -1
- data/lib/new_relic/agent/datastores/metric_helper.rb +21 -22
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +7 -6
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +17 -21
- data/lib/new_relic/agent/datastores/mongo.rb +6 -11
- data/lib/new_relic/agent/datastores/nosql_obfuscator.rb +41 -0
- data/lib/new_relic/agent/datastores/redis.rb +9 -15
- data/lib/new_relic/agent/datastores.rb +13 -15
- data/lib/new_relic/agent/deprecator.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +10 -10
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +45 -40
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +22 -22
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +23 -23
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +52 -54
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +10 -11
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +82 -83
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +42 -41
- data/lib/new_relic/agent/distributed_tracing.rb +33 -101
- data/lib/new_relic/agent/encoding_normalizer.rb +4 -2
- data/lib/new_relic/agent/error_collector.rb +105 -58
- data/lib/new_relic/agent/error_event_aggregator.rb +4 -5
- data/lib/new_relic/agent/error_filter.rb +174 -0
- data/lib/new_relic/agent/error_trace_aggregator.rb +9 -7
- data/lib/new_relic/agent/event_aggregator.rb +22 -21
- data/lib/new_relic/agent/event_buffer.rb +7 -8
- data/lib/new_relic/agent/event_listener.rb +1 -2
- data/lib/new_relic/agent/event_loop.rb +27 -25
- data/lib/new_relic/agent/external.rb +11 -44
- data/lib/new_relic/agent/guid_generator.rb +13 -11
- data/lib/new_relic/agent/harvester.rb +5 -8
- data/lib/new_relic/agent/heap.rb +8 -9
- data/lib/new_relic/agent/hostname.rb +21 -14
- data/lib/new_relic/agent/http_clients/abstract.rb +22 -31
- data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +80 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +14 -17
- data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +109 -0
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +15 -17
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +7 -6
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +8 -9
- data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +91 -0
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +13 -8
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +12 -13
- data/lib/new_relic/agent/http_clients/uri_util.rb +3 -5
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +9 -22
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +42 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +41 -33
- 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 +20 -21
- data/lib/new_relic/agent/instrumentation/active_job.rb +33 -13
- data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +20 -6
- data/lib/new_relic/agent/instrumentation/active_record.rb +41 -38
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +87 -75
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +54 -66
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +6 -6
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +30 -22
- data/lib/new_relic/agent/instrumentation/active_storage.rb +7 -3
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +8 -33
- data/lib/new_relic/agent/instrumentation/active_support.rb +27 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -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 +24 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +26 -0
- data/lib/new_relic/agent/instrumentation/active_support_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
- data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/async_http.rb +28 -0
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +159 -0
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/bunny.rb +11 -154
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +36 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +20 -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 +74 -63
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +91 -0
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +225 -0
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +61 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +14 -246
- data/lib/new_relic/agent/instrumentation/custom_events.rb +12 -0
- data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +38 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +36 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +51 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +30 -53
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +29 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +70 -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/ethon/chain.rb +39 -0
- data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
- data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +11 -7
- data/lib/new_relic/agent/instrumentation/excon.rb +27 -29
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +27 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +20 -0
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +25 -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 +104 -0
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/grape.rb +16 -117
- data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +97 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +94 -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 +138 -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 +41 -0
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httpclient.rb +10 -32
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +34 -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/httpx/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
- data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httpx.rb +27 -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 +69 -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 +59 -128
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +59 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +99 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +103 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +58 -74
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +15 -14
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +6 -8
- data/lib/new_relic/agent/instrumentation/mongo.rb +6 -137
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +24 -23
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/{net_prepend.rb → net_http/instrumentation.rb} +18 -14
- 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 +56 -10
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +38 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +32 -0
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +20 -58
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +6 -6
- 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 +81 -0
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +43 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +32 -142
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +25 -56
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +9 -8
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +18 -5
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb +8 -5
- 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 +146 -0
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/rake.rb +17 -158
- 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 +98 -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 +19 -108
- 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 +38 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +32 -43
- data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
- data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
- data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +68 -0
- data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +29 -0
- data/lib/new_relic/agent/instrumentation/roda.rb +36 -0
- data/lib/new_relic/agent/instrumentation/sequel.rb +16 -19
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +12 -12
- data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +24 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +30 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +60 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +27 -65
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +30 -36
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +130 -0
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +4 -6
- data/lib/new_relic/agent/instrumentation/sinatra.rb +34 -163
- data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
- data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +24 -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 +46 -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 +84 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +12 -91
- data/lib/new_relic/agent/instrumentation/view_component/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +39 -0
- data/lib/new_relic/agent/instrumentation/view_component/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/view_component.rb +26 -0
- data/lib/new_relic/agent/instrumentation.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +2 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +58 -48
- 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 +282 -0
- data/lib/new_relic/agent/log_event_attributes.rb +115 -0
- data/lib/new_relic/agent/log_once.rb +1 -1
- data/lib/new_relic/agent/log_priority.rb +20 -0
- data/lib/new_relic/agent/logging.rb +95 -52
- data/lib/new_relic/agent/memory_logger.rb +2 -2
- data/lib/new_relic/agent/messaging.rb +72 -86
- data/lib/new_relic/agent/method_tracer.rb +159 -154
- data/lib/new_relic/agent/method_tracer_helpers.rb +109 -11
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +26 -19
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +5 -4
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +1 -2
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +17 -9
- data/lib/new_relic/agent/monitors.rb +6 -7
- data/lib/new_relic/agent/new_relic_service/encoders.rb +9 -9
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +6 -6
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +2 -2
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -4
- data/lib/new_relic/agent/new_relic_service.rb +282 -213
- data/lib/new_relic/agent/{noticible_error.rb → noticeable_error.rb} +2 -5
- data/lib/new_relic/agent/null_logger.rb +7 -3
- data/lib/new_relic/agent/obfuscator.rb +7 -11
- data/lib/new_relic/agent/parameter_filtering.rb +29 -15
- data/lib/new_relic/agent/payload_metric_mapping.rb +9 -10
- data/lib/new_relic/agent/pipe_channel_manager.rb +34 -23
- data/lib/new_relic/agent/pipe_service.rb +13 -8
- data/lib/new_relic/agent/prepend_supportability.rb +2 -2
- data/lib/new_relic/agent/priority_sampled_buffer.rb +9 -12
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +11 -11
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -14
- data/lib/new_relic/agent/rules_engine.rb +6 -5
- data/lib/new_relic/agent/sampler.rb +5 -5
- data/lib/new_relic/agent/sampler_collection.rb +4 -5
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +8 -7
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +20 -17
- data/lib/new_relic/agent/samplers/memory_sampler.rb +32 -21
- data/lib/new_relic/agent/samplers/object_sampler.rb +2 -2
- data/lib/new_relic/agent/samplers/vm_sampler.rb +21 -19
- data/lib/new_relic/agent/span_event_aggregator.rb +15 -15
- data/lib/new_relic/agent/span_event_primitive.rb +77 -59
- data/lib/new_relic/agent/sql_sampler.rb +20 -21
- data/lib/new_relic/agent/stats.rb +79 -42
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +9 -11
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +12 -13
- data/lib/new_relic/agent/stats_engine.rb +8 -8
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +8 -9
- data/lib/new_relic/agent/system_info.rb +113 -67
- data/lib/new_relic/agent/threading/agent_thread.rb +18 -14
- data/lib/new_relic/agent/threading/backtrace_node.rb +12 -13
- data/lib/new_relic/agent/threading/backtrace_service.rb +17 -21
- data/lib/new_relic/agent/threading/thread_profile.rb +24 -24
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +2 -2
- data/lib/new_relic/agent/tracer.rb +101 -96
- data/lib/new_relic/agent/transaction/abstract_segment.rb +176 -52
- data/lib/new_relic/agent/transaction/datastore_segment.rb +22 -18
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +65 -57
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +46 -48
- data/lib/new_relic/agent/transaction/external_request_segment.rb +52 -39
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +31 -37
- data/lib/new_relic/agent/transaction/request_attributes.rb +78 -42
- data/lib/new_relic/agent/transaction/segment.rb +20 -10
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +1 -3
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +2 -2
- data/lib/new_relic/agent/transaction/trace.rb +16 -12
- data/lib/new_relic/agent/transaction/trace_builder.rb +10 -10
- data/lib/new_relic/agent/transaction/trace_context.rb +35 -35
- data/lib/new_relic/agent/transaction/trace_node.rb +30 -28
- data/lib/new_relic/agent/transaction/tracing.rb +32 -13
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +6 -6
- data/lib/new_relic/agent/transaction.rb +229 -178
- data/lib/new_relic/agent/transaction_error_primitive.rb +43 -25
- data/lib/new_relic/agent/transaction_event_aggregator.rb +16 -16
- data/lib/new_relic/agent/transaction_event_primitive.rb +51 -33
- data/lib/new_relic/agent/transaction_event_recorder.rb +16 -15
- data/lib/new_relic/agent/transaction_metrics.rb +10 -9
- data/lib/new_relic/agent/transaction_sampler.rb +7 -8
- data/lib/new_relic/agent/transaction_time_aggregator.rb +32 -27
- data/lib/new_relic/agent/utilization/aws.rb +34 -4
- data/lib/new_relic/agent/utilization/azure.rb +6 -6
- data/lib/new_relic/agent/utilization/gcp.rb +11 -13
- data/lib/new_relic/agent/utilization/pcf.rb +6 -5
- data/lib/new_relic/agent/utilization/vendor.rb +45 -32
- data/lib/new_relic/agent/utilization_data.rb +7 -5
- data/lib/new_relic/agent/vm/c_ruby_vm.rb +99 -0
- data/lib/new_relic/agent/vm/jruby_vm.rb +1 -1
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +3 -3
- data/lib/new_relic/agent/vm/snapshot.rb +5 -5
- data/lib/new_relic/agent/vm.rb +3 -3
- data/lib/new_relic/agent/worker_loop.rb +10 -12
- data/lib/new_relic/agent.rb +204 -111
- data/lib/new_relic/base64.rb +25 -0
- data/lib/new_relic/cli/command.rb +26 -25
- data/lib/new_relic/cli/commands/deployments.rb +100 -49
- data/lib/new_relic/cli/commands/install.rb +31 -34
- data/lib/new_relic/coerce.rb +15 -13
- data/lib/new_relic/collection_helper.rb +50 -48
- data/lib/new_relic/constants.rb +13 -12
- data/lib/new_relic/control/class_methods.rb +6 -12
- data/lib/new_relic/control/frameworks/external.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +60 -30
- data/lib/new_relic/control/frameworks/rails3.rb +3 -4
- 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/roda.rb +20 -0
- data/lib/new_relic/control/frameworks/ruby.rb +3 -3
- data/lib/new_relic/control/frameworks/sinatra.rb +7 -1
- data/lib/new_relic/control/frameworks.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +27 -45
- data/lib/new_relic/control/instrumentation.rb +25 -11
- data/lib/new_relic/control/private_instance_methods.rb +48 -0
- data/lib/new_relic/control/server_methods.rb +3 -4
- data/lib/new_relic/control.rb +1 -2
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +141 -32
- data/lib/new_relic/environment_report.rb +41 -33
- data/lib/new_relic/helper.rb +49 -7
- data/lib/new_relic/language_support.rb +39 -6
- data/lib/new_relic/latest_changes.rb +10 -9
- data/lib/new_relic/local_environment.rb +42 -37
- data/lib/new_relic/metric_data.rb +31 -26
- data/lib/new_relic/metric_spec.rb +8 -6
- data/lib/new_relic/noticed_error.rb +43 -46
- data/lib/new_relic/rack/agent_hooks.rb +2 -2
- data/lib/new_relic/rack/agent_middleware.rb +3 -17
- data/lib/new_relic/rack/browser_monitoring.rb +135 -121
- data/lib/new_relic/rack.rb +1 -1
- 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 +1 -1
- data/lib/new_relic/supportability_helper.rb +14 -12
- data/lib/new_relic/traced_thread.rb +38 -0
- data/lib/new_relic/version.rb +6 -17
- data/lib/newrelic_rpm.rb +20 -33
- data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +18 -21
- data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +9 -15
- data/lib/tasks/all.rb +3 -3
- data/lib/tasks/bump_version.rake +21 -0
- data/lib/tasks/config.rake +25 -119
- data/lib/tasks/coverage_report.rake +28 -0
- data/lib/tasks/helpers/config.html.erb +114 -0
- data/lib/tasks/helpers/format.rb +127 -0
- data/lib/tasks/helpers/matches.rb +12 -0
- data/lib/tasks/helpers/newrelicyml.rb +144 -0
- data/lib/tasks/helpers/prompt.rb +24 -0
- data/lib/tasks/helpers/version_bump.rb +62 -0
- data/lib/tasks/install.rake +8 -4
- 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 +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 +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/newrelic.rb +2 -1
- data/lib/tasks/newrelicyml.rake +13 -0
- data/lib/tasks/tests.rake +83 -17
- data/newrelic.yml +790 -4
- data/newrelic_rpm.gemspec +52 -43
- data/recipes/newrelic.rb +2 -2
- data/test/agent_helper.rb +252 -198
- metadata +275 -95
- data/.gitignore +0 -37
- data/.project +0 -23
- data/.yardopts +0 -26
- data/Guardfile +0 -25
- data/ROADMAP.md +0 -24
- data/bin/mongrel_rpm +0 -33
- data/bin/newrelic_cmd +0 -5
- data/cert/cacert.pem +0 -1177
- data/config/database.yml +0 -5
- data/config.dot +0 -278
- 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/instrumentation/acts_as_solr.rb +0 -75
- data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -25
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -204
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
- data/lib/new_relic/agent/instrumentation/http.rb +0 -49
- 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 -70
- 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/rainbows_instrumentation.rb +0 -26
- data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -33
- data/lib/new_relic/agent/range_extensions.rb +0 -47
- data/lib/new_relic/agent/supported_versions.rb +0 -275
- data/lib/new_relic/agent/vm/mri_vm.rb +0 -81
- data/lib/new_relic/control/frameworks/merb.rb +0 -29
- data/lib/tasks/config.html.erb +0 -32
- data/lib/tasks/multiverse.rake +0 -2
- data/lib/tasks/multiverse.rb +0 -104
- /data/lib/tasks/{config.text.erb → helpers/config.text.erb} +0 -0
@@ -0,0 +1,109 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic
|
6
|
+
module Agent
|
7
|
+
module AttributePreFiltering
|
8
|
+
module_function
|
9
|
+
|
10
|
+
PRE_FILTER_KEYS = %i[include exclude].freeze
|
11
|
+
DISCARDED = :nr_discarded
|
12
|
+
|
13
|
+
def formulate_regexp_union(option)
|
14
|
+
return if NewRelic::Agent.config[option].empty?
|
15
|
+
|
16
|
+
Regexp.union(NewRelic::Agent.config[option].map { |p| string_to_regexp(p) }.uniq.compact).freeze
|
17
|
+
rescue StandardError => e
|
18
|
+
NewRelic::Agent.logger.warn("Failed to formulate a Regexp union from the '#{option}' configuration option " +
|
19
|
+
"- #{e.class}: #{e.message}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def string_to_regexp(str)
|
23
|
+
Regexp.new(str)
|
24
|
+
rescue StandardError => e
|
25
|
+
NewRelic::Agent.logger.warn("Failed to initialize Regexp from string '#{str}' - #{e.class}: #{e.message}")
|
26
|
+
end
|
27
|
+
|
28
|
+
# attribute filtering suppresses data that has already been flattened
|
29
|
+
# and coerced (serialized as text) via #flatten_and_coerce, and is
|
30
|
+
# restricted to basic text matching with a single optional wildcard.
|
31
|
+
# pre filtering operates on raw Ruby objects beforehand and uses full
|
32
|
+
# Ruby regex syntax
|
33
|
+
def pre_filter(values = [], options = {})
|
34
|
+
return values unless !options.empty? && PRE_FILTER_KEYS.any? { |k| options.key?(k) }
|
35
|
+
|
36
|
+
# if there's a prefix in play for (non-pre) attribute filtration and
|
37
|
+
# attribute filtration won't allow that prefix, then don't even bother
|
38
|
+
# with pre filtration that could only result in values that would be
|
39
|
+
# blocked
|
40
|
+
if options.key?(:attribute_namespace) &&
|
41
|
+
!NewRelic::Agent.instance.attribute_filter.might_allow_prefix?(options[:attribute_namespace])
|
42
|
+
return values
|
43
|
+
end
|
44
|
+
|
45
|
+
values.each_with_object([]) do |element, filtered|
|
46
|
+
object = pre_filter_object(element, options)
|
47
|
+
filtered << object unless discarded?(object)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def pre_filter_object(object, options)
|
52
|
+
if object.is_a?(Hash)
|
53
|
+
pre_filter_hash(object, options)
|
54
|
+
elsif object.is_a?(Array)
|
55
|
+
pre_filter_array(object, options)
|
56
|
+
else
|
57
|
+
pre_filter_scalar(object, options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def pre_filter_hash(hash, options)
|
62
|
+
filtered_hash = hash.each_with_object({}) do |(key, value), filtered|
|
63
|
+
filtered_key = pre_filter_object(key, options)
|
64
|
+
next if discarded?(filtered_key)
|
65
|
+
|
66
|
+
# If the key is permitted, skip include filtration for the value
|
67
|
+
# but still apply exclude filtration
|
68
|
+
if options.key?(:exclude)
|
69
|
+
exclude_only = options.dup
|
70
|
+
exclude_only.delete(:include)
|
71
|
+
filtered_value = pre_filter_object(value, exclude_only)
|
72
|
+
next if discarded?(filtered_value)
|
73
|
+
else
|
74
|
+
filtered_value = value
|
75
|
+
end
|
76
|
+
|
77
|
+
filtered[filtered_key] = filtered_value
|
78
|
+
end
|
79
|
+
|
80
|
+
filtered_hash.empty? && !hash.empty? ? DISCARDED : filtered_hash
|
81
|
+
end
|
82
|
+
|
83
|
+
def pre_filter_array(array, options)
|
84
|
+
filtered_array = array.each_with_object([]) do |element, filtered|
|
85
|
+
filtered_element = pre_filter_object(element, options)
|
86
|
+
next if discarded?(filtered_element)
|
87
|
+
|
88
|
+
filtered.push(filtered_element)
|
89
|
+
end
|
90
|
+
|
91
|
+
filtered_array.empty? && !array.empty? ? DISCARDED : filtered_array
|
92
|
+
end
|
93
|
+
|
94
|
+
def pre_filter_scalar(scalar, options)
|
95
|
+
return DISCARDED if options.key?(:include) && !scalar.to_s.match?(options[:include])
|
96
|
+
return DISCARDED if options.key?(:exclude) && scalar.to_s.match?(options[:exclude])
|
97
|
+
|
98
|
+
scalar
|
99
|
+
end
|
100
|
+
|
101
|
+
# `nil`, empty enumerable objects, and `false` are all valid in their
|
102
|
+
# own right as application data, so pre-filtering uses a special value
|
103
|
+
# to indicate that filtered out data has been discarded
|
104
|
+
def discarded?(object)
|
105
|
+
object == DISCARDED
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -1,29 +1,29 @@
|
|
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 AttributeProcessing
|
8
8
|
module_function
|
9
9
|
|
10
|
-
EMPTY_HASH_STRING_LITERAL =
|
11
|
-
EMPTY_ARRAY_STRING_LITERAL =
|
10
|
+
EMPTY_HASH_STRING_LITERAL = '{}'.freeze
|
11
|
+
EMPTY_ARRAY_STRING_LITERAL = '[]'.freeze
|
12
12
|
|
13
13
|
def flatten_and_coerce(object, prefix = nil, result = {}, &blk)
|
14
|
-
if object.is_a?
|
14
|
+
if object.is_a?(Hash)
|
15
15
|
flatten_and_coerce_hash(object, prefix, result, &blk)
|
16
|
-
elsif object.is_a?
|
16
|
+
elsif object.is_a?(Array)
|
17
17
|
flatten_and_coerce_array(object, prefix, result, &blk)
|
18
18
|
elsif prefix
|
19
19
|
val = Coerce.scalar(object)
|
20
20
|
if blk
|
21
|
-
|
21
|
+
yield(prefix, val)
|
22
22
|
elsif !val.nil?
|
23
23
|
result[prefix] = val
|
24
24
|
end
|
25
25
|
else
|
26
|
-
NewRelic::Agent.logger.warn
|
26
|
+
NewRelic::Agent.logger.warn("Unexpected object: #{object.inspect} with nil prefix passed to NewRelic::Agent::AttributeProcessing.flatten_and_coerce")
|
27
27
|
end
|
28
28
|
result
|
29
29
|
end
|
@@ -31,7 +31,7 @@ module NewRelic
|
|
31
31
|
def flatten_and_coerce_hash(hash, prefix, result, &blk)
|
32
32
|
if hash.empty?
|
33
33
|
if blk
|
34
|
-
|
34
|
+
yield(prefix, EMPTY_HASH_STRING_LITERAL)
|
35
35
|
else
|
36
36
|
result[prefix] = EMPTY_HASH_STRING_LITERAL
|
37
37
|
end
|
@@ -46,7 +46,7 @@ module NewRelic
|
|
46
46
|
def flatten_and_coerce_array(array, prefix, result, &blk)
|
47
47
|
if array.empty?
|
48
48
|
if blk
|
49
|
-
|
49
|
+
yield(prefix, EMPTY_ARRAY_STRING_LITERAL)
|
50
50
|
else
|
51
51
|
result[prefix] = EMPTY_ARRAY_STRING_LITERAL
|
52
52
|
end
|
@@ -1,13 +1,13 @@
|
|
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/attribute_processing'
|
6
6
|
|
7
7
|
module NewRelic
|
8
8
|
module Agent
|
9
9
|
class Attributes
|
10
|
-
KEY_LIMIT
|
10
|
+
KEY_LIMIT = 255
|
11
11
|
VALUE_LIMIT = 255
|
12
12
|
COUNT_LIMIT = 64
|
13
13
|
|
@@ -34,7 +34,7 @@ module NewRelic
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def add_agent_attribute_with_key_check(key, value, default_destinations)
|
37
|
-
if exceeds_bytesize_limit?
|
37
|
+
if exceeds_bytesize_limit?(key, KEY_LIMIT)
|
38
38
|
NewRelic::Agent.logger.debug("Agent attribute #{key} was dropped for exceeding key length limit #{KEY_LIMIT}")
|
39
39
|
return
|
40
40
|
end
|
@@ -58,6 +58,7 @@ module NewRelic
|
|
58
58
|
def merge_custom_attributes(other)
|
59
59
|
return unless Agent.config[:'custom_attributes.enabled']
|
60
60
|
return if other.empty?
|
61
|
+
|
61
62
|
AttributeProcessing.flatten_and_coerce(other) do |k, v|
|
62
63
|
add_custom_attribute(k, v)
|
63
64
|
end
|
@@ -73,7 +74,7 @@ module NewRelic
|
|
73
74
|
|
74
75
|
def intrinsic_attributes_for(destination)
|
75
76
|
if destination == NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER ||
|
76
|
-
|
77
|
+
destination == NewRelic::Agent::AttributeFilter::DST_ERROR_COLLECTOR
|
77
78
|
@intrinsic_attributes
|
78
79
|
else
|
79
80
|
NewRelic::EMPTY_HASH
|
@@ -1,10 +1,11 @@
|
|
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 'logger'
|
6
6
|
require 'fileutils'
|
7
7
|
require 'new_relic/agent/hostname'
|
8
|
+
require 'new_relic/agent/instrumentation/logger/instrumentation'
|
8
9
|
|
9
10
|
module NewRelic
|
10
11
|
module Agent
|
@@ -28,11 +29,12 @@ module NewRelic
|
|
28
29
|
|
29
30
|
def log_request_headers(uri, headers)
|
30
31
|
return unless enabled? && allowed_endpoint?(uri)
|
32
|
+
|
31
33
|
@log.info("REQUEST HEADERS: #{headers}")
|
32
34
|
rescue StandardError, SystemStackError, SystemCallError => e
|
33
|
-
::NewRelic::Agent.logger.warn(
|
35
|
+
::NewRelic::Agent.logger.warn('Failed writing request headers to audit log', e)
|
34
36
|
rescue Exception => e
|
35
|
-
::NewRelic::Agent.logger.warn(
|
37
|
+
::NewRelic::Agent.logger.warn('Failed writing request headers to audit log with exception. Re-raising in case of interrupt.', e)
|
36
38
|
raise
|
37
39
|
end
|
38
40
|
|
@@ -48,9 +50,9 @@ module NewRelic
|
|
48
50
|
@log.info("REQUEST: #{uri}")
|
49
51
|
@log.info("REQUEST BODY: #{request_body}")
|
50
52
|
rescue StandardError, SystemStackError, SystemCallError => e
|
51
|
-
::NewRelic::Agent.logger.warn(
|
53
|
+
::NewRelic::Agent.logger.warn('Failed writing to audit log', e)
|
52
54
|
rescue Exception => e
|
53
|
-
::NewRelic::Agent.logger.warn(
|
55
|
+
::NewRelic::Agent.logger.warn('Failed writing to audit log with exception. Re-raising in case of interrupt.', e)
|
54
56
|
raise
|
55
57
|
end
|
56
58
|
|
@@ -62,7 +64,7 @@ module NewRelic
|
|
62
64
|
if wants_stdout?
|
63
65
|
# Using $stdout global for easier reassignment in testing
|
64
66
|
@log = ::Logger.new($stdout)
|
65
|
-
::NewRelic::Agent.logger.info(
|
67
|
+
::NewRelic::Agent.logger.info('Audit log enabled to STDOUT')
|
66
68
|
elsif path = ensure_log_path
|
67
69
|
@log = ::Logger.new(path)
|
68
70
|
::NewRelic::Agent.logger.info("Audit log enabled at '#{path}'")
|
@@ -70,6 +72,9 @@ module NewRelic
|
|
70
72
|
@log = NewRelic::Agent::NullLogger.new
|
71
73
|
end
|
72
74
|
|
75
|
+
# Never have agent log forwarding capture audits
|
76
|
+
NewRelic::Agent::Instrumentation::Logger.mark_skip_instrumenting(@log)
|
77
|
+
|
73
78
|
@log.formatter = create_log_formatter
|
74
79
|
end
|
75
80
|
|
@@ -90,13 +95,13 @@ module NewRelic
|
|
90
95
|
end
|
91
96
|
|
92
97
|
def wants_stdout?
|
93
|
-
::NewRelic::Agent.config[:'audit_log.path'].
|
98
|
+
::NewRelic::Agent.config[:'audit_log.path'].casecmp(NewRelic::STANDARD_OUT) == 0
|
94
99
|
end
|
95
100
|
|
96
101
|
def create_log_formatter
|
97
102
|
@hostname = NewRelic::Agent::Hostname.get
|
98
103
|
@prefix = wants_stdout? ? '** [NewRelic]' : ''
|
99
|
-
|
104
|
+
proc do |severity, time, progname, msg|
|
100
105
|
"#{@prefix}[#{time} #{@hostname} (#{$$})] : #{msg}\n"
|
101
106
|
end
|
102
107
|
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,25 +18,32 @@ module NewRelic
|
|
18
18
|
module Autostart
|
19
19
|
extend self
|
20
20
|
|
21
|
-
|
22
21
|
# The constants, executables (i.e. $0) and rake tasks used can be
|
23
22
|
# configured with the config keys 'autostart.denylisted_constants',
|
24
23
|
# 'autostart.denylisted_executables' and
|
25
24
|
# 'autostart.denylisted_rake_tasks'
|
26
25
|
def agent_should_start?
|
27
|
-
|
26
|
+
!denylisted_constants? &&
|
28
27
|
!denylisted_executables? &&
|
29
28
|
!in_denylisted_rake_task?
|
30
29
|
end
|
31
30
|
|
32
|
-
COMMA =
|
31
|
+
COMMA = ','.freeze
|
33
32
|
|
34
33
|
def denylisted_constants?
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
denylisted?(NewRelic::Agent.config[:'autostart.denylisted_constants']) do |name|
|
35
|
+
if RUBY_PLATFORM.eql?('java')
|
36
|
+
# As of JRuby 9.3.4.0, Object.const_defined? will still cross
|
37
|
+
# namespaces to find constants, which is not what we want. This
|
38
|
+
# behavior is similar to CRuby's Object.const_get prior to v2.6.
|
39
|
+
#
|
40
|
+
# Example:
|
41
|
+
# irb> class MyClass; end; module MyModule; end
|
42
|
+
# irb> Object.const_defined?('MyModule::MyClass') # => true
|
43
|
+
!!::NewRelic::LanguageSupport.constantize(name)
|
44
|
+
else
|
45
|
+
Object.const_defined?(name)
|
46
|
+
end
|
40
47
|
end
|
41
48
|
end
|
42
49
|
|
@@ -46,23 +53,17 @@ module NewRelic
|
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
49
|
-
# Lookup whether namespaced constants (e.g. ::Foo::Bar::Baz) are in the
|
50
|
-
# environment.
|
51
|
-
def constant_is_defined?(const_name)
|
52
|
-
!!::NewRelic::LanguageSupport.constantize(const_name)
|
53
|
-
end
|
54
|
-
|
55
56
|
def denylisted?(value, &block)
|
56
57
|
value.split(/\s*,\s*/).any?(&block)
|
57
58
|
end
|
58
59
|
|
59
60
|
def in_denylisted_rake_task?
|
60
61
|
tasks = begin
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
::Rake.application.top_level_tasks
|
63
|
+
rescue => e
|
64
|
+
::NewRelic::Agent.logger.debug("Not in Rake environment so skipping denylisted_rake_tasks check: #{e}")
|
65
|
+
NewRelic::EMPTY_ARRAY
|
66
|
+
end
|
66
67
|
!(tasks & ::NewRelic::Agent.config[:'autostart.denylisted_rake_tasks'].split(/\s*,\s*/)).empty?
|
67
68
|
end
|
68
69
|
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
|
# This class is used by NewRelic::Agent.set_sql_obfuscator to chain multiple
|
6
6
|
# obfuscation blocks when not using the default :replace action
|
@@ -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
|
@@ -9,9 +9,9 @@ module NewRelic
|
|
9
9
|
attr_reader :id, :name, :arguments
|
10
10
|
|
11
11
|
def initialize(raw_collector_command)
|
12
|
-
@id
|
13
|
-
@name
|
14
|
-
@arguments = raw_collector_command[1][
|
12
|
+
@id = raw_collector_command[0]
|
13
|
+
@name = raw_collector_command[1]['name']
|
14
|
+
@arguments = raw_collector_command[1]['arguments']
|
15
15
|
end
|
16
16
|
end
|
17
17
|
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
|
# This class is the central point for dispatching get_agent_commands messages
|
6
6
|
# to the various components that actually process them.
|
@@ -19,17 +19,18 @@ module NewRelic
|
|
19
19
|
|
20
20
|
attr_accessor :thread_profiler_session, :backtrace_service
|
21
21
|
|
22
|
-
def initialize(event_listener=nil)
|
23
|
-
@handlers
|
22
|
+
def initialize(event_listener = nil)
|
23
|
+
@handlers = Hash.new { |*| proc { |cmd| self.unrecognized_agent_command(cmd) } }
|
24
24
|
|
25
25
|
@backtrace_service = Threading::BacktraceService.new(event_listener)
|
26
26
|
|
27
27
|
@thread_profiler_session = ThreadProfilerSession.new(@backtrace_service)
|
28
28
|
|
29
|
-
@handlers['start_profiler'] =
|
30
|
-
@handlers['stop_profiler']
|
29
|
+
@handlers['start_profiler'] = proc { |cmd| thread_profiler_session.handle_start_command(cmd) }
|
30
|
+
@handlers['stop_profiler'] = proc { |cmd| thread_profiler_session.handle_stop_command(cmd) }
|
31
31
|
|
32
|
-
|
32
|
+
# the following statement needs else branch coverage
|
33
|
+
if event_listener # rubocop:disable Style/SafeNavigation
|
33
34
|
event_listener.subscribe(:before_shutdown, &method(:on_before_shutdown))
|
34
35
|
end
|
35
36
|
end
|
@@ -63,6 +64,7 @@ module NewRelic
|
|
63
64
|
# Same with reset! - we don't support asynchronous cancellation of a
|
64
65
|
# running thread profile currently.
|
65
66
|
def merge!(*args); end
|
67
|
+
|
66
68
|
def reset!; end
|
67
69
|
|
68
70
|
def harvest_from_thread_profiler_session
|
@@ -76,17 +78,17 @@ module NewRelic
|
|
76
78
|
|
77
79
|
def log_profiles(profiles)
|
78
80
|
if profiles.empty?
|
79
|
-
::NewRelic::Agent.logger.debug
|
81
|
+
::NewRelic::Agent.logger.debug('No thread profiles with data found to send.')
|
80
82
|
else
|
81
83
|
profile_descriptions = profiles.map { |p| p.to_log_description }
|
82
|
-
::NewRelic::Agent.logger.debug
|
84
|
+
::NewRelic::Agent.logger.debug("Sending thread profiles [#{profile_descriptions.join(', ')}]")
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
88
|
def get_agent_commands
|
87
89
|
commands = new_relic_service.get_agent_commands
|
88
|
-
NewRelic::Agent.logger.debug
|
89
|
-
commands.map {|collector_command| AgentCommand.new(collector_command)}
|
90
|
+
NewRelic::Agent.logger.debug("Received get_agent_commands = #{commands.inspect}")
|
91
|
+
commands.map { |collector_command| AgentCommand.new(collector_command) }
|
90
92
|
end
|
91
93
|
|
92
94
|
def invoke_commands(agent_commands)
|
@@ -112,15 +114,15 @@ module NewRelic
|
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
115
|
-
SUCCESS_RESULT =
|
116
|
-
ERROR_KEY =
|
117
|
+
SUCCESS_RESULT = NewRelic::EMPTY_HASH
|
118
|
+
ERROR_KEY = 'error'
|
117
119
|
|
118
120
|
def success
|
119
121
|
SUCCESS_RESULT
|
120
122
|
end
|
121
123
|
|
122
124
|
def error(err)
|
123
|
-
{
|
125
|
+
{ERROR_KEY => err.message}
|
124
126
|
end
|
125
127
|
|
126
128
|
def call_handler_for(agent_command)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
# This file is distributed under New Relic's license terms.
|
3
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require 'new_relic/agent/threading/agent_thread'
|
6
6
|
require 'new_relic/agent/threading/backtrace_service'
|
@@ -9,9 +9,7 @@ require 'new_relic/agent/threading/thread_profile'
|
|
9
9
|
module NewRelic
|
10
10
|
module Agent
|
11
11
|
module Commands
|
12
|
-
|
13
12
|
class ThreadProfilerSession
|
14
|
-
|
15
13
|
def initialize(backtrace_service)
|
16
14
|
@backtrace_service = backtrace_service
|
17
15
|
@started_at = nil
|
@@ -27,31 +25,34 @@ module NewRelic
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def handle_stop_command(agent_command)
|
30
|
-
report_data = agent_command.arguments.fetch(
|
28
|
+
report_data = agent_command.arguments.fetch('report_data', true)
|
31
29
|
stop(report_data)
|
32
30
|
end
|
33
31
|
|
34
32
|
def start(agent_command)
|
35
|
-
NewRelic::Agent.logger.debug(
|
33
|
+
NewRelic::Agent.logger.debug('Starting Thread Profiler.')
|
36
34
|
profile = @backtrace_service.subscribe(
|
37
35
|
NewRelic::Agent::Threading::BacktraceService::ALL_TRANSACTIONS,
|
38
36
|
agent_command.arguments
|
39
37
|
)
|
40
38
|
|
41
|
-
@started_at =
|
39
|
+
@started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
42
40
|
@duration = profile.duration if profile
|
43
41
|
end
|
44
42
|
|
45
43
|
def stop(report_data)
|
46
44
|
return unless running?
|
47
|
-
|
45
|
+
|
46
|
+
NewRelic::Agent.logger.debug('Stopping Thread Profiler.')
|
48
47
|
@finished_profile = @backtrace_service.harvest(NewRelic::Agent::Threading::BacktraceService::ALL_TRANSACTIONS)
|
49
48
|
@backtrace_service.unsubscribe(NewRelic::Agent::Threading::BacktraceService::ALL_TRANSACTIONS)
|
50
49
|
@finished_profile = nil if !report_data
|
51
50
|
end
|
52
51
|
|
53
52
|
def harvest
|
54
|
-
NewRelic::Agent.logger.debug(
|
53
|
+
NewRelic::Agent.logger.debug(
|
54
|
+
"Harvesting from Thread Profiler #{@finished_profile&.to_log_description}"
|
55
|
+
)
|
55
56
|
profile = @finished_profile
|
56
57
|
@backtrace_service.profile_agent_code = false
|
57
58
|
@finished_profile = nil
|
@@ -72,7 +73,9 @@ module NewRelic
|
|
72
73
|
end
|
73
74
|
|
74
75
|
def past_time?
|
75
|
-
@started_at && (
|
76
|
+
@started_at && (
|
77
|
+
Process.clock_gettime(Process::CLOCK_REALTIME) > @started_at + @duration
|
78
|
+
)
|
76
79
|
end
|
77
80
|
|
78
81
|
def stopped?
|
@@ -86,9 +89,9 @@ module NewRelic
|
|
86
89
|
end
|
87
90
|
|
88
91
|
def raise_unsupported_error
|
89
|
-
msg =
|
90
|
-
Thread profiling is not supported for Resque processes. If you did not intend to
|
91
|
-
profile a Resque process, profiling again might select an appropriate agent.
|
92
|
+
msg = <<~EOF
|
93
|
+
Thread profiling is not supported for Resque processes. If you did not intend to
|
94
|
+
profile a Resque process, profiling again might select an appropriate agent.
|
92
95
|
EOF
|
93
96
|
raise_command_error(msg)
|
94
97
|
end
|
@@ -99,10 +102,9 @@ profile a Resque process, profiling again might select an appropriate agent.
|
|
99
102
|
end
|
100
103
|
|
101
104
|
def raise_already_started_error
|
102
|
-
msg =
|
105
|
+
msg = 'Profile already in progress. Ignoring agent command to start another.'
|
103
106
|
raise_command_error(msg)
|
104
107
|
end
|
105
|
-
|
106
108
|
end
|
107
109
|
end
|
108
110
|
end
|