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
|
@@ -0,0 +1,26 @@
|
|
|
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::Agent::Instrumentation
|
|
6
|
+
module RedisClient
|
|
7
|
+
module ClusterMiddleware
|
|
8
|
+
include NewRelic::Agent::Instrumentation::Redis
|
|
9
|
+
|
|
10
|
+
# Until we decide to move our Redis instrumentation entirely off patches
|
|
11
|
+
# keep the middleware instrumentation for the call and connect methods
|
|
12
|
+
# limited to the redis-clustering instrumentation.
|
|
13
|
+
#
|
|
14
|
+
# Redis's middleware option does not capture errors as high in the stack
|
|
15
|
+
# as our patches. Leaving the patches for call and connect on the main
|
|
16
|
+
# Redis gem limits the feature disparity our customers experience.
|
|
17
|
+
def call(*args, &block)
|
|
18
|
+
call_with_tracing(args[0]) { super }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def connect(*args, &block)
|
|
22
|
+
connect_with_tracing { super }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -6,12 +6,12 @@ module NewRelic::Agent::Instrumentation::Redis
|
|
|
6
6
|
class Constants
|
|
7
7
|
PRODUCT_NAME = 'Redis'
|
|
8
8
|
CONNECT = 'connect'
|
|
9
|
-
UNKNOWN =
|
|
9
|
+
UNKNOWN = NewRelic::UNKNOWN_LOWER
|
|
10
10
|
LOCALHOST = 'localhost'
|
|
11
11
|
MULTI_OPERATION = 'multi'
|
|
12
12
|
PIPELINE_OPERATION = 'pipeline'
|
|
13
13
|
HAS_REDIS_CLIENT = defined?(::Redis) &&
|
|
14
|
-
|
|
14
|
+
NewRelic::Helper.version_satisfied?(::Redis::VERSION, '>=', '5.0.0') &&
|
|
15
15
|
!defined?(::RedisClient).nil?
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -6,15 +6,17 @@ require_relative 'constants'
|
|
|
6
6
|
|
|
7
7
|
module NewRelic::Agent::Instrumentation
|
|
8
8
|
module Redis
|
|
9
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
|
10
|
+
|
|
9
11
|
def connect_with_tracing
|
|
10
|
-
with_tracing(Constants::CONNECT, database:
|
|
12
|
+
with_tracing(Constants::CONNECT, database: _nr_db) { yield }
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def call_with_tracing(command, &block)
|
|
14
16
|
operation = command[0]
|
|
15
17
|
statement = ::NewRelic::Agent::Datastores::Redis.format_command(command)
|
|
16
18
|
|
|
17
|
-
with_tracing(operation, statement: statement, database:
|
|
19
|
+
with_tracing(operation, statement: statement, database: _nr_db) { yield }
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
# Used for Redis 4.x and 3.x
|
|
@@ -22,27 +24,22 @@ module NewRelic::Agent::Instrumentation
|
|
|
22
24
|
operation = pipeline.is_a?(::Redis::Pipeline::Multi) ? Constants::MULTI_OPERATION : Constants::PIPELINE_OPERATION
|
|
23
25
|
statement = ::NewRelic::Agent::Datastores::Redis.format_pipeline_commands(pipeline.commands)
|
|
24
26
|
|
|
25
|
-
with_tracing(operation, statement: statement, database:
|
|
27
|
+
with_tracing(operation, statement: statement, database: _nr_db) { yield }
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
# Used for Redis 5.x+
|
|
29
31
|
def call_pipelined_with_tracing(pipeline)
|
|
30
|
-
db = begin
|
|
31
|
-
_nr_redis_client_config.db
|
|
32
|
-
rescue StandardError => e
|
|
33
|
-
NewRelic::Agent.logger.error("Failed to determine configured Redis db value: #{e.class} - #{e.message}")
|
|
34
|
-
nil
|
|
35
|
-
end
|
|
36
|
-
|
|
37
32
|
operation = pipeline.flatten.include?('MULTI') ? Constants::MULTI_OPERATION : Constants::PIPELINE_OPERATION
|
|
38
33
|
statement = ::NewRelic::Agent::Datastores::Redis.format_pipeline_commands(pipeline)
|
|
39
34
|
|
|
40
|
-
with_tracing(operation, statement: statement, database:
|
|
35
|
+
with_tracing(operation, statement: statement, database: _nr_db) { yield }
|
|
41
36
|
end
|
|
42
37
|
|
|
43
38
|
private
|
|
44
39
|
|
|
45
40
|
def with_tracing(operation, statement: nil, database: nil)
|
|
41
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
42
|
+
|
|
46
43
|
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
|
47
44
|
product: Constants::PRODUCT_NAME,
|
|
48
45
|
operation: operation,
|
|
@@ -90,5 +87,15 @@ module NewRelic::Agent::Instrumentation
|
|
|
90
87
|
config
|
|
91
88
|
end
|
|
92
89
|
end
|
|
90
|
+
|
|
91
|
+
def _nr_db
|
|
92
|
+
# db is a method on the Redis client in versions < 5.x
|
|
93
|
+
return db if respond_to?(:db)
|
|
94
|
+
# db is accessible through the RedisClient::Config object in versions > 5.x
|
|
95
|
+
return _nr_redis_client_config.db if _nr_redis_client_config.respond_to?(:db)
|
|
96
|
+
rescue StandardError => e
|
|
97
|
+
NewRelic::Agent.logger.debug("Failed to determine configured Redis db value: #{e.class} - #{e.message}")
|
|
98
|
+
nil
|
|
99
|
+
end
|
|
93
100
|
end
|
|
94
101
|
end
|
|
@@ -6,6 +6,9 @@ module NewRelic::Agent::Instrumentation
|
|
|
6
6
|
module RedisClient
|
|
7
7
|
module Middleware
|
|
8
8
|
# This module is used to instrument Redis 5.x+
|
|
9
|
+
#
|
|
10
|
+
# It only instruments call_pipelined because connect and call are accessed
|
|
11
|
+
# too late in the stack to capture all errors
|
|
9
12
|
include NewRelic::Agent::Instrumentation::Redis
|
|
10
13
|
|
|
11
14
|
def call_pipelined(*args, &block)
|
|
@@ -10,6 +10,7 @@ require_relative 'redis/chain'
|
|
|
10
10
|
require_relative 'redis/constants'
|
|
11
11
|
require_relative 'redis/prepend'
|
|
12
12
|
require_relative 'redis/middleware'
|
|
13
|
+
require_relative 'redis/cluster_middleware'
|
|
13
14
|
|
|
14
15
|
DependencyDetection.defer do
|
|
15
16
|
# Why not :redis? newrelic-redis used that name, so avoid conflicting
|
|
@@ -30,15 +31,20 @@ DependencyDetection.defer do
|
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
executes do
|
|
33
|
-
NewRelic::Agent.logger.info('Installing Redis Instrumentation')
|
|
34
34
|
if NewRelic::Agent::Instrumentation::Redis::Constants::HAS_REDIS_CLIENT
|
|
35
35
|
RedisClient.register(NewRelic::Agent::Instrumentation::RedisClient::Middleware)
|
|
36
|
+
|
|
37
|
+
if defined?(Redis::Cluster::Client)
|
|
38
|
+
RedisClient.register(NewRelic::Agent::Instrumentation::RedisClient::ClusterMiddleware)
|
|
39
|
+
end
|
|
36
40
|
end
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
unless defined?(Redis::Cluster::Client)
|
|
43
|
+
if use_prepend?
|
|
44
|
+
prepend_instrument Redis::Client, NewRelic::Agent::Instrumentation::Redis::Prepend
|
|
45
|
+
else
|
|
46
|
+
chain_instrument NewRelic::Agent::Instrumentation::Redis::Chain
|
|
47
|
+
end
|
|
42
48
|
end
|
|
43
49
|
end
|
|
44
50
|
end
|
|
@@ -6,7 +6,11 @@ module NewRelic::Agent::Instrumentation
|
|
|
6
6
|
module Resque
|
|
7
7
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
|
8
8
|
|
|
9
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
|
10
|
+
|
|
9
11
|
def with_tracing
|
|
12
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
13
|
+
|
|
10
14
|
begin
|
|
11
15
|
perform_action_with_newrelic_trace(
|
|
12
16
|
:name => 'perform',
|
|
@@ -15,15 +15,17 @@ DependencyDetection.defer do
|
|
|
15
15
|
|
|
16
16
|
# Airbrake uses method chaining on Resque::Job on versions < 11.0.3
|
|
17
17
|
conflicts_with_prepend do
|
|
18
|
-
defined?(Airbrake) && defined?(Airbrake::AIRBRAKE_VERSION) &&
|
|
18
|
+
defined?(Airbrake) && defined?(Airbrake::AIRBRAKE_VERSION) && NewRelic::Helper.version_satisfied?(Airbrake::AIRBRAKE_VERSION, '<', '11.0.3')
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
executes do
|
|
22
|
-
NewRelic::Agent.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
if NewRelic::Agent.config[:'resque.use_ruby_dns'] &&
|
|
23
|
+
NewRelic::Agent.config[:dispatcher] == :resque &&
|
|
24
|
+
# resolv-replace is no longer part of the language in Ruby 3.4.
|
|
25
|
+
# we don't believe this lib is still necessary for Ruby 3.4 users.
|
|
26
|
+
# however, if we receive customer feedback to the contrary, we can find
|
|
27
|
+
# an alternate approach.
|
|
28
|
+
NewRelic::Helper.version_satisfied?(RUBY_VERSION, '<', '3.4')
|
|
27
29
|
NewRelic::Agent.logger.info('Requiring resolv-replace')
|
|
28
30
|
require 'resolv'
|
|
29
31
|
require 'resolv-replace'
|
|
@@ -0,0 +1,43 @@
|
|
|
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::Agent::Instrumentation
|
|
6
|
+
module Roda
|
|
7
|
+
module Chain
|
|
8
|
+
def self.instrument!
|
|
9
|
+
::Roda.class_eval do
|
|
10
|
+
include ::NewRelic::Agent::Instrumentation::Roda::Tracer
|
|
11
|
+
|
|
12
|
+
alias_method(:_roda_handle_main_route_without_tracing, :_roda_handle_main_route)
|
|
13
|
+
|
|
14
|
+
def _roda_handle_main_route(*args)
|
|
15
|
+
_roda_handle_main_route_with_tracing(*args) do
|
|
16
|
+
_roda_handle_main_route_without_tracing(*args)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module Build
|
|
24
|
+
module Chain
|
|
25
|
+
def self.instrument!
|
|
26
|
+
::Roda.class_eval do
|
|
27
|
+
include ::NewRelic::Agent::Instrumentation::Roda::Tracer
|
|
28
|
+
|
|
29
|
+
class << self
|
|
30
|
+
alias_method(:build_rack_app_without_tracing, :build_rack_app)
|
|
31
|
+
|
|
32
|
+
def build_rack_app
|
|
33
|
+
build_rack_app_with_tracing do
|
|
34
|
+
build_rack_app_without_tracing
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
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::Agent::Instrumentation
|
|
6
|
+
module Roda
|
|
7
|
+
module Ignorer
|
|
8
|
+
def self.should_ignore?(app, type)
|
|
9
|
+
return false unless app.opts.include?(:newrelic_ignores)
|
|
10
|
+
|
|
11
|
+
app.opts[:newrelic_ignores][type].any? do |pattern|
|
|
12
|
+
pattern === app.request.path_info
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def newrelic_ignore(*routes)
|
|
17
|
+
set_newrelic_ignore(:routes, *routes)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def newrelic_ignore_apdex(*routes)
|
|
21
|
+
set_newrelic_ignore(:apdex, *routes)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def newrelic_ignore_enduser(*routes)
|
|
25
|
+
set_newrelic_ignore(:enduser, *routes)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def set_newrelic_ignore(type, *routes)
|
|
31
|
+
# Create a newrelic_ignores hash if one doesn't exist
|
|
32
|
+
opts[:newrelic_ignores] = Hash.new([]) if !opts.include?(:newrelic_ignores)
|
|
33
|
+
|
|
34
|
+
if routes.empty?
|
|
35
|
+
opts[:newrelic_ignores][type] += [Regexp.new('.*')]
|
|
36
|
+
else
|
|
37
|
+
opts[:newrelic_ignores][type] += routes.map do |r|
|
|
38
|
+
# Roda adds leading slashes to routes, so we need to do the same
|
|
39
|
+
"#{'/' unless r.start_with?('/')}#{r}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
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::Agent::Instrumentation
|
|
6
|
+
module Roda
|
|
7
|
+
module Tracer
|
|
8
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
|
9
|
+
|
|
10
|
+
INSTRUMENTATION_NAME = 'Roda'
|
|
11
|
+
|
|
12
|
+
def self.included(clazz)
|
|
13
|
+
clazz.extend(self)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def newrelic_middlewares
|
|
17
|
+
middlewares = [NewRelic::Rack::BrowserMonitoring]
|
|
18
|
+
if NewRelic::Rack::AgentHooks.needed?
|
|
19
|
+
middlewares << NewRelic::Rack::AgentHooks
|
|
20
|
+
end
|
|
21
|
+
middlewares
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def build_rack_app_with_tracing
|
|
25
|
+
unless NewRelic::Agent.config[:disable_roda_auto_middleware]
|
|
26
|
+
newrelic_middlewares.each do |middleware_class|
|
|
27
|
+
self.use middleware_class
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
yield
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Roda makes use of Rack, so we can get params from the request object
|
|
34
|
+
def rack_request_params
|
|
35
|
+
begin
|
|
36
|
+
@_request.params
|
|
37
|
+
rescue => e
|
|
38
|
+
NewRelic::Agent.logger.debug('Failed to get params from Rack request.', e)
|
|
39
|
+
NewRelic::EMPTY_HASH
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def _roda_handle_main_route_with_tracing(*args)
|
|
44
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
45
|
+
|
|
46
|
+
perform_action_with_newrelic_trace(
|
|
47
|
+
category: :roda,
|
|
48
|
+
name: ::NewRelic::Agent::Instrumentation::Roda::TransactionNamer.transaction_name(request),
|
|
49
|
+
params: ::NewRelic::Agent::ParameterFiltering::apply_filters(request.env, rack_request_params)
|
|
50
|
+
) do
|
|
51
|
+
yield
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def do_not_trace?
|
|
56
|
+
NewRelic::Agent::Instrumentation::Roda::Ignorer.should_ignore?(self, :routes)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def ignore_apdex?
|
|
60
|
+
NewRelic::Agent::Instrumentation::Roda::Ignorer.should_ignore?(self, :apdex)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def ignore_enduser?
|
|
64
|
+
NewRelic::Agent::Instrumentation::Roda::Ignorer.should_ignore?(self, :enduser)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
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::Agent::Instrumentation
|
|
6
|
+
module Roda
|
|
7
|
+
module Prepend
|
|
8
|
+
include ::NewRelic::Agent::Instrumentation::Roda::Tracer
|
|
9
|
+
|
|
10
|
+
def _roda_handle_main_route(*args)
|
|
11
|
+
_roda_handle_main_route_with_tracing(*args) { super }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module Build
|
|
16
|
+
module Prepend
|
|
17
|
+
include ::NewRelic::Agent::Instrumentation::Roda::Tracer
|
|
18
|
+
def build_rack_app
|
|
19
|
+
build_rack_app_with_tracing { super }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
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 Instrumentation
|
|
8
|
+
module Roda
|
|
9
|
+
module TransactionNamer
|
|
10
|
+
extend self
|
|
11
|
+
|
|
12
|
+
REGEX_MULTIPLE_SLASHES = %r{^[/^]*(.*?)[/$?]*$}.freeze
|
|
13
|
+
|
|
14
|
+
def transaction_name(request)
|
|
15
|
+
path = request.path || ::NewRelic::Agent::UNKNOWN_METRIC
|
|
16
|
+
name = path.gsub(REGEX_MULTIPLE_SLASHES, '\1') # remove any rogue slashes
|
|
17
|
+
name = NewRelic::ROOT if name.empty?
|
|
18
|
+
name = "#{request.request_method} #{name}" if request.respond_to?(:request_method)
|
|
19
|
+
|
|
20
|
+
name
|
|
21
|
+
rescue => e
|
|
22
|
+
::NewRelic::Agent.logger.debug("#{e.class} : #{e.message} - Error encountered trying to identify Roda transaction name")
|
|
23
|
+
::NewRelic::Agent::UNKNOWN_METRIC
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
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 'roda/instrumentation'
|
|
6
|
+
require_relative 'roda/roda_transaction_namer'
|
|
7
|
+
require_relative 'roda/ignorer'
|
|
8
|
+
|
|
9
|
+
DependencyDetection.defer do
|
|
10
|
+
named :roda
|
|
11
|
+
|
|
12
|
+
depends_on do
|
|
13
|
+
defined?(Roda) &&
|
|
14
|
+
NewRelic::Helper.version_satisfied?(Roda::RodaVersion, '>=', '3.19.0') &&
|
|
15
|
+
Roda::RodaPlugins::Base::ClassMethods.private_method_defined?(:build_rack_app) &&
|
|
16
|
+
Roda::RodaPlugins::Base::InstanceMethods.method_defined?(:_roda_handle_main_route)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
executes do
|
|
20
|
+
require_relative '../../rack/agent_hooks'
|
|
21
|
+
require_relative '../../rack/browser_monitoring'
|
|
22
|
+
|
|
23
|
+
if use_prepend?
|
|
24
|
+
require_relative 'roda/prepend'
|
|
25
|
+
|
|
26
|
+
supportability_name = NewRelic::Agent::Instrumentation::Roda::Tracer::INSTRUMENTATION_NAME
|
|
27
|
+
prepend_instrument Roda.singleton_class, NewRelic::Agent::Instrumentation::Roda::Build::Prepend, supportability_name
|
|
28
|
+
prepend_instrument Roda, NewRelic::Agent::Instrumentation::Roda::Prepend
|
|
29
|
+
else
|
|
30
|
+
require_relative 'roda/chain'
|
|
31
|
+
chain_instrument NewRelic::Agent::Instrumentation::Roda::Build::Chain, supportability_name
|
|
32
|
+
chain_instrument NewRelic::Agent::Instrumentation::Roda::Chain
|
|
33
|
+
end
|
|
34
|
+
Roda.class_eval { extend NewRelic::Agent::Instrumentation::Roda::Ignorer }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
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::Agent::Instrumentation
|
|
6
|
+
module RubyKafka::Chain
|
|
7
|
+
def self.instrument!
|
|
8
|
+
::Kafka::Producer.class_eval do
|
|
9
|
+
include NewRelic::Agent::Instrumentation::RubyKafka
|
|
10
|
+
|
|
11
|
+
alias_method(:produce_without_new_relic, :produce)
|
|
12
|
+
|
|
13
|
+
def produce(value, **kwargs)
|
|
14
|
+
produce_with_new_relic(value, **kwargs) do |headers|
|
|
15
|
+
kwargs[:headers] = headers
|
|
16
|
+
produce_without_new_relic(value, **kwargs)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
::Kafka::Consumer.class_eval do
|
|
22
|
+
include NewRelic::Agent::Instrumentation::RubyKafka
|
|
23
|
+
|
|
24
|
+
alias_method(:each_message_without_new_relic, :each_message)
|
|
25
|
+
|
|
26
|
+
def each_message(*args)
|
|
27
|
+
each_message_without_new_relic(*args) do |message|
|
|
28
|
+
each_message_with_new_relic(message) do
|
|
29
|
+
yield(message)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
::Kafka::Client.class_eval do
|
|
36
|
+
include NewRelic::Agent::Instrumentation::RubyKafkaConfig
|
|
37
|
+
|
|
38
|
+
alias_method(:producer_without_new_relic, :producer)
|
|
39
|
+
alias_method(:consumer_without_new_relic, :consumer)
|
|
40
|
+
|
|
41
|
+
def producer(**kwargs)
|
|
42
|
+
producer_without_new_relic(**kwargs).tap do |producer|
|
|
43
|
+
set_nr_config(producer)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def consumer(**kwargs)
|
|
48
|
+
consumer_without_new_relic(**kwargs).tap do |consumer|
|
|
49
|
+
set_nr_config(consumer)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
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 'new_relic/agent/messaging'
|
|
6
|
+
|
|
7
|
+
module NewRelic::Agent::Instrumentation
|
|
8
|
+
module RubyKafka
|
|
9
|
+
MESSAGING_LIBRARY = 'Kafka'
|
|
10
|
+
PRODUCE = 'Produce'
|
|
11
|
+
CONSUME = 'Consume'
|
|
12
|
+
|
|
13
|
+
INSTRUMENTATION_NAME = 'ruby-kafka'
|
|
14
|
+
|
|
15
|
+
def produce_with_new_relic(value, **kwargs)
|
|
16
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
17
|
+
|
|
18
|
+
topic_name = kwargs[:topic]
|
|
19
|
+
segment = NewRelic::Agent::Tracer.start_message_broker_segment(
|
|
20
|
+
action: :produce,
|
|
21
|
+
library: MESSAGING_LIBRARY,
|
|
22
|
+
destination_type: :topic,
|
|
23
|
+
destination_name: topic_name
|
|
24
|
+
)
|
|
25
|
+
create_kafka_metrics(action: PRODUCE, topic: topic_name)
|
|
26
|
+
|
|
27
|
+
headers = kwargs[:headers] || {}
|
|
28
|
+
::NewRelic::Agent::DistributedTracing.insert_distributed_trace_headers(headers)
|
|
29
|
+
|
|
30
|
+
NewRelic::Agent::Tracer.capture_segment_error(segment) { yield(headers) }
|
|
31
|
+
ensure
|
|
32
|
+
segment&.finish
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def each_message_with_new_relic(message)
|
|
36
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
37
|
+
|
|
38
|
+
headers = message&.headers || {}
|
|
39
|
+
topic_name = message&.topic
|
|
40
|
+
|
|
41
|
+
NewRelic::Agent::Messaging.wrap_message_broker_consume_transaction(
|
|
42
|
+
library: MESSAGING_LIBRARY,
|
|
43
|
+
destination_type: :topic,
|
|
44
|
+
destination_name: topic_name,
|
|
45
|
+
headers: headers,
|
|
46
|
+
action: :consume
|
|
47
|
+
) do
|
|
48
|
+
create_kafka_metrics(action: CONSUME, topic: topic_name)
|
|
49
|
+
yield
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def create_kafka_metrics(action:, topic:)
|
|
54
|
+
@nr_config.each do |seed_broker|
|
|
55
|
+
host = "#{seed_broker&.host}:#{seed_broker&.port}"
|
|
56
|
+
NewRelic::Agent.record_metric("MessageBroker/Kafka/Nodes/#{host}/#{action}/#{topic}", 1)
|
|
57
|
+
NewRelic::Agent.record_metric("MessageBroker/Kafka/Nodes/#{host}", 1)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
module RubyKafkaConfig
|
|
63
|
+
def set_nr_config(producer_or_consumer)
|
|
64
|
+
producer_or_consumer.instance_variable_set(:@nr_config, @seed_brokers)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
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::Agent::Instrumentation
|
|
6
|
+
module RubyKafkaProducer
|
|
7
|
+
module Prepend
|
|
8
|
+
include NewRelic::Agent::Instrumentation::RubyKafka
|
|
9
|
+
|
|
10
|
+
def produce(value, **kwargs)
|
|
11
|
+
produce_with_new_relic(value, **kwargs) do |headers|
|
|
12
|
+
kwargs[:headers] = headers
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module RubyKafkaConsumer
|
|
20
|
+
module Prepend
|
|
21
|
+
include NewRelic::Agent::Instrumentation::RubyKafka
|
|
22
|
+
|
|
23
|
+
if NewRelic::Helper.version_satisfied?(RUBY_VERSION, '>=', '3')
|
|
24
|
+
def each_message(**args)
|
|
25
|
+
super do |message|
|
|
26
|
+
each_message_with_new_relic(message) do
|
|
27
|
+
yield(message)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
def each_message(*args)
|
|
33
|
+
super do |message|
|
|
34
|
+
each_message_with_new_relic(message) do
|
|
35
|
+
yield(message)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
module RubyKafkaClient
|
|
44
|
+
module Prepend
|
|
45
|
+
include NewRelic::Agent::Instrumentation::RubyKafkaConfig
|
|
46
|
+
|
|
47
|
+
def producer(**kwargs)
|
|
48
|
+
super.tap do |producer|
|
|
49
|
+
set_nr_config(producer)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def consumer(**kwargs)
|
|
54
|
+
super.tap do |consumer|
|
|
55
|
+
set_nr_config(consumer)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
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 'ruby_kafka/instrumentation'
|
|
6
|
+
require_relative 'ruby_kafka/chain'
|
|
7
|
+
require_relative 'ruby_kafka/prepend'
|
|
8
|
+
|
|
9
|
+
DependencyDetection.defer do
|
|
10
|
+
named :'ruby_kafka'
|
|
11
|
+
|
|
12
|
+
depends_on do
|
|
13
|
+
defined?(Kafka)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
executes do
|
|
17
|
+
if use_prepend?
|
|
18
|
+
prepend_instrument Kafka::Producer, NewRelic::Agent::Instrumentation::RubyKafkaProducer::Prepend
|
|
19
|
+
prepend_instrument Kafka::Consumer, NewRelic::Agent::Instrumentation::RubyKafkaConsumer::Prepend
|
|
20
|
+
prepend_instrument Kafka::Client, NewRelic::Agent::Instrumentation::RubyKafkaClient::Prepend
|
|
21
|
+
else
|
|
22
|
+
chain_instrument NewRelic::Agent::Instrumentation::RubyKafka::Chain
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|