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,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
|
+
module NewRelic::Agent::Instrumentation
|
|
6
|
+
module Kinesis
|
|
7
|
+
INSTRUMENTED_METHODS = %w[
|
|
8
|
+
add_tags_to_stream
|
|
9
|
+
create_stream
|
|
10
|
+
decrease_stream_retention_period
|
|
11
|
+
delete_stream
|
|
12
|
+
describe_limits
|
|
13
|
+
describe_stream
|
|
14
|
+
disable_enhanced_monitoring
|
|
15
|
+
enable_enhanced_monitoring
|
|
16
|
+
get_records
|
|
17
|
+
get_shard_iterator
|
|
18
|
+
increase_stream_retention_period
|
|
19
|
+
list_streams
|
|
20
|
+
list_tags_for_stream
|
|
21
|
+
merge_shards
|
|
22
|
+
put_record
|
|
23
|
+
put_records
|
|
24
|
+
remove_tags_from_stream
|
|
25
|
+
split_shard
|
|
26
|
+
update_shard_count
|
|
27
|
+
].freeze
|
|
28
|
+
|
|
29
|
+
KINESIS = 'Kinesis'
|
|
30
|
+
AWS_KINESIS_DATA_STREAMS = 'aws_kinesis_data_streams'
|
|
31
|
+
MESSAGE_BROKER_SEGMENT_METHODS = %w[put_record put_records get_records].freeze
|
|
32
|
+
|
|
33
|
+
def instrument_method_with_new_relic(method_name, *args)
|
|
34
|
+
return yield unless NewRelic::Agent::Tracer.tracing_enabled?
|
|
35
|
+
|
|
36
|
+
NewRelic::Agent.record_instrumentation_invocation(KINESIS)
|
|
37
|
+
params = args[0]
|
|
38
|
+
arn = get_arn(params) if params
|
|
39
|
+
|
|
40
|
+
if MESSAGE_BROKER_SEGMENT_METHODS.include?(method_name)
|
|
41
|
+
stream_name = get_stream_name(params, arn)
|
|
42
|
+
segment = NewRelic::Agent::Tracer.start_message_broker_segment(
|
|
43
|
+
action: method_name == 'get_records' ? :consume : :produce,
|
|
44
|
+
library: KINESIS,
|
|
45
|
+
destination_type: :stream,
|
|
46
|
+
destination_name: stream_name
|
|
47
|
+
)
|
|
48
|
+
else
|
|
49
|
+
segment = NewRelic::Agent::Tracer.start_segment(name: get_segment_name(method_name, params))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
segment&.add_agent_attribute('cloud.resource_id', arn) if arn
|
|
53
|
+
|
|
54
|
+
begin
|
|
55
|
+
NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
|
|
56
|
+
ensure
|
|
57
|
+
segment&.add_agent_attribute('cloud.platform', AWS_KINESIS_DATA_STREAMS)
|
|
58
|
+
segment&.finish
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def get_segment_name(method_name, params)
|
|
63
|
+
stream_name = params&.dig(:stream_name)
|
|
64
|
+
return "#{KINESIS}/#{method_name}/#{stream_name}" if stream_name
|
|
65
|
+
|
|
66
|
+
"#{KINESIS}/#{method_name}"
|
|
67
|
+
rescue => e
|
|
68
|
+
NewRelic::Agent.logger.warn("Failed to create segment name: #{e}")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def get_stream_name(params, arn)
|
|
72
|
+
params&.dig(:stream_name) || arn.split('/').last || NewRelic::UNKNOWN_LOWER
|
|
73
|
+
rescue => e
|
|
74
|
+
NewRelic::Agent.logger.warn("Failed to get stream name: #{e}")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def nr_account_id
|
|
78
|
+
return @nr_account_id if defined?(@nr_account_id)
|
|
79
|
+
|
|
80
|
+
@nr_account_id = NewRelic::Agent::Aws.get_account_id(config)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def get_arn(params)
|
|
84
|
+
stream_arn = params&.dig(:stream_arn)
|
|
85
|
+
return stream_arn if stream_arn
|
|
86
|
+
|
|
87
|
+
stream_name = params&.dig(:stream_name)
|
|
88
|
+
NewRelic::Agent::Aws.create_arn(KINESIS.downcase, "stream/#{stream_name}", config&.region, nr_account_id) if stream_name
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
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 Kinesis::Prepend
|
|
7
|
+
include NewRelic::Agent::Instrumentation::Kinesis
|
|
8
|
+
|
|
9
|
+
INSTRUMENTED_METHODS.each do |method_name|
|
|
10
|
+
define_method(method_name) do |*args|
|
|
11
|
+
instrument_method_with_new_relic(method_name, *args) { super(*args) }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
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 'aws_sdk_kinesis/instrumentation'
|
|
6
|
+
require_relative 'aws_sdk_kinesis/chain'
|
|
7
|
+
require_relative 'aws_sdk_kinesis/prepend'
|
|
8
|
+
|
|
9
|
+
DependencyDetection.defer do
|
|
10
|
+
named :aws_sdk_kinesis
|
|
11
|
+
|
|
12
|
+
depends_on do
|
|
13
|
+
defined?(Aws::Kinesis::Client)
|
|
14
|
+
end
|
|
15
|
+
executes do
|
|
16
|
+
if use_prepend?
|
|
17
|
+
prepend_instrument Aws::Kinesis::Client, NewRelic::Agent::Instrumentation::Kinesis::Prepend
|
|
18
|
+
else
|
|
19
|
+
chain_instrument NewRelic::Agent::Instrumentation::Kinesis::Chain
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
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 'instrumentation'
|
|
6
|
+
|
|
7
|
+
module NewRelic::Agent::Instrumentation
|
|
8
|
+
module AwsSdkLambda::Chain
|
|
9
|
+
def self.instrument!
|
|
10
|
+
::Aws::Lambda::Client.class_eval do
|
|
11
|
+
include NewRelic::Agent::Instrumentation::AwsSdkLambda
|
|
12
|
+
|
|
13
|
+
alias_method(:invoke_without_new_relic, :invoke)
|
|
14
|
+
|
|
15
|
+
def invoke(*args)
|
|
16
|
+
invoke_with_new_relic(*args) { invoke_without_new_relic(*args) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
alias_method(:invoke_async_without_new_relic, :invoke_async)
|
|
20
|
+
|
|
21
|
+
def invoke_async(*args)
|
|
22
|
+
invoke_async_with_new_relic(*args) { invoke_async_without_new_relic(*args) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
alias_method(:invoke_with_response_stream_without_new_relic, :invoke_with_response_stream)
|
|
26
|
+
|
|
27
|
+
def invoke_with_response_stream(*args)
|
|
28
|
+
invoke_with_response_stream_with_new_relic(*args) { invoke_with_response_stream_without_new_relic(*args) }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
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 'json'
|
|
6
|
+
|
|
7
|
+
module NewRelic::Agent::Instrumentation
|
|
8
|
+
module AwsSdkLambda
|
|
9
|
+
INSTRUMENTATION_NAME = 'aws_sdk_lambda'
|
|
10
|
+
AWS_SERVICE = 'lambda'
|
|
11
|
+
CLOUD_PLATFORM = 'aws_lambda'
|
|
12
|
+
WRAPPED_RESPONSE = Struct.new(:status_code, :has_status_code?)
|
|
13
|
+
|
|
14
|
+
def invoke_with_new_relic(*args)
|
|
15
|
+
with_tracing(:invoke, *args) { yield }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def invoke_async_with_new_relic(*args)
|
|
19
|
+
with_tracing(:invoke_async, *args) { yield }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def invoke_with_response_stream_with_new_relic(*args)
|
|
23
|
+
with_tracing(:invoke_with_response_stream, *args) { yield }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def with_tracing(action, *args)
|
|
29
|
+
segment = generate_segment(action, *args)
|
|
30
|
+
|
|
31
|
+
# prevent additional instrumentation for things like Net::HTTP from
|
|
32
|
+
# creating any segments that may appear as redundant / confusing
|
|
33
|
+
NewRelic::Agent.disable_all_tracing do
|
|
34
|
+
response = NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
|
|
35
|
+
process_response(response, segment)
|
|
36
|
+
response
|
|
37
|
+
end
|
|
38
|
+
ensure
|
|
39
|
+
segment&.finish
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def process_response(response, segment)
|
|
43
|
+
process_function_error(response) if response.respond_to?(:function_error)
|
|
44
|
+
rescue => e
|
|
45
|
+
NewRelic::Agent.logger.error("Error processing aws-sdk-lambda invocation response: #{e}")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# notice error that was raised / unhandled by the function
|
|
49
|
+
def process_function_error(response)
|
|
50
|
+
function_error = response.function_error
|
|
51
|
+
return unless function_error
|
|
52
|
+
|
|
53
|
+
msg = "[#{function_error}]"
|
|
54
|
+
payload = response.payload&.string if response.respond_to?(:payload)
|
|
55
|
+
payload_hash = JSON.parse(payload) if payload
|
|
56
|
+
msg = "#{msg} #{payload_hash['errorType']} - #{payload_hash['errorMessage']}" if payload_hash
|
|
57
|
+
e = StandardError.new(msg)
|
|
58
|
+
e.set_backtrace(payload_hash['stackTrace']) if payload_hash
|
|
59
|
+
|
|
60
|
+
NewRelic::Agent.notice_error(e)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def generate_segment(action, options = {})
|
|
64
|
+
function = function_name(options)
|
|
65
|
+
region = aws_region
|
|
66
|
+
arn = aws_arn(function, region)
|
|
67
|
+
segment = NewRelic::Agent::Tracer.start_segment(name: "Lambda/#{action}/#{function}")
|
|
68
|
+
segment.add_agent_attribute('cloud.account.id', nr_account_id)
|
|
69
|
+
segment.add_agent_attribute('cloud.platform', CLOUD_PLATFORM)
|
|
70
|
+
segment.add_agent_attribute('cloud.region', region)
|
|
71
|
+
segment.add_agent_attribute('cloud.resource_id', arn) if arn
|
|
72
|
+
segment
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def function_name(options = {})
|
|
76
|
+
(options.fetch(:function_name, nil) if options.respond_to?(:fetch)) || NewRelic::UNKNOWN
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def aws_region
|
|
80
|
+
config&.region if self.respond_to?(:config)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def aws_arn(function, region)
|
|
84
|
+
NewRelic::Agent::Aws.create_arn(AWS_SERVICE, "function:#{function}", region, nr_account_id)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def nr_account_id
|
|
88
|
+
return @nr_account_id if defined?(@nr_account_id)
|
|
89
|
+
|
|
90
|
+
@nr_account_id = NewRelic::Agent::Aws.get_account_id(config)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
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 'instrumentation'
|
|
6
|
+
|
|
7
|
+
module NewRelic::Agent::Instrumentation
|
|
8
|
+
module AwsSdkLambda::Prepend
|
|
9
|
+
include NewRelic::Agent::Instrumentation::AwsSdkLambda
|
|
10
|
+
|
|
11
|
+
def invoke(*args)
|
|
12
|
+
invoke_with_new_relic(*args) { super }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def invoke_async(*args)
|
|
16
|
+
invoke_async_with_new_relic(*args) { super }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def invoke_with_response_stream(*args)
|
|
20
|
+
invoke_with_response_stream_with_new_relic(*args) { super }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
DependencyDetection.defer do
|
|
6
|
+
named :aws_sdk_lambda
|
|
7
|
+
|
|
8
|
+
depends_on do
|
|
9
|
+
defined?(Aws::Lambda::Client)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
executes do
|
|
13
|
+
require_relative 'aws_sdk_lambda/instrumentation'
|
|
14
|
+
|
|
15
|
+
if use_prepend?
|
|
16
|
+
require_relative 'aws_sdk_lambda/prepend'
|
|
17
|
+
prepend_instrument Aws::Lambda::Client, NewRelic::Agent::Instrumentation::AwsSdkLambda::Prepend
|
|
18
|
+
else
|
|
19
|
+
require_relative 'aws_sdk_lambda/chain'
|
|
20
|
+
chain_instrument NewRelic::Agent::Instrumentation::AwsSdkLambda::Chain
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
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 AwsSqs::Chain
|
|
7
|
+
def self.instrument!
|
|
8
|
+
::Aws::SQS::Client.class_eval do
|
|
9
|
+
include NewRelic::Agent::Instrumentation::AwsSqs
|
|
10
|
+
|
|
11
|
+
alias_method(:send_message_without_new_relic, :send_message)
|
|
12
|
+
|
|
13
|
+
def send_message(*args)
|
|
14
|
+
send_message_with_new_relic(*args) do
|
|
15
|
+
send_message_without_new_relic(*args)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
alias_method(:send_message_batch_without_new_relic, :send_message_batch)
|
|
20
|
+
|
|
21
|
+
def send_message_batch(*args)
|
|
22
|
+
send_message_batch_with_new_relic(*args) do
|
|
23
|
+
send_message_batch_without_new_relic(*args)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
alias_method(:receive_message_without_new_relic, :receive_message)
|
|
28
|
+
|
|
29
|
+
def receive_message(*args)
|
|
30
|
+
receive_message_with_new_relic(*args) do
|
|
31
|
+
receive_message_without_new_relic(*args)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
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
|
+
module NewRelic::Agent::Instrumentation
|
|
6
|
+
module AwsSqs
|
|
7
|
+
MESSAGING_LIBRARY = 'SQS'
|
|
8
|
+
|
|
9
|
+
def send_message_with_new_relic(*args)
|
|
10
|
+
with_tracing(:produce, args) do
|
|
11
|
+
yield
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def send_message_batch_with_new_relic(*args)
|
|
16
|
+
with_tracing(:produce, args) do
|
|
17
|
+
yield
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def receive_message_with_new_relic(*args)
|
|
22
|
+
with_tracing(:consume, args) do
|
|
23
|
+
yield
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def with_tracing(action, params)
|
|
28
|
+
segment = nil
|
|
29
|
+
begin
|
|
30
|
+
info = get_url_info(params[0])
|
|
31
|
+
segment = NewRelic::Agent::Tracer.start_message_broker_segment(
|
|
32
|
+
action: action,
|
|
33
|
+
library: MESSAGING_LIBRARY,
|
|
34
|
+
destination_type: :queue,
|
|
35
|
+
destination_name: info[:queue_name]
|
|
36
|
+
)
|
|
37
|
+
add_aws_attributes(segment, info)
|
|
38
|
+
rescue => e
|
|
39
|
+
NewRelic::Agent.logger.error('Error starting message broker segment in Aws::SQS::Client', e)
|
|
40
|
+
end
|
|
41
|
+
NewRelic::Agent::Tracer.capture_segment_error(segment) do
|
|
42
|
+
yield
|
|
43
|
+
end
|
|
44
|
+
ensure
|
|
45
|
+
segment&.finish
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def add_aws_attributes(segment, info)
|
|
51
|
+
return unless segment
|
|
52
|
+
|
|
53
|
+
segment.add_agent_attribute('messaging.system', 'aws_sqs')
|
|
54
|
+
segment.add_agent_attribute('cloud.region', config&.region)
|
|
55
|
+
segment.add_agent_attribute('cloud.account.id', info[:account_id])
|
|
56
|
+
segment.add_agent_attribute('messaging.destination.name', info[:queue_name])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def get_url_info(params)
|
|
60
|
+
split = params[:queue_url].split('/')
|
|
61
|
+
{
|
|
62
|
+
queue_name: split.last,
|
|
63
|
+
account_id: split[-2]
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
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 AwsSqs::Prepend
|
|
7
|
+
include NewRelic::Agent::Instrumentation::AwsSqs
|
|
8
|
+
|
|
9
|
+
def send_message(*args)
|
|
10
|
+
send_message_with_new_relic(*args) { super }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def send_message_batch(*args)
|
|
14
|
+
send_message_batch_with_new_relic(*args) { super }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def receive_message(*args)
|
|
18
|
+
receive_message_with_new_relic(*args) { super }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
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 'aws_sqs/instrumentation'
|
|
6
|
+
require_relative 'aws_sqs/chain'
|
|
7
|
+
require_relative 'aws_sqs/prepend'
|
|
8
|
+
|
|
9
|
+
DependencyDetection.defer do
|
|
10
|
+
named :aws_sqs
|
|
11
|
+
|
|
12
|
+
depends_on do
|
|
13
|
+
defined?(Aws::SQS::Client)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
executes do
|
|
17
|
+
if use_prepend?
|
|
18
|
+
prepend_instrument Aws::SQS::Client, NewRelic::Agent::Instrumentation::AwsSqs::Prepend
|
|
19
|
+
else
|
|
20
|
+
chain_instrument NewRelic::Agent::Instrumentation::AwsSqs::Chain
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -12,6 +12,7 @@ module NewRelic
|
|
|
12
12
|
DEFAULT_NAME = 'Default'
|
|
13
13
|
DEFAULT_TYPE = :direct
|
|
14
14
|
SLASH = '/'
|
|
15
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
|
15
16
|
|
|
16
17
|
def exchange_name(name)
|
|
17
18
|
name.empty? ? DEFAULT_NAME : name
|
|
@@ -28,6 +29,8 @@ module NewRelic
|
|
|
28
29
|
include Bunny
|
|
29
30
|
|
|
30
31
|
def publish_with_tracing(payload, opts = {})
|
|
32
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
33
|
+
|
|
31
34
|
begin
|
|
32
35
|
destination = exchange_name(name)
|
|
33
36
|
|
|
@@ -45,6 +48,12 @@ module NewRelic
|
|
|
45
48
|
correlation_id: opts[:correlation_id],
|
|
46
49
|
exchange_type: type
|
|
47
50
|
)
|
|
51
|
+
if segment
|
|
52
|
+
segment.add_agent_attribute('server.address', channel&.connection&.hostname)
|
|
53
|
+
segment.add_agent_attribute('server.port', channel&.connection&.port)
|
|
54
|
+
segment.add_agent_attribute('messaging.destination.name', destination) # for produce, this is exchange name
|
|
55
|
+
segment.add_agent_attribute('messaging.rabbitmq.destination.routing_key', opts[:routing_key])
|
|
56
|
+
end
|
|
48
57
|
rescue => e
|
|
49
58
|
NewRelic::Agent.logger.error('Error starting message broker segment in Bunny::Exchange#publish', e)
|
|
50
59
|
yield
|
|
@@ -62,6 +71,8 @@ module NewRelic
|
|
|
62
71
|
include Bunny
|
|
63
72
|
|
|
64
73
|
def pop_with_tracing
|
|
74
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
75
|
+
|
|
65
76
|
bunny_error, delivery_info, message_properties, _payload = nil, nil, nil, nil
|
|
66
77
|
begin
|
|
67
78
|
t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
|
@@ -89,6 +100,14 @@ module NewRelic
|
|
|
89
100
|
queue_name: name,
|
|
90
101
|
start_time: t0
|
|
91
102
|
)
|
|
103
|
+
if segment
|
|
104
|
+
segment.add_agent_attribute('server.address', channel&.connection&.hostname)
|
|
105
|
+
segment.add_agent_attribute('server.port', channel&.connection&.port)
|
|
106
|
+
segment.add_agent_attribute('messaging.destination.name', name) # for consume, this is queue name
|
|
107
|
+
segment.add_agent_attribute('messaging.destination_publish.name', exch_name)
|
|
108
|
+
segment.add_agent_attribute('message.queueName', name)
|
|
109
|
+
segment.add_agent_attribute('messaging.rabbitmq.destination.routing_key', delivery_info&.routing_key)
|
|
110
|
+
end
|
|
92
111
|
rescue => e
|
|
93
112
|
NewRelic::Agent.logger.error('Error starting message broker segment in Bunny::Queue#pop', e)
|
|
94
113
|
else
|
|
@@ -104,6 +123,8 @@ module NewRelic
|
|
|
104
123
|
end
|
|
105
124
|
|
|
106
125
|
def purge_with_tracing
|
|
126
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
127
|
+
|
|
107
128
|
begin
|
|
108
129
|
type = server_named? ? :temporary_queue : :queue
|
|
109
130
|
segment = NewRelic::Agent::Tracer.start_message_broker_segment(
|
|
@@ -129,6 +150,8 @@ module NewRelic
|
|
|
129
150
|
include Bunny
|
|
130
151
|
|
|
131
152
|
def call_with_tracing(*args)
|
|
153
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
154
|
+
|
|
132
155
|
delivery_info, message_properties, _ = args
|
|
133
156
|
queue_name = queue.respond_to?(:name) ? queue.name : queue
|
|
134
157
|
|
|
@@ -14,7 +14,6 @@ DependencyDetection.defer do
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
executes do
|
|
17
|
-
NewRelic::Agent.logger.info('Installing Bunny instrumentation')
|
|
18
17
|
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
|
19
18
|
require 'new_relic/agent/messaging'
|
|
20
19
|
require 'new_relic/agent/transaction/message_broker_segment'
|
|
@@ -22,11 +21,11 @@ DependencyDetection.defer do
|
|
|
22
21
|
|
|
23
22
|
executes do
|
|
24
23
|
if use_prepend?
|
|
25
|
-
prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange
|
|
26
|
-
prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue
|
|
27
|
-
prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer
|
|
24
|
+
prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange, 'Bunny::Exchange'
|
|
25
|
+
prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue, 'Bunny::Queue'
|
|
26
|
+
prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer, 'Bunny::Consumer'
|
|
28
27
|
else
|
|
29
|
-
chain_instrument NewRelic::Agent::Instrumentation::Bunny
|
|
28
|
+
chain_instrument NewRelic::Agent::Instrumentation::Bunny::Chain
|
|
30
29
|
end
|
|
31
30
|
end
|
|
32
31
|
end
|
|
@@ -13,7 +13,7 @@ module NewRelic::Agent::Instrumentation
|
|
|
13
13
|
def post(*args, &task)
|
|
14
14
|
return post_without_new_relic(*args, &task) unless NewRelic::Agent::Tracer.tracing_enabled?
|
|
15
15
|
|
|
16
|
-
traced_task = add_task_tracing(
|
|
16
|
+
traced_task = add_task_tracing(&task)
|
|
17
17
|
post_without_new_relic(*args, &traced_task)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
module NewRelic::Agent::Instrumentation
|
|
6
6
|
module ConcurrentRuby
|
|
7
7
|
SEGMENT_NAME = 'Concurrent/Task'
|
|
8
|
-
|
|
8
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
|
9
9
|
|
|
10
|
-
def add_task_tracing(
|
|
11
|
-
NewRelic::Agent.
|
|
10
|
+
def add_task_tracing(&task)
|
|
11
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
|
12
12
|
|
|
13
13
|
NewRelic::Agent::Tracer.thread_block_with_current_transaction(
|
|
14
|
-
*args,
|
|
15
14
|
segment_name: SEGMENT_NAME,
|
|
16
15
|
parent: NewRelic::Agent::Tracer.current_segment,
|
|
17
16
|
&task
|
|
@@ -10,7 +10,7 @@ module NewRelic::Agent::Instrumentation
|
|
|
10
10
|
def post(*args, &task)
|
|
11
11
|
return super(*args, &task) unless NewRelic::Agent::Tracer.tracing_enabled?
|
|
12
12
|
|
|
13
|
-
traced_task = add_task_tracing(
|
|
13
|
+
traced_task = add_task_tracing(&task)
|
|
14
14
|
super(*args, &traced_task)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -11,12 +11,11 @@ DependencyDetection.defer do
|
|
|
11
11
|
|
|
12
12
|
depends_on do
|
|
13
13
|
defined?(Concurrent) &&
|
|
14
|
-
|
|
14
|
+
defined?(Concurrent::VERSION) &&
|
|
15
|
+
NewRelic::Helper.version_satisfied?(Concurrent::VERSION, '>=', '1.1.5')
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
executes do
|
|
18
|
-
NewRelic::Agent.logger.info('Installing concurrent-ruby instrumentation')
|
|
19
|
-
|
|
20
19
|
if use_prepend?
|
|
21
20
|
prepend_instrument(Concurrent::ThreadPoolExecutor, NewRelic::Agent::Instrumentation::ConcurrentRuby::Prepend)
|
|
22
21
|
|
|
@@ -41,8 +41,6 @@ module NewRelic
|
|
|
41
41
|
clazz.extend(ClassMethodsShim)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def new_relic_trace_controller_action(*args); yield; end
|
|
45
|
-
|
|
46
44
|
def perform_action_with_newrelic_trace(*args); yield; end
|
|
47
45
|
end
|
|
48
46
|
|
|
@@ -56,6 +54,7 @@ module NewRelic
|
|
|
56
54
|
# Have NewRelic ignore actions in this controller. Specify the actions as hash options
|
|
57
55
|
# using :except and :only. If no actions are specified, all actions are ignored.
|
|
58
56
|
#
|
|
57
|
+
# @!scope class
|
|
59
58
|
# @api public
|
|
60
59
|
#
|
|
61
60
|
def newrelic_ignore(specifiers = {})
|
|
@@ -67,6 +66,7 @@ module NewRelic
|
|
|
67
66
|
# actions that are not user facing or that skew your overall apdex measurement.
|
|
68
67
|
# Accepts :except and :only options, as with #newrelic_ignore.
|
|
69
68
|
#
|
|
69
|
+
# @!scope class
|
|
70
70
|
# @api public
|
|
71
71
|
#
|
|
72
72
|
def newrelic_ignore_apdex(specifiers = {})
|
|
@@ -74,6 +74,7 @@ module NewRelic
|
|
|
74
74
|
newrelic_ignore_aspect(NR_IGNORE_APDEX_KEY, specifiers)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# @!scope class
|
|
77
78
|
# @api public
|
|
78
79
|
def newrelic_ignore_enduser(specifiers = {})
|
|
79
80
|
NewRelic::Agent.record_api_supportability_metric(:newrelic_ignore_enduser)
|
|
@@ -161,6 +162,7 @@ module NewRelic
|
|
|
161
162
|
# See NewRelic::Agent::Instrumentation::ControllerInstrumentation#perform_action_with_newrelic_trace
|
|
162
163
|
# for the full list of available options.
|
|
163
164
|
#
|
|
165
|
+
# @!scope class
|
|
164
166
|
# @api public
|
|
165
167
|
#
|
|
166
168
|
def add_transaction_tracer(method, options = {})
|
|
@@ -245,6 +247,7 @@ module NewRelic
|
|
|
245
247
|
when :background then ::NewRelic::Agent::Transaction::TASK_PREFIX
|
|
246
248
|
when :rack then ::NewRelic::Agent::Transaction::RACK_PREFIX
|
|
247
249
|
when :uri then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
|
|
250
|
+
when :roda then ::NewRelic::Agent::Transaction::RODA_PREFIX
|
|
248
251
|
when :sinatra then ::NewRelic::Agent::Transaction::SINATRA_PREFIX
|
|
249
252
|
when :middleware then ::NewRelic::Agent::Transaction::MIDDLEWARE_PREFIX
|
|
250
253
|
when :grape then ::NewRelic::Agent::Transaction::GRAPE_PREFIX
|