newrelic_rpm 9.1.0 → 9.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.build_ignore +27 -0
- data/CHANGELOG.md +841 -7
- data/CONTRIBUTING.md +2 -9
- data/README.md +25 -22
- data/Rakefile +2 -2
- data/bin/newrelic +3 -9
- data/bin/newrelic_rpm +15 -0
- data/init.rb +2 -2
- data/lib/boot/strap.rb +102 -0
- data/lib/new_relic/agent/agent.rb +11 -2
- data/lib/new_relic/agent/agent_helpers/connect.rb +13 -8
- data/lib/new_relic/agent/agent_helpers/harvest.rb +3 -0
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +4 -1
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +4 -3
- data/lib/new_relic/agent/agent_helpers/startup.rb +11 -3
- data/lib/new_relic/agent/agent_logger.rb +3 -1
- data/lib/new_relic/agent/attribute_filter.rb +3 -3
- data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
- data/lib/new_relic/agent/aws.rb +68 -0
- data/lib/new_relic/agent/configuration/default_source.rb +918 -166
- data/lib/new_relic/agent/configuration/environment_source.rb +15 -3
- data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
- data/lib/new_relic/agent/configuration/manager.rb +72 -11
- data/lib/new_relic/agent/configuration/security_policy_source.rb +11 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +22 -2
- data/lib/new_relic/agent/connect/request_builder.rb +1 -1
- data/lib/new_relic/agent/custom_event_aggregator.rb +27 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +11 -11
- data/lib/new_relic/agent/database/obfuscator.rb +1 -0
- data/lib/new_relic/agent/database.rb +41 -1
- data/lib/new_relic/agent/database_adapter.rb +1 -1
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +1 -1
- data/lib/new_relic/agent/datastores/redis.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +4 -8
- data/lib/new_relic/agent/distributed_tracing.rb +5 -3
- data/lib/new_relic/agent/error_collector.rb +40 -11
- data/lib/new_relic/agent/event_loop.rb +1 -1
- data/lib/new_relic/agent/external.rb +2 -0
- data/lib/new_relic/agent/harvester.rb +1 -1
- data/lib/new_relic/agent/health_check.rb +136 -0
- data/lib/new_relic/agent/http_clients/abstract.rb +4 -0
- data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +80 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -3
- data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +109 -0
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +0 -3
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +1 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +0 -3
- data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +91 -0
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +1 -4
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +0 -3
- data/lib/new_relic/agent/http_clients/uri_util.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_dispatch.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_mailbox.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_mailer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_job.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +6 -2
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -16
- data/lib/new_relic/agent/instrumentation/active_record.rb +8 -13
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +8 -5
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +13 -10
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +9 -16
- 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 +17 -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 +21 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -3
- 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 +27 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_firehose.rb +22 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/instrumentation.rb +91 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_kinesis.rb +22 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/chain.rb +33 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/instrumentation.rb +93 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda/prepend.rb +23 -0
- data/lib/new_relic/agent/instrumentation/aws_sdk_lambda.rb +23 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs/chain.rb +37 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs/instrumentation.rb +67 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs/prepend.rb +21 -0
- data/lib/new_relic/agent/instrumentation/aws_sqs.rb +23 -0
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +23 -0
- data/lib/new_relic/agent/instrumentation/bunny.rb +4 -5
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +3 -4
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +2 -3
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +5 -2
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +4 -5
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -23
- data/lib/new_relic/agent/instrumentation/dynamodb/chain.rb +27 -0
- data/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +64 -0
- data/lib/new_relic/agent/instrumentation/dynamodb/prepend.rb +19 -0
- data/lib/new_relic/agent/instrumentation/dynamodb.rb +23 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +65 -10
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +2 -4
- 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 +35 -0
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -0
- data/lib/new_relic/agent/instrumentation/excon.rb +1 -17
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +11 -4
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +2 -6
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +10 -3
- data/lib/new_relic/agent/instrumentation/fiber.rb +1 -3
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -3
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +5 -2
- data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +2 -2
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httpclient.rb +1 -5
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +0 -1
- 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 +23 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -3
- data/lib/new_relic/agent/instrumentation/logstasher/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/logstasher/instrumentation.rb +24 -0
- data/lib/new_relic/agent/instrumentation/logstasher/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/logstasher.rb +25 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +4 -2
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +13 -4
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +4 -2
- data/lib/new_relic/agent/instrumentation/memcache.rb +4 -5
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +3 -5
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +13 -3
- data/lib/new_relic/agent/instrumentation/net_http.rb +2 -1
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +4 -2
- data/lib/new_relic/agent/instrumentation/opensearch/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb +66 -0
- data/lib/new_relic/agent/instrumentation/opensearch/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/opensearch.rb +23 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +3 -3
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +10 -5
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -2
- data/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +72 -0
- data/lib/new_relic/agent/instrumentation/rdkafka/instrumentation.rb +70 -0
- data/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +67 -0
- data/lib/new_relic/agent/instrumentation/rdkafka.rb +25 -0
- data/lib/new_relic/agent/instrumentation/redis/cluster_middleware.rb +26 -0
- data/lib/new_relic/agent/instrumentation/redis/constants.rb +2 -2
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +18 -11
- data/lib/new_relic/agent/instrumentation/redis/middleware.rb +3 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +11 -5
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +8 -6
- 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/ruby_kafka/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka/instrumentation.rb +67 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +60 -0
- data/lib/new_relic/agent/instrumentation/ruby_kafka.rb +25 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai/chain.rb +36 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai/instrumentation.rb +196 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/ruby_openai.rb +35 -0
- data/lib/new_relic/agent/instrumentation/sequel.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delay_extensions.rb +24 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +13 -16
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -3
- data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -19
- data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
- data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +98 -0
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +1 -5
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread.rb +0 -2
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/tilt.rb +0 -4
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +7 -3
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +0 -1
- data/lib/new_relic/agent/instrumentation/view_component/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +45 -0
- data/lib/{tasks/instrumentation_generator/templates/instrumentation.tt → new_relic/agent/instrumentation/view_component/prepend.rb} +4 -4
- data/lib/new_relic/agent/instrumentation/view_component.rb +24 -0
- data/lib/new_relic/agent/javascript_instrumentor.rb +2 -4
- data/lib/new_relic/agent/llm/chat_completion_message.rb +25 -0
- data/lib/new_relic/agent/llm/chat_completion_summary.rb +66 -0
- data/lib/new_relic/agent/llm/embedding.rb +60 -0
- data/lib/new_relic/agent/llm/llm_event.rb +95 -0
- data/lib/new_relic/agent/llm/response_headers.rb +80 -0
- data/lib/new_relic/agent/llm.rb +49 -0
- data/lib/new_relic/agent/local_log_decorator.rb +20 -3
- data/lib/new_relic/agent/log_event_aggregator.rb +149 -26
- data/lib/new_relic/agent/log_event_attributes.rb +115 -0
- data/lib/new_relic/agent/logging.rb +5 -5
- data/lib/new_relic/agent/messaging.rb +18 -7
- data/lib/new_relic/agent/method_tracer.rb +4 -1
- data/lib/new_relic/agent/method_tracer_helpers.rb +26 -5
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +1 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
- data/lib/new_relic/agent/new_relic_service/encoders.rb +2 -2
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
- data/lib/new_relic/agent/new_relic_service.rb +61 -28
- data/lib/new_relic/agent/obfuscator.rb +0 -2
- data/lib/new_relic/agent/opentelemetry/context/propagation/trace_propagator.rb +66 -0
- data/lib/new_relic/agent/opentelemetry/context/propagation.rb +15 -0
- data/lib/{tasks/instrumentation_generator/templates/Envfile.tt → new_relic/agent/opentelemetry/context.rb} +9 -5
- data/lib/new_relic/agent/opentelemetry/trace/span.rb +31 -0
- data/lib/new_relic/agent/opentelemetry/trace/tracer.rb +129 -0
- data/lib/new_relic/agent/opentelemetry/trace/tracer_provider.rb +18 -0
- data/lib/new_relic/agent/opentelemetry/trace.rb +15 -0
- data/lib/new_relic/agent/opentelemetry/transaction_patch.rb +69 -0
- data/lib/new_relic/agent/opentelemetry_bridge.rb +32 -0
- data/lib/new_relic/agent/parameter_filtering.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +2 -2
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -2
- data/lib/new_relic/agent/rules_engine.rb +1 -1
- data/lib/new_relic/agent/sampler.rb +1 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/memory_sampler.rb +1 -1
- data/lib/new_relic/agent/serverless_handler.rb +406 -0
- data/lib/new_relic/agent/serverless_handler_event_sources.json +155 -0
- data/lib/new_relic/agent/serverless_handler_event_sources.rb +49 -0
- data/lib/new_relic/agent/span_event_primitive.rb +32 -15
- data/lib/new_relic/agent/sql_sampler.rb +0 -1
- data/lib/new_relic/agent/system_info.rb +40 -0
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -2
- data/lib/new_relic/agent/threading/backtrace_node.rb +10 -1
- data/lib/new_relic/agent/tracer.rb +16 -16
- data/lib/new_relic/agent/transaction/abstract_segment.rb +103 -41
- data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +3 -3
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +7 -8
- data/lib/new_relic/agent/transaction/external_request_segment.rb +5 -12
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -3
- data/lib/new_relic/agent/transaction/request_attributes.rb +54 -11
- data/lib/new_relic/agent/transaction/trace_context.rb +34 -5
- data/lib/new_relic/agent/transaction/tracing.rb +20 -4
- data/lib/new_relic/agent/transaction.rb +38 -13
- data/lib/new_relic/agent/transaction_error_primitive.rb +39 -19
- data/lib/new_relic/agent/transaction_event_primitive.rb +19 -0
- data/lib/new_relic/agent/transaction_time_aggregator.rb +1 -1
- data/lib/new_relic/agent/utilization/ecs.rb +22 -0
- data/lib/new_relic/agent/utilization/ecs_v4.rb +22 -0
- data/lib/new_relic/agent/utilization/gcp.rb +1 -3
- data/lib/new_relic/agent/utilization/vendor.rb +5 -7
- data/lib/new_relic/agent/utilization_data.rb +40 -5
- data/lib/new_relic/agent/vm/{mri_vm.rb → c_ruby_vm.rb} +10 -18
- data/lib/new_relic/agent/vm.rb +2 -2
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +286 -17
- data/lib/new_relic/base64.rb +25 -0
- data/lib/new_relic/cli/command.rb +6 -3
- data/lib/new_relic/constants.rb +8 -0
- data/lib/new_relic/control/class_methods.rb +1 -7
- data/lib/new_relic/control/frameworks/grape.rb +14 -0
- data/lib/new_relic/control/frameworks/padrino.rb +14 -0
- data/lib/new_relic/control/frameworks/rails.rb +17 -5
- data/lib/new_relic/control/frameworks/rails4.rb +1 -3
- data/lib/new_relic/control/frameworks/roda.rb +20 -0
- data/lib/new_relic/control/instance_methods.rb +13 -0
- data/lib/new_relic/control/instrumentation.rb +2 -16
- data/lib/new_relic/control/private_instance_methods.rb +4 -0
- data/lib/new_relic/control/security_interface.rb +57 -0
- data/lib/new_relic/control.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +25 -13
- data/lib/new_relic/environment_report.rb +2 -2
- data/lib/new_relic/helper.rb +22 -0
- data/lib/new_relic/language_support.rb +12 -1
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/local_environment.rb +31 -18
- data/lib/new_relic/noticed_error.rb +5 -2
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +0 -16
- data/lib/new_relic/rack/browser_monitoring.rb +29 -13
- data/lib/new_relic/supportability_helper.rb +5 -1
- data/lib/new_relic/thread_local_storage.rb +31 -0
- data/lib/new_relic/traced_thread.rb +2 -3
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/new_relic_instrumentation.rb +4 -3
- data/lib/tasks/bump_version.rake +21 -0
- data/lib/tasks/config.rake +11 -5
- data/lib/tasks/coverage_report.rake +1 -1
- data/lib/tasks/gha.rake +31 -0
- data/lib/tasks/helpers/config.html.erb +94 -0
- data/lib/tasks/helpers/format.rb +11 -7
- data/lib/tasks/helpers/newrelicyml.rb +211 -0
- data/lib/tasks/helpers/version_bump.rb +62 -0
- data/lib/tasks/newrelic.rb +1 -0
- data/lib/tasks/newrelicyml.rake +13 -0
- data/lib/tasks/tests.rake +71 -0
- data/newrelic.yml +657 -251
- data/newrelic_rpm.gemspec +17 -10
- data/test/agent_helper.rb +38 -4
- metadata +230 -44
- data/.gitignore +0 -43
- data/.project +0 -23
- data/.rubocop.yml +0 -1909
- data/.rubocop_todo.yml +0 -61
- data/.simplecov +0 -15
- data/.snyk +0 -11
- data/.yardopts +0 -27
- data/Brewfile +0 -12
- data/DOCKER.md +0 -167
- data/Dockerfile +0 -10
- data/Guardfile +0 -26
- data/bin/newrelic_cmd +0 -6
- data/config/database.yml +0 -5
- data/config.dot +0 -278
- data/docker-compose.yml +0 -107
- data/lefthook.yml +0 -9
- data/lib/new_relic/agent/range_extensions.rb +0 -27
- data/lib/tasks/helpers/removers.rb +0 -33
- data/lib/tasks/instrumentation_generator/README.md +0 -63
- data/lib/tasks/instrumentation_generator/TODO.md +0 -33
- data/lib/tasks/instrumentation_generator/instrumentation.thor +0 -121
- data/lib/tasks/instrumentation_generator/templates/chain.tt +0 -22
- data/lib/tasks/instrumentation_generator/templates/chain_method.tt +0 -8
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +0 -29
- data/lib/tasks/instrumentation_generator/templates/instrumentation_method.tt +0 -3
- data/lib/tasks/instrumentation_generator/templates/newrelic.yml.tt +0 -19
- data/lib/tasks/instrumentation_generator/templates/prepend.tt +0 -13
- data/lib/tasks/instrumentation_generator/templates/prepend_method.tt +0 -3
- data/lib/tasks/instrumentation_generator/templates/test.tt +0 -15
- data/lib/tasks/multiverse.rake +0 -6
- data/lib/tasks/multiverse.rb +0 -83
|
@@ -156,7 +156,7 @@ module NewRelic
|
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
if !errors.empty?
|
|
159
|
-
::NewRelic::Agent.logger.error("#{errors.size} error(s) running task for event '#{event}' in
|
|
159
|
+
::NewRelic::Agent.logger.error("#{errors.size} error(s) running task for event '#{event}' in agent event loop:", *errors)
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
@@ -29,6 +29,7 @@ module NewRelic
|
|
|
29
29
|
#
|
|
30
30
|
# @param request_metadata [String] received obfuscated request metadata
|
|
31
31
|
#
|
|
32
|
+
# @!scope class
|
|
32
33
|
# @api public
|
|
33
34
|
#
|
|
34
35
|
def process_request_metadata(request_metadata)
|
|
@@ -74,6 +75,7 @@ module NewRelic
|
|
|
74
75
|
#
|
|
75
76
|
# @return [String] obfuscated response metadata to send
|
|
76
77
|
#
|
|
78
|
+
# @!scope class
|
|
77
79
|
# @api public
|
|
78
80
|
#
|
|
79
81
|
def get_response_metadata
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
class HealthCheck
|
|
8
|
+
def initialize
|
|
9
|
+
@start_time = nano_time
|
|
10
|
+
@continue = true
|
|
11
|
+
@status = HEALTHY
|
|
12
|
+
# the following assignments may set @continue = false if they are invalid
|
|
13
|
+
set_enabled
|
|
14
|
+
set_delivery_location
|
|
15
|
+
set_frequency
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
HEALTHY = {healthy: true, last_error: 'NR-APM-000', message: 'Healthy'}.freeze
|
|
19
|
+
INVALID_LICENSE_KEY = {healthy: false, last_error: 'NR-APM-001', message: 'Invalid license key (HTTP status code 401)'}.freeze
|
|
20
|
+
MISSING_LICENSE_KEY = {healthy: false, last_error: 'NR-APM-002', message: 'License key missing in configuration'}.freeze
|
|
21
|
+
FORCED_DISCONNECT = {healthy: false, last_error: 'NR-APM-003', message: 'Forced disconnect received from New Relic (HTTP status code 410)'}.freeze
|
|
22
|
+
HTTP_ERROR = {healthy: false, last_error: 'NR-APM-004', message: 'HTTP error response code [%s] recevied from New Relic while sending data type [%s]'}.freeze
|
|
23
|
+
MISSING_APP_NAME = {healthy: false, last_error: 'NR-APM-005', message: 'Missing application name in agent configuration'}.freeze
|
|
24
|
+
APP_NAME_EXCEEDED = {healthy: false, last_error: 'NR-APM-006', message: 'The maximum number of configured app names (3) exceeded'}.freeze
|
|
25
|
+
PROXY_CONFIG_ERROR = {healthy: false, last_error: 'NR-APM-007', message: 'HTTP Proxy configuration error; response code [%s]'}.freeze
|
|
26
|
+
AGENT_DISABLED = {healthy: false, last_error: 'NR-APM-008', message: 'Agent is disabled via configuration'}.freeze
|
|
27
|
+
FAILED_TO_CONNECT = {healthy: false, last_error: 'NR-APM-009', message: 'Failed to connect to New Relic data collector'}.freeze
|
|
28
|
+
FAILED_TO_PARSE_CONFIG = {healthy: false, last_error: 'NR-APM-010', message: 'Agent config file is not able to be parsed'}.freeze
|
|
29
|
+
SHUTDOWN = {healthy: true, last_error: 'NR-APM-099', message: 'Agent has shutdown'}.freeze
|
|
30
|
+
|
|
31
|
+
def create_and_run_health_check_loop
|
|
32
|
+
return unless health_checks_enabled? && @continue
|
|
33
|
+
|
|
34
|
+
NewRelic::Agent.logger.debug('Agent Control health check conditions met. Starting health checks.')
|
|
35
|
+
NewRelic::Agent.record_metric('Supportability/AgentControl/Health/enabled', 1)
|
|
36
|
+
|
|
37
|
+
Thread.new do
|
|
38
|
+
while @continue
|
|
39
|
+
begin
|
|
40
|
+
sleep @frequency
|
|
41
|
+
write_file
|
|
42
|
+
@continue = false if @status == SHUTDOWN
|
|
43
|
+
rescue StandardError => e
|
|
44
|
+
NewRelic::Agent.logger.error("Aborting Agent Control health check. Error raised: #{e}")
|
|
45
|
+
@continue = false
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def update_status(status, options = [])
|
|
52
|
+
return unless @continue
|
|
53
|
+
|
|
54
|
+
@status = status.dup
|
|
55
|
+
update_message(options) unless options.empty?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def healthy?
|
|
59
|
+
@status == HEALTHY
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def set_enabled
|
|
65
|
+
@enabled = if ENV['NEW_RELIC_AGENT_CONTROL_ENABLED'] == 'true'
|
|
66
|
+
true
|
|
67
|
+
else
|
|
68
|
+
NewRelic::Agent.logger.debug('NEW_RELIC_AGENT_CONTROL_ENABLED not true, disabling health checks')
|
|
69
|
+
@continue = false
|
|
70
|
+
false
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def set_delivery_location
|
|
75
|
+
@delivery_location = if ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_DELIVERY_LOCATION']
|
|
76
|
+
# The spec states file paths for the delivery location will begin with file://
|
|
77
|
+
# This does not create a valid path in Ruby, so remove the prefix when present
|
|
78
|
+
ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_DELIVERY_LOCATION']&.gsub('file://', '')
|
|
79
|
+
else
|
|
80
|
+
# The spec default is 'file:///newrelic/apm/health', but since we're just going to remove it anyway...
|
|
81
|
+
'/newrelic/apm/health'
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def set_frequency
|
|
86
|
+
@frequency = ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_FREQUENCY'] ? ENV['NEW_RELIC_AGENT_CONTROL_HEALTH_FREQUENCY'].to_i : 5
|
|
87
|
+
|
|
88
|
+
if @frequency <= 0
|
|
89
|
+
NewRelic::Agent.logger.debug('NEW_RELIC_AGENT_CONTROL_HEALTH_FREQUENCY zero or less, disabling health checks')
|
|
90
|
+
@continue = false
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def contents
|
|
95
|
+
<<~CONTENTS
|
|
96
|
+
healthy: #{@status[:healthy]}
|
|
97
|
+
status: #{@status[:message]}#{last_error}
|
|
98
|
+
start_time_unix_nano: #{@start_time}
|
|
99
|
+
status_time_unix_nano: #{nano_time}
|
|
100
|
+
CONTENTS
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def last_error
|
|
104
|
+
@status[:healthy] ? '' : "\nlast_error: #{@status[:last_error]}"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def nano_time
|
|
108
|
+
Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def file_name
|
|
112
|
+
"health-#{NewRelic::Agent::GuidGenerator.generate_guid(32)}.yml"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def write_file
|
|
116
|
+
@file ||= "#{@delivery_location}/#{file_name}"
|
|
117
|
+
|
|
118
|
+
File.write(@file, contents)
|
|
119
|
+
rescue StandardError => e
|
|
120
|
+
NewRelic::Agent.logger.error("Agent Control health check raised an error while writing a file: #{e}")
|
|
121
|
+
@continue = false
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def health_checks_enabled?
|
|
125
|
+
@enabled && @delivery_location && @frequency > 0
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def update_message(options)
|
|
129
|
+
@status[:message] = sprintf(@status[:message], *options)
|
|
130
|
+
rescue StandardError => e
|
|
131
|
+
NewRelic::Agent.logger.debug("Error raised while updating Agent Control health check message: #{e}." \
|
|
132
|
+
"options = #{options}, @status[:message] = #{@status[:message]}")
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
require_relative 'abstract'
|
|
6
|
+
require 'resolv'
|
|
7
|
+
|
|
8
|
+
module NewRelic
|
|
9
|
+
module Agent
|
|
10
|
+
module HTTPClients
|
|
11
|
+
class AsyncHTTPResponse < AbstractResponse
|
|
12
|
+
def get_status_code
|
|
13
|
+
get_status_code_using(:status)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def [](key)
|
|
17
|
+
to_hash[key.downcase]&.first
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_hash
|
|
21
|
+
@wrapped_response.headers.to_h
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class AsyncHTTPRequest < AbstractRequest
|
|
26
|
+
def initialize(connection, method, url, headers)
|
|
27
|
+
@connection = connection
|
|
28
|
+
@method = method
|
|
29
|
+
@url = ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(url)
|
|
30
|
+
@headers = headers
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
ASYNC_HTTP = 'Async::HTTP'
|
|
34
|
+
|
|
35
|
+
def type
|
|
36
|
+
ASYNC_HTTP
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def host_from_header
|
|
40
|
+
if hostname = (self[LHOST] || self[UHOST])
|
|
41
|
+
hostname.split(COLON).first
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def host
|
|
46
|
+
host_from_header || uri.host.to_s
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def [](key)
|
|
50
|
+
return headers[key] unless headers.is_a?(Array)
|
|
51
|
+
|
|
52
|
+
headers.each do |header|
|
|
53
|
+
return header[1] if header[0].casecmp?(key)
|
|
54
|
+
end
|
|
55
|
+
nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def []=(key, value)
|
|
59
|
+
if headers.is_a?(Array)
|
|
60
|
+
headers << [key, value]
|
|
61
|
+
else
|
|
62
|
+
headers[key] = value
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def uri
|
|
67
|
+
@url
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def headers
|
|
71
|
+
@headers
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def method
|
|
75
|
+
@method
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -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
|
+
require 'uri'
|
|
6
|
+
require_relative 'abstract'
|
|
7
|
+
|
|
8
|
+
module NewRelic
|
|
9
|
+
module Agent
|
|
10
|
+
module HTTPClients
|
|
11
|
+
class EthonHTTPResponse < AbstractResponse
|
|
12
|
+
def initialize(easy)
|
|
13
|
+
@easy = easy
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def status_code
|
|
17
|
+
@easy.response_code
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def [](key)
|
|
21
|
+
headers[format_key(key)]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def headers
|
|
25
|
+
# Ethon::Easy#response_headers will return '' if headers are unset
|
|
26
|
+
@easy.response_headers.scan(/\n([^:]+?): ([^:\n]+?)\r/).each_with_object({}) do |pair, hash|
|
|
27
|
+
hash[format_key(pair[0])] = pair[1]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
alias to_hash headers
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def format_key(key)
|
|
35
|
+
key.tr('-', '_').downcase
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class EthonHTTPRequest < AbstractRequest
|
|
40
|
+
attr_reader :uri
|
|
41
|
+
|
|
42
|
+
DEFAULT_ACTION = 'GET'
|
|
43
|
+
DEFAULT_HOST = 'UNKNOWN_HOST'
|
|
44
|
+
ETHON = 'Ethon'
|
|
45
|
+
|
|
46
|
+
def initialize(easy)
|
|
47
|
+
@easy = easy
|
|
48
|
+
@uri = uri_from_easy
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def type
|
|
52
|
+
ETHON
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def host_from_header
|
|
56
|
+
self[LHOST] || self[UHOST]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def uri_from_easy
|
|
60
|
+
# anticipate `Ethon::Easy#url` being `example.com` without a protocol
|
|
61
|
+
# defined and use an 'http' protocol prefix for `URI.parse` to work
|
|
62
|
+
# with the URL as desired
|
|
63
|
+
url_str = @easy.url.match?(':') ? @easy.url : "http://#{@easy.url}"
|
|
64
|
+
begin
|
|
65
|
+
URI.parse(url_str)
|
|
66
|
+
rescue URI::InvalidURIError => e
|
|
67
|
+
NewRelic::Agent.logger.debug("Failed to parse URI '#{url_str}': #{e.class} - #{e.message}")
|
|
68
|
+
URI.parse(NewRelic::EMPTY_STR)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def host
|
|
73
|
+
host_from_header || uri.host&.downcase || DEFAULT_HOST
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def method
|
|
77
|
+
return DEFAULT_ACTION unless @easy.instance_variable_defined?(action_instance_var)
|
|
78
|
+
|
|
79
|
+
@easy.instance_variable_get(action_instance_var)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def action_instance_var
|
|
83
|
+
NewRelic::Agent::Instrumentation::Ethon::Easy::ACTION_INSTANCE_VAR
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def []=(key, value)
|
|
87
|
+
headers[key] = value
|
|
88
|
+
@easy.headers = headers
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def headers
|
|
92
|
+
@headers ||= if @easy.instance_variable_defined?(headers_instance_var)
|
|
93
|
+
@easy.instance_variable_get(headers_instance_var)
|
|
94
|
+
else
|
|
95
|
+
{}
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def headers_instance_var
|
|
100
|
+
NewRelic::Agent::Instrumentation::Ethon::Easy::HEADERS_INSTANCE_VAR
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def [](key)
|
|
104
|
+
headers[key]
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -20,8 +20,6 @@ module NewRelic
|
|
|
20
20
|
|
|
21
21
|
class HTTPRequest < AbstractRequest
|
|
22
22
|
HTTP_RB = 'http.rb'
|
|
23
|
-
HOST = 'host'
|
|
24
|
-
COLON = ':'
|
|
25
23
|
|
|
26
24
|
def initialize(wrapped_request)
|
|
27
25
|
@wrapped_request = wrapped_request
|
|
@@ -36,7 +34,7 @@ module NewRelic
|
|
|
36
34
|
end
|
|
37
35
|
|
|
38
36
|
def host_from_header
|
|
39
|
-
if hostname = self[
|
|
37
|
+
if hostname = self[LHOST]
|
|
40
38
|
hostname.split(COLON).first
|
|
41
39
|
end
|
|
42
40
|
end
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
require_relative 'abstract'
|
|
6
|
+
|
|
7
|
+
module NewRelic
|
|
8
|
+
module Agent
|
|
9
|
+
module HTTPClients
|
|
10
|
+
# HTTPX returns an instance of HTTPX::ErrorResponse on error,
|
|
11
|
+
# and that instance itself yields the underlying HTTP response
|
|
12
|
+
# object via #response, but depending on the error that HTTP
|
|
13
|
+
# response object could be unset.
|
|
14
|
+
class HTTPXErrorResponse
|
|
15
|
+
def status; end
|
|
16
|
+
def headers; {}; end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class HTTPXHTTPResponse < AbstractResponse
|
|
20
|
+
def initialize(response)
|
|
21
|
+
if response.is_a?(::HTTPX::ErrorResponse)
|
|
22
|
+
@response = response.response || HTTPXErrorResponse.new
|
|
23
|
+
else
|
|
24
|
+
@response = response
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def status_code
|
|
29
|
+
@response.status
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def [](key)
|
|
33
|
+
headers[format_key(key)]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def headers
|
|
37
|
+
headers ||= @response.headers.to_hash.each_with_object({}) do |(k, v), h|
|
|
38
|
+
h[format_key(k)] = v
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
alias to_hash headers
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def format_key(key)
|
|
46
|
+
key.tr('-', '_').downcase
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class HTTPXHTTPRequest < AbstractRequest
|
|
51
|
+
attr_reader :uri
|
|
52
|
+
|
|
53
|
+
DEFAULT_HOST = 'UNKNOWN_HOST'
|
|
54
|
+
TYPE = 'HTTPX'
|
|
55
|
+
|
|
56
|
+
def initialize(request)
|
|
57
|
+
@request = request
|
|
58
|
+
@uri = request.uri
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def type
|
|
62
|
+
TYPE
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def host_from_header
|
|
66
|
+
self[LHOST] || self[UHOST]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def host
|
|
70
|
+
host_from_header || uri.host&.downcase || DEFAULT_HOST
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def method
|
|
74
|
+
@request.verb
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def []=(key, value)
|
|
78
|
+
@request.headers[key] = value
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def headers
|
|
82
|
+
@request.headers
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def [](key)
|
|
86
|
+
@request.headers[key]
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -23,7 +23,7 @@ module NewRelic
|
|
|
23
23
|
|
|
24
24
|
def metric_name(name, payload)
|
|
25
25
|
controller_name = controller_name_for_metric(payload)
|
|
26
|
-
"Ruby/ActionController#{"/#{controller_name}" if controller_name}/#{name.gsub(
|
|
26
|
+
"Ruby/ActionController#{"/#{controller_name}" if controller_name}/#{name.gsub('.action_controller', '')}"
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def controller_name_for_metric(payload)
|
|
@@ -16,7 +16,7 @@ DependencyDetection.defer do
|
|
|
16
16
|
defined?(ActionDispatch) &&
|
|
17
17
|
defined?(ActionPack) &&
|
|
18
18
|
ActionPack.respond_to?(:gem_version) &&
|
|
19
|
-
ActionPack.gem_version >=
|
|
19
|
+
NewRelic::Helper.version_satisfied?(ActionPack.gem_version, '>=', '6.0.0') && # notifications for dispatch added in Rails 6
|
|
20
20
|
!NewRelic::Agent::Instrumentation::ActionDispatchSubscriber.subscribed?
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -15,7 +15,7 @@ DependencyDetection.defer do
|
|
|
15
15
|
defined?(ActiveSupport) &&
|
|
16
16
|
defined?(ActionMailbox) &&
|
|
17
17
|
ActionMailbox.respond_to?(:gem_version) && # 'require "action_mailbox"' doesn't require version...
|
|
18
|
-
ActionMailbox.gem_version >=
|
|
18
|
+
NewRelic::Helper.version_satisfied?(ActionMailbox.gem_version, '>=', '7.1.0.alpha') && # notifications added in Rails 7.1
|
|
19
19
|
!NewRelic::Agent::Instrumentation::ActionMailboxSubscriber.subscribed?
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -15,7 +15,7 @@ DependencyDetection.defer do
|
|
|
15
15
|
defined?(ActiveSupport) &&
|
|
16
16
|
defined?(ActionMailer) &&
|
|
17
17
|
ActionMailer.respond_to?(:gem_version) &&
|
|
18
|
-
ActionMailer.gem_version >=
|
|
18
|
+
NewRelic::Helper.version_satisfied?(ActionMailer.gem_version, '>=', '5.0') &&
|
|
19
19
|
!NewRelic::Agent::Instrumentation::ActionMailerSubscriber.subscribed?
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -30,7 +30,7 @@ DependencyDetection.defer do
|
|
|
30
30
|
executes do
|
|
31
31
|
if defined?(ActiveSupport) &&
|
|
32
32
|
ActiveJob.respond_to?(:gem_version) &&
|
|
33
|
-
ActiveJob.gem_version >=
|
|
33
|
+
NewRelic::Helper.version_satisfied?(ActiveJob.gem_version, '>=', '6.0.0') &&
|
|
34
34
|
!NewRelic::Agent.config[:disable_activejob] &&
|
|
35
35
|
!NewRelic::Agent::Instrumentation::ActiveJobSubscriber.subscribed?
|
|
36
36
|
NewRelic::Agent.logger.info('Installing notifications based ActiveJob instrumentation')
|
|
@@ -8,7 +8,7 @@ module NewRelic
|
|
|
8
8
|
module Agent
|
|
9
9
|
module Instrumentation
|
|
10
10
|
class ActiveJobSubscriber < NotificationsSubscriber
|
|
11
|
-
PAYLOAD_KEYS = %i[adapter db_runtime error job wait]
|
|
11
|
+
PAYLOAD_KEYS = %i[adapter db_runtime error job wait jobs]
|
|
12
12
|
|
|
13
13
|
def add_segment_params(segment, payload)
|
|
14
14
|
PAYLOAD_KEYS.each do |key|
|
|
@@ -16,8 +16,12 @@ module NewRelic
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# NOTE: For `enqueue_all.active_job`, only the first job is used to determine the queue.
|
|
20
|
+
# Therefore, this assumes all jobs given as arguments for perform_all_later share the same queue.
|
|
19
21
|
def metric_name(name, payload)
|
|
20
|
-
|
|
22
|
+
job = payload[:job] || payload[:jobs].first
|
|
23
|
+
|
|
24
|
+
queue = job.queue_name
|
|
21
25
|
method = method_from_name(name)
|
|
22
26
|
"Ruby/ActiveJob/#{queue}/#{method}"
|
|
23
27
|
end
|
|
@@ -27,25 +27,12 @@ DependencyDetection.defer do
|
|
|
27
27
|
actions = [:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update]
|
|
28
28
|
actions.each do |operation|
|
|
29
29
|
if implemented_methods.include?(operation)
|
|
30
|
-
add_method_tracer operation, [->
|
|
31
|
-
->
|
|
32
|
-
->
|
|
30
|
+
add_method_tracer operation, [->(*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
|
|
31
|
+
->(*) { "ActiveMerchant/gateway/#{gateway_name}" },
|
|
32
|
+
->(*) { "ActiveMerchant/operation/#{operation}" }]
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
|
-
|
|
39
|
-
executes do
|
|
40
|
-
next unless Gem::Version.new(ActiveMerchant::VERSION) < Gem::Version.new('1.65.0')
|
|
41
|
-
|
|
42
|
-
deprecation_msg = 'The Ruby Agent is dropping support for ActiveMerchant versions below 1.65.0 ' \
|
|
43
|
-
'in version 9.0.0. Please upgrade your ActiveMerchant version to continue receiving full support. ' \
|
|
44
|
-
|
|
45
|
-
NewRelic::Agent.logger.log_once(
|
|
46
|
-
:warn,
|
|
47
|
-
:deprecated_active_merchant_version,
|
|
48
|
-
deprecation_msg
|
|
49
|
-
)
|
|
50
|
-
end
|
|
51
38
|
end
|