From cd8cd949b26cb402cf3b4366b7387f99e0b85443 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Wed, 25 Sep 2024 16:09:56 -0700 Subject: [PATCH 01/59] Remove opensearch service from depends_on OpenSearch does not have a service, it's commented out. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4fd6bdaf0c..bc4a30774f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -101,7 +101,7 @@ services: depends_on: - elasticsearch7 - elasticsearch8 - - opensearch + # - opensearch - mysql - memcached - mongodb From 7264efa09c28719a635d4734179b53f9c11cb8e5 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 30 Sep 2024 16:03:39 -0700 Subject: [PATCH 02/59] Update verbiage to match docs website Tweaks for automatic_custom_instrumentation_method_list --- lib/new_relic/agent/configuration/default_source.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/new_relic/agent/configuration/default_source.rb b/lib/new_relic/agent/configuration/default_source.rb index 246af67829..e091c8ecf3 100644 --- a/lib/new_relic/agent/configuration/default_source.rb +++ b/lib/new_relic/agent/configuration/default_source.rb @@ -1159,7 +1159,7 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil) :allowed_from_server => false, :transform => proc { |arr| NewRelic::Agent.add_automatic_method_tracers(arr) }, :description => <<~DESCRIPTION - An array of `CLASS#METHOD` (for instance methods) and/or `CLASS.METHOD` (for class methods) strings representing Ruby methods for the agent to automatically add custom instrumentation to without the need for altering any of the source code that defines the methods. + An array of `CLASS#METHOD` (for instance methods) and/or `CLASS.METHOD` (for class methods) strings representing Ruby methods that the agent can automatically add custom instrumentation to. This doesn't require any modifications of the source code that defines the methods. Use fully qualified class names (using the `::` delimiter) that include any module or class namespacing. @@ -1189,13 +1189,13 @@ def self.notify - MyCompany::User.notify ``` - That configuration example uses YAML array syntax to specify both methods. Alternatively, a comma-delimited string can be used instead: + That configuration example uses YAML array syntax to specify both methods. Alternatively, you can use a comma-delimited string: ``` automatic_custom_instrumentation_method_list: 'MyCompany::Image#render_png, MyCompany::User.notify' ``` - Whitespace around the comma(s) in the list is optional. When configuring the agent with a list of methods via the `NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST` environment variable, this comma-delimited string format should be used: + Whitespace around the comma(s) in the list is optional. When configuring the agent with a list of methods via the `NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST` environment variable, use this comma-delimited string format: ``` export NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST='MyCompany::Image#render_png, MyCompany::User.notify' From c7ebec7a27b573019fe53a4397c3c708165d0470 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Tue, 1 Oct 2024 13:34:22 -0500 Subject: [PATCH 03/59] add ruby version check --- lib/new_relic/agent/instrumentation/rdkafka/chain.rb | 3 ++- lib/new_relic/agent/instrumentation/rdkafka/prepend.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/new_relic/agent/instrumentation/rdkafka/chain.rb b/lib/new_relic/agent/instrumentation/rdkafka/chain.rb index fc9b826aa8..8652987fed 100644 --- a/lib/new_relic/agent/instrumentation/rdkafka/chain.rb +++ b/lib/new_relic/agent/instrumentation/rdkafka/chain.rb @@ -40,7 +40,8 @@ def each(**kwargs) alias_method(:producer_without_new_relic, :producer) alias_method(:consumer_without_new_relic, :consumer) - if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0') + if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0') || + (Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')) def producer(**kwargs) producer_without_new_relic(**kwargs).tap do |producer| set_nr_config(producer) diff --git a/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb b/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb index 3397c2436c..24dfba9037 100644 --- a/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb +++ b/lib/new_relic/agent/instrumentation/rdkafka/prepend.rb @@ -36,7 +36,8 @@ module RdkafkaConfig module Prepend include NewRelic::Agent::Instrumentation::RdkafkaConfig - if defined?(::Rdkafka) && Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0') + if (defined?(::Rdkafka) && Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0')) || + (Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')) def producer(**kwargs) super.tap do |producer| set_nr_config(producer) From fff792ad77ad373928d22fbcf70c5daf4f3ae95f Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 1 Oct 2024 15:42:03 -0700 Subject: [PATCH 04/59] Update 9.14 changelog to match release notes --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cec4b666f..404edb142f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v9.14.0 -Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka gems, introduces a configuration-based, automatic way to add custom instrumentation method tracers, correctly captures MIME type for AcionDispatch 7.0+ requests, properly handles Boolean coercion for `newrelic.yml` configuration, fixes a JRuby bug in the configuration manager, fixes a bug related to `Bundler.rubygems.installed_specs`, and fixes a bug to make the agent compatible with ViewComponent v3.15.0+. +Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka gems, introduces a configuration-based, automatic way to add custom instrumentation method tracers, correctly captures MIME type for ActionDispatch 7.0+ requests, properly handles Boolean coercion for `newrelic.yml` configuration, fixes a JRuby bug in the configuration manager, fixes a bug related to `Bundler.rubygems.installed_specs`, and fixes a bug to make the agent compatible with ViewComponent v3.15.0+. - **Feature: Add Apache Kafka instrumentation for the rdkafka and ruby-kafka gems** @@ -42,13 +42,13 @@ Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka - MyCompany::User.notify ``` - That configuration example uses YAML array syntax to specify both methods. Alternatively, a comma-delimited string can be used instead: + That configuration example uses YAML array syntax to specify both methods. Alternatively, you can use a comma-delimited string: ``` automatic_custom_instrumentation_method_list: 'MyCompany::Image#render_png, MyCompany::User.notify' ``` - Whitespace around the comma(s) in the list is optional. When configuring the agent with a list of methods via the `NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST` environment variable, this comma-delimited string format should be used: + Whitespace around the comma(s) in the list is optional. When configuring the agent with a list of methods via the `NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST` environment variable, use this comma-delimited string format: ``` export NEW_RELIC_AUTOMATIC_CUSTOM_INSTRUMENTATION_METHOD_LIST='MyCompany::Image#render_png, MyCompany::User.notify' @@ -56,7 +56,7 @@ Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka [PR#2851](https://github.com/newrelic/newrelic-ruby-agent/pull/2851) -- **Feature: Collect just MIME type for AcionDispatch 7.0+ requests** +- **Feature: Collect just MIME type for ActionDispatch 7.0+ requests** Rails 7.0 [introduced changes](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#actiondispatch-request-content-type-now-returns-content-type-header-as-it-is) to the behavior of `ActionDispatch::Request#content_type`, adding extra request-related details the agent wasn't expecting to collect. Additionally, the agent's use of `content_type ` was triggering deprecation warnings. The agent now uses `ActionDispatch::Request#media_type` to capture the MIME type. Thanks to [@internethostage](https://github.com/internethostage) for letting us know about this change. [Issue#2500](https://github.com/newrelic/newrelic-ruby-agent/issues/2500) [PR#2855](https://github.com/newrelic/newrelic-ruby-agent/pull/2855) From 41e118b56d0844116ec7d9781dfc953958e25b57 Mon Sep 17 00:00:00 2001 From: fallwith Date: Wed, 2 Oct 2024 13:30:51 -0700 Subject: [PATCH 05/59] Stripe: restrict CI tests to Stripe <= v12 For now, limit Stripe testing to < v13 --- test/multiverse/suites/stripe/Envfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/multiverse/suites/stripe/Envfile b/test/multiverse/suites/stripe/Envfile index 8d8a605713..77f2812d43 100644 --- a/test/multiverse/suites/stripe/Envfile +++ b/test/multiverse/suites/stripe/Envfile @@ -7,7 +7,9 @@ instrumentation_methods :chain STRIPE_VERSIONS = [ - [nil, 2.4], + # TODO: support Stripe v13+ https://github.com/newrelic/newrelic-ruby-agent/issues/2884 + # [nil, 2.4], + ['12.6.0', 2.4], ['5.38.0', 2.4] ] From 2f8d3c69f2391e77d8fe5a870c765724e111cd6c Mon Sep 17 00:00:00 2001 From: fallwith Date: Wed, 2 Oct 2024 16:50:28 -0700 Subject: [PATCH 06/59] Sequel: relax Ruby requirement for Timed pool Accommodate Sequel v5.85.0, which has made the timed connection pool the default for Ruby 3.2+ by always permitting the use of a timed connection pool for explain plan generation in a Ruby 3.2+ context (previously only a Ruby 3.4+ context would work). https://sequel.jeremyevans.net/rdoc/files/doc/release_notes/5_85_0_txt.html#label-Other+Improvements --- lib/sequel/extensions/new_relic_instrumentation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sequel/extensions/new_relic_instrumentation.rb b/lib/sequel/extensions/new_relic_instrumentation.rb index 11a465b7af..13602c11ac 100644 --- a/lib/sequel/extensions/new_relic_instrumentation.rb +++ b/lib/sequel/extensions/new_relic_instrumentation.rb @@ -79,7 +79,7 @@ def notice_sql(sql) THREAD_SAFE_CONNECTION_POOL_CLASSES = [ (defined?(::Sequel::ThreadedConnectionPool) && ::Sequel::ThreadedConnectionPool), - (defined?(::Sequel::TimedQueueConnectionPool) && RUBY_VERSION >= '3.4' && ::Sequel::TimedQueueConnectionPool) + (defined?(::Sequel::TimedQueueConnectionPool) && RUBY_VERSION >= '3.2' && ::Sequel::TimedQueueConnectionPool) ].compact.freeze def explainer_for(sql) From 17afe8b14cc9dd11e18106bb37d2242ce1fb1e56 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Thu, 3 Oct 2024 10:40:02 -0500 Subject: [PATCH 07/59] add changelog entry --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 404edb142f..f092af903b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # New Relic Ruby Agent Release Notes +## dev + +Version resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. + +- **Bugfix: Instrumentation errors when using the karafka-rdkafka gem** + + Due to version differences between the rdkafka gem and karafka-rdkafka gem, the agent was installing instrumentation on some versions of karafka-rdkafka that encountered errors. This has now been resolved. Thank you to @krisdigital for bringing this issue to our attention. [PR#2880](https://github.com/newrelic/newrelic-ruby-agent/pull/2880) + + ## v9.14.0 Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka gems, introduces a configuration-based, automatic way to add custom instrumentation method tracers, correctly captures MIME type for ActionDispatch 7.0+ requests, properly handles Boolean coercion for `newrelic.yml` configuration, fixes a JRuby bug in the configuration manager, fixes a bug related to `Bundler.rubygems.installed_specs`, and fixes a bug to make the agent compatible with ViewComponent v3.15.0+. From f4f13059a8267d691867cb2edeac20ab56a6e5ab Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:45:05 -0700 Subject: [PATCH 08/59] Remove excess info-level instrumentation logs (#2881) * Remove duplicate info-level instrumentation logs The methods `prepend_instrument` and `chain_instrument` eventually produce info-level log statements. Remove duplicate statements. --------- Co-authored-by: James Bunch --- .../instrumentation/active_support_broadcast_logger.rb | 2 -- .../agent/instrumentation/active_support_logger.rb | 2 -- lib/new_relic/agent/instrumentation/async_http.rb | 3 +-- lib/new_relic/agent/instrumentation/aws_sqs.rb | 2 -- lib/new_relic/agent/instrumentation/bunny.rb | 7 +++---- lib/new_relic/agent/instrumentation/concurrent_ruby.rb | 2 -- lib/new_relic/agent/instrumentation/curb.rb | 7 +++---- .../agent/instrumentation/delayed_job_instrumentation.rb | 4 ---- lib/new_relic/agent/instrumentation/dynamodb.rb | 2 -- lib/new_relic/agent/instrumentation/elasticsearch.rb | 2 -- lib/new_relic/agent/instrumentation/ethon.rb | 4 ---- lib/new_relic/agent/instrumentation/fiber.rb | 2 -- lib/new_relic/agent/instrumentation/httpclient.rb | 1 - lib/new_relic/agent/instrumentation/httprb.rb | 1 - lib/new_relic/agent/instrumentation/httpx.rb | 4 ---- lib/new_relic/agent/instrumentation/logger.rb | 4 +--- lib/new_relic/agent/instrumentation/logstasher.rb | 2 -- lib/new_relic/agent/instrumentation/memcache.rb | 1 - lib/new_relic/agent/instrumentation/opensearch.rb | 2 -- lib/new_relic/agent/instrumentation/padrino.rb | 6 +++--- lib/new_relic/agent/instrumentation/rake.rb | 1 - lib/new_relic/agent/instrumentation/rdkafka.rb | 2 -- lib/new_relic/agent/instrumentation/redis.rb | 1 - lib/new_relic/agent/instrumentation/resque.rb | 4 ---- lib/new_relic/agent/instrumentation/roda.rb | 8 ++++---- lib/new_relic/agent/instrumentation/ruby_kafka.rb | 2 -- lib/new_relic/agent/instrumentation/sinatra.rb | 9 +++------ lib/new_relic/agent/instrumentation/thread.rb | 2 -- lib/new_relic/agent/instrumentation/tilt.rb | 4 ---- lib/new_relic/agent/instrumentation/typhoeus.rb | 1 - lib/new_relic/agent/instrumentation/view_component.rb | 2 -- .../templates/dependency_detection.tt | 7 +++++-- 32 files changed, 23 insertions(+), 80 deletions(-) diff --git a/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb b/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb index 8505dd2d72..3e51c1abd6 100644 --- a/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +++ b/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb @@ -12,8 +12,6 @@ depends_on { defined?(ActiveSupport::BroadcastLogger) } executes do - NewRelic::Agent.logger.info('Installing ActiveSupport::BroadcastLogger instrumentation') - if use_prepend? prepend_instrument ActiveSupport::BroadcastLogger, NewRelic::Agent::Instrumentation::ActiveSupportBroadcastLogger::Prepend else diff --git a/lib/new_relic/agent/instrumentation/active_support_logger.rb b/lib/new_relic/agent/instrumentation/active_support_logger.rb index a89effca96..73c8f66159 100644 --- a/lib/new_relic/agent/instrumentation/active_support_logger.rb +++ b/lib/new_relic/agent/instrumentation/active_support_logger.rb @@ -14,8 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing ActiveSupport::Logger instrumentation') - if use_prepend? # the only method currently instrumented is a class method prepend_instrument ActiveSupport::Logger.singleton_class, NewRelic::Agent::Instrumentation::ActiveSupportLogger::Prepend diff --git a/lib/new_relic/agent/instrumentation/async_http.rb b/lib/new_relic/agent/instrumentation/async_http.rb index 0087877e95..82aa620915 100644 --- a/lib/new_relic/agent/instrumentation/async_http.rb +++ b/lib/new_relic/agent/instrumentation/async_http.rb @@ -16,9 +16,8 @@ end executes do - NewRelic::Agent.logger.info('Installing async_http instrumentation') - require 'async/http/internet' + if use_prepend? prepend_instrument Async::HTTP::Internet, NewRelic::Agent::Instrumentation::AsyncHttp::Prepend else diff --git a/lib/new_relic/agent/instrumentation/aws_sqs.rb b/lib/new_relic/agent/instrumentation/aws_sqs.rb index 7f5acb82c3..35d55428e2 100644 --- a/lib/new_relic/agent/instrumentation/aws_sqs.rb +++ b/lib/new_relic/agent/instrumentation/aws_sqs.rb @@ -14,8 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing aws-sdk-sqs instrumentation') - if use_prepend? prepend_instrument Aws::SQS::Client, NewRelic::Agent::Instrumentation::AwsSqs::Prepend else diff --git a/lib/new_relic/agent/instrumentation/bunny.rb b/lib/new_relic/agent/instrumentation/bunny.rb index b7cf291eb0..c9486acf0b 100644 --- a/lib/new_relic/agent/instrumentation/bunny.rb +++ b/lib/new_relic/agent/instrumentation/bunny.rb @@ -14,7 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing Bunny instrumentation') require 'new_relic/agent/distributed_tracing/cross_app_tracing' require 'new_relic/agent/messaging' require 'new_relic/agent/transaction/message_broker_segment' @@ -22,9 +21,9 @@ executes do if use_prepend? - prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange - prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue - prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer + prepend_instrument Bunny::Exchange, NewRelic::Agent::Instrumentation::Bunny::Prepend::Exchange, 'Bunny::Exchange' + prepend_instrument Bunny::Queue, NewRelic::Agent::Instrumentation::Bunny::Prepend::Queue, 'Bunny::Queue' + prepend_instrument Bunny::Consumer, NewRelic::Agent::Instrumentation::Bunny::Prepend::Consumer, 'Bunny::Consumer' else chain_instrument NewRelic::Agent::Instrumentation::Bunny::Chain end diff --git a/lib/new_relic/agent/instrumentation/concurrent_ruby.rb b/lib/new_relic/agent/instrumentation/concurrent_ruby.rb index 0937bcd73b..0e8c661940 100644 --- a/lib/new_relic/agent/instrumentation/concurrent_ruby.rb +++ b/lib/new_relic/agent/instrumentation/concurrent_ruby.rb @@ -16,8 +16,6 @@ end executes do - NewRelic::Agent.logger.info('Installing concurrent-ruby instrumentation') - if use_prepend? prepend_instrument(Concurrent::ThreadPoolExecutor, NewRelic::Agent::Instrumentation::ConcurrentRuby::Prepend) diff --git a/lib/new_relic/agent/instrumentation/curb.rb b/lib/new_relic/agent/instrumentation/curb.rb index 2aa2699e67..aa38d183c9 100644 --- a/lib/new_relic/agent/instrumentation/curb.rb +++ b/lib/new_relic/agent/instrumentation/curb.rb @@ -16,17 +16,16 @@ end executes do - NewRelic::Agent.logger.info('Installing Curb instrumentation') require 'new_relic/agent/distributed_tracing/cross_app_tracing' require 'new_relic/agent/http_clients/curb_wrappers' end executes do if use_prepend? - prepend_instrument Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend - prepend_instrument Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend + prepend_instrument Curl::Easy, NewRelic::Agent::Instrumentation::Curb::Easy::Prepend, 'Curb::Easy' + prepend_instrument Curl::Multi, NewRelic::Agent::Instrumentation::Curb::Multi::Prepend, 'Curb::Multi' else - chain_instrument NewRelic::Agent::Instrumentation::Curb::Chain + chain_instrument NewRelic::Agent::Instrumentation::Curb::Chain, NewRelic::Agent::Instrumentation::Curb::Multi::INSTRUMENTATION_NAME end end end diff --git a/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb b/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb index e5c88644e5..b9bde8ac1d 100644 --- a/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +++ b/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb @@ -82,10 +82,6 @@ def method_name(payload_object) defined?(Delayed) && defined?(Delayed::Worker) end - executes do - NewRelic::Agent.logger.info('Installing DelayedJob instrumentation [part 1/2]') - end - executes do if use_prepend? prepend_instrument Delayed::Worker, NewRelic::Agent::Instrumentation::DelayedJob::Prepend diff --git a/lib/new_relic/agent/instrumentation/dynamodb.rb b/lib/new_relic/agent/instrumentation/dynamodb.rb index 7f74e76f08..dedd1f3c43 100644 --- a/lib/new_relic/agent/instrumentation/dynamodb.rb +++ b/lib/new_relic/agent/instrumentation/dynamodb.rb @@ -14,8 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing DynamoDB instrumentation') - if use_prepend? prepend_instrument Aws::DynamoDB::Client, NewRelic::Agent::Instrumentation::DynamoDB::Prepend else diff --git a/lib/new_relic/agent/instrumentation/elasticsearch.rb b/lib/new_relic/agent/instrumentation/elasticsearch.rb index dca764b752..3c34f3c442 100644 --- a/lib/new_relic/agent/instrumentation/elasticsearch.rb +++ b/lib/new_relic/agent/instrumentation/elasticsearch.rb @@ -14,8 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing Elasticsearch instrumentation') - to_instrument = if Gem::Version.create(Elasticsearch::VERSION) < Gem::Version.create('8.0.0') Elasticsearch::Transport::Client else diff --git a/lib/new_relic/agent/instrumentation/ethon.rb b/lib/new_relic/agent/instrumentation/ethon.rb index 20daa492d5..8af7469ced 100644 --- a/lib/new_relic/agent/instrumentation/ethon.rb +++ b/lib/new_relic/agent/instrumentation/ethon.rb @@ -21,10 +21,6 @@ defined?(Ethon) && Gem::Version.new(Ethon::VERSION) >= Gem::Version.new('0.12.0') end - executes do - NewRelic::Agent.logger.info('Installing ethon instrumentation') - end - executes do if use_prepend? # NOTE: by default prepend_instrument will go with the module name that diff --git a/lib/new_relic/agent/instrumentation/fiber.rb b/lib/new_relic/agent/instrumentation/fiber.rb index ada212afb0..2412cbe891 100644 --- a/lib/new_relic/agent/instrumentation/fiber.rb +++ b/lib/new_relic/agent/instrumentation/fiber.rb @@ -14,8 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing Fiber instrumentation') - if use_prepend? prepend_instrument Fiber, NewRelic::Agent::Instrumentation::MonitoredFiber::Prepend else diff --git a/lib/new_relic/agent/instrumentation/httpclient.rb b/lib/new_relic/agent/instrumentation/httpclient.rb index 9dc9678d86..dc6e1fc871 100644 --- a/lib/new_relic/agent/instrumentation/httpclient.rb +++ b/lib/new_relic/agent/instrumentation/httpclient.rb @@ -23,7 +23,6 @@ end executes do - NewRelic::Agent.logger.info('Installing HTTPClient instrumentation') require 'new_relic/agent/distributed_tracing/cross_app_tracing' require 'new_relic/agent/http_clients/httpclient_wrappers' end diff --git a/lib/new_relic/agent/instrumentation/httprb.rb b/lib/new_relic/agent/instrumentation/httprb.rb index 822a2b0469..0def79c154 100644 --- a/lib/new_relic/agent/instrumentation/httprb.rb +++ b/lib/new_relic/agent/instrumentation/httprb.rb @@ -14,7 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing http.rb Wrappers') require 'new_relic/agent/distributed_tracing/cross_app_tracing' require 'new_relic/agent/http_clients/http_rb_wrappers' end diff --git a/lib/new_relic/agent/instrumentation/httpx.rb b/lib/new_relic/agent/instrumentation/httpx.rb index d709532ef0..ed58385230 100644 --- a/lib/new_relic/agent/instrumentation/httpx.rb +++ b/lib/new_relic/agent/instrumentation/httpx.rb @@ -13,10 +13,6 @@ defined?(HTTPX) && Gem::Version.new(HTTPX::VERSION) >= Gem::Version.new('1.0.0') end - executes do - NewRelic::Agent.logger.info('Installing httpx instrumentation') - end - executes do if use_prepend? prepend_instrument HTTPX::Session, NewRelic::Agent::Instrumentation::HTTPX::Prepend diff --git a/lib/new_relic/agent/instrumentation/logger.rb b/lib/new_relic/agent/instrumentation/logger.rb index c351fa6f59..a92b978660 100644 --- a/lib/new_relic/agent/instrumentation/logger.rb +++ b/lib/new_relic/agent/instrumentation/logger.rb @@ -15,12 +15,10 @@ end executes do - NewRelic::Agent.logger.info('Installing Logger instrumentation') - if use_prepend? prepend_instrument Logger, NewRelic::Agent::Instrumentation::Logger::Prepend else - chain_instrument NewRelic::Agent::Instrumentation::Logger + chain_instrument NewRelic::Agent::Instrumentation::Logger, NewRelic::Agent::Instrumentation::Logger::INSTRUMENTATION_NAME end end end diff --git a/lib/new_relic/agent/instrumentation/logstasher.rb b/lib/new_relic/agent/instrumentation/logstasher.rb index 2799996e5e..81129cabce 100644 --- a/lib/new_relic/agent/instrumentation/logstasher.rb +++ b/lib/new_relic/agent/instrumentation/logstasher.rb @@ -16,8 +16,6 @@ end executes do - NewRelic::Agent.logger.info('Installing LogStasher instrumentation') - if use_prepend? prepend_instrument LogStasher.singleton_class, NewRelic::Agent::Instrumentation::LogStasher::Prepend else diff --git a/lib/new_relic/agent/instrumentation/memcache.rb b/lib/new_relic/agent/instrumentation/memcache.rb index f5a9caa2b8..6d2e470a98 100644 --- a/lib/new_relic/agent/instrumentation/memcache.rb +++ b/lib/new_relic/agent/instrumentation/memcache.rb @@ -74,7 +74,6 @@ depends_on { NewRelic::Agent::Instrumentation::Memcache::DalliCAS.should_instrument? } executes do - NewRelic::Agent.logger.info('Installing Dalli CAS Client Memcache instrumentation') if use_prepend? prepend_module = NewRelic::Agent::Instrumentation::Memcache::Prepend prepend_module.dalli_cas_prependers do |client_class, instrumenting_module| diff --git a/lib/new_relic/agent/instrumentation/opensearch.rb b/lib/new_relic/agent/instrumentation/opensearch.rb index 0b10f1914a..0871fe1b15 100644 --- a/lib/new_relic/agent/instrumentation/opensearch.rb +++ b/lib/new_relic/agent/instrumentation/opensearch.rb @@ -14,8 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing opensearch-ruby instrumentation') - if use_prepend? prepend_instrument OpenSearch::Transport::Client, NewRelic::Agent::Instrumentation::OpenSearch::Prepend else diff --git a/lib/new_relic/agent/instrumentation/padrino.rb b/lib/new_relic/agent/instrumentation/padrino.rb index 912c0a9487..a81f8ff5b2 100644 --- a/lib/new_relic/agent/instrumentation/padrino.rb +++ b/lib/new_relic/agent/instrumentation/padrino.rb @@ -22,11 +22,11 @@ depends_on { defined?(Padrino) && defined?(Padrino::Routing::InstanceMethods) } executes do - NewRelic::Agent.logger.info('Installing Padrino instrumentation') + supportability_name = NewRelic::Agent::Instrumentation::Padrino::INSTRUMENTATION_NAME if use_prepend? - prepend_instrument Padrino::Application, NewRelic::Agent::Instrumentation::PadrinoTracer::Prepend + prepend_instrument Padrino::Application, NewRelic::Agent::Instrumentation::PadrinoTracer::Prepend, supportability_name else - chain_instrument NewRelic::Agent::Instrumentation::PadrinoTracer::Chain + chain_instrument NewRelic::Agent::Instrumentation::PadrinoTracer::Chain, supportability_name end end end diff --git a/lib/new_relic/agent/instrumentation/rake.rb b/lib/new_relic/agent/instrumentation/rake.rb index 543b52b50d..0581a64153 100644 --- a/lib/new_relic/agent/instrumentation/rake.rb +++ b/lib/new_relic/agent/instrumentation/rake.rb @@ -17,7 +17,6 @@ depends_on { NewRelic::Agent::Instrumentation::Rake.safe_from_third_party_gem? } executes do - NewRelic::Agent.logger.info('Installing Rake instrumentation') NewRelic::Agent.logger.debug("Instrumenting Rake tasks: #{NewRelic::Agent.config[:'rake.tasks']}") end diff --git a/lib/new_relic/agent/instrumentation/rdkafka.rb b/lib/new_relic/agent/instrumentation/rdkafka.rb index 51b8dae73d..e42cc774be 100644 --- a/lib/new_relic/agent/instrumentation/rdkafka.rb +++ b/lib/new_relic/agent/instrumentation/rdkafka.rb @@ -10,8 +10,6 @@ end executes do - NewRelic::Agent.logger.info('Installing rdkafka instrumentation') - require_relative 'rdkafka/instrumentation' require_relative 'rdkafka/chain' require_relative 'rdkafka/prepend' diff --git a/lib/new_relic/agent/instrumentation/redis.rb b/lib/new_relic/agent/instrumentation/redis.rb index fa435855c3..fdfd43a2a8 100644 --- a/lib/new_relic/agent/instrumentation/redis.rb +++ b/lib/new_relic/agent/instrumentation/redis.rb @@ -31,7 +31,6 @@ end executes do - NewRelic::Agent.logger.info('Installing Redis Instrumentation') if NewRelic::Agent::Instrumentation::Redis::Constants::HAS_REDIS_CLIENT RedisClient.register(NewRelic::Agent::Instrumentation::RedisClient::Middleware) diff --git a/lib/new_relic/agent/instrumentation/resque.rb b/lib/new_relic/agent/instrumentation/resque.rb index 8ccd3a8933..3c4158d17e 100644 --- a/lib/new_relic/agent/instrumentation/resque.rb +++ b/lib/new_relic/agent/instrumentation/resque.rb @@ -18,10 +18,6 @@ defined?(Airbrake) && defined?(Airbrake::AIRBRAKE_VERSION) && Gem::Version.create(Airbrake::AIRBRAKE_VERSION) < Gem::Version.create('11.0.3') end - executes do - NewRelic::Agent.logger.info('Installing Resque instrumentation') - end - executes do if NewRelic::Agent.config[:'resque.use_ruby_dns'] && NewRelic::Agent.config[:dispatcher] == :resque NewRelic::Agent.logger.info('Requiring resolv-replace') diff --git a/lib/new_relic/agent/instrumentation/roda.rb b/lib/new_relic/agent/instrumentation/roda.rb index c9f85b263f..2e82f6288a 100644 --- a/lib/new_relic/agent/instrumentation/roda.rb +++ b/lib/new_relic/agent/instrumentation/roda.rb @@ -20,15 +20,15 @@ require_relative '../../rack/agent_hooks' require_relative '../../rack/browser_monitoring' - NewRelic::Agent.logger.info('Installing Roda instrumentation') - if use_prepend? require_relative 'roda/prepend' - prepend_instrument Roda.singleton_class, NewRelic::Agent::Instrumentation::Roda::Build::Prepend + + supportability_name = NewRelic::Agent::Instrumentation::Roda::Tracer::INSTRUMENTATION_NAME + prepend_instrument Roda.singleton_class, NewRelic::Agent::Instrumentation::Roda::Build::Prepend, supportability_name prepend_instrument Roda, NewRelic::Agent::Instrumentation::Roda::Prepend else require_relative 'roda/chain' - chain_instrument NewRelic::Agent::Instrumentation::Roda::Build::Chain + chain_instrument NewRelic::Agent::Instrumentation::Roda::Build::Chain, supportability_name chain_instrument NewRelic::Agent::Instrumentation::Roda::Chain end Roda.class_eval { extend NewRelic::Agent::Instrumentation::Roda::Ignorer } diff --git a/lib/new_relic/agent/instrumentation/ruby_kafka.rb b/lib/new_relic/agent/instrumentation/ruby_kafka.rb index 6ab2c88654..42da1c2c86 100644 --- a/lib/new_relic/agent/instrumentation/ruby_kafka.rb +++ b/lib/new_relic/agent/instrumentation/ruby_kafka.rb @@ -14,8 +14,6 @@ end executes do - NewRelic::Agent.logger.info('Installing ruby-kafka instrumentation') - if use_prepend? prepend_instrument Kafka::Producer, NewRelic::Agent::Instrumentation::RubyKafkaProducer::Prepend prepend_instrument Kafka::Consumer, NewRelic::Agent::Instrumentation::RubyKafkaConsumer::Prepend diff --git a/lib/new_relic/agent/instrumentation/sinatra.rb b/lib/new_relic/agent/instrumentation/sinatra.rb index ceb743e574..29e83370fa 100644 --- a/lib/new_relic/agent/instrumentation/sinatra.rb +++ b/lib/new_relic/agent/instrumentation/sinatra.rb @@ -16,10 +16,6 @@ depends_on { Sinatra::Base.private_method_defined?(:process_route) } depends_on { Sinatra::Base.private_method_defined?(:route_eval) } - executes do - NewRelic::Agent.logger.info('Installing Sinatra instrumentation') - end - executes do if use_prepend? prepend_instrument Sinatra::Base, NewRelic::Agent::Instrumentation::Sinatra::Prepend @@ -32,14 +28,15 @@ end executes do + supportability_name = NewRelic::Agent::Instrumentation::Sinatra::Tracer::INSTRUMENTATION_NAME # These requires are inside an executes block because they require rack, and # we can't be sure that rack is available when this file is first required. require 'new_relic/rack/agent_hooks' require 'new_relic/rack/browser_monitoring' if use_prepend? - prepend_instrument Sinatra::Base.singleton_class, NewRelic::Agent::Instrumentation::Sinatra::Build::Prepend + prepend_instrument Sinatra::Base.singleton_class, NewRelic::Agent::Instrumentation::Sinatra::Build::Prepend, supportability_name else - chain_instrument NewRelic::Agent::Instrumentation::Sinatra::Build::Chain + chain_instrument NewRelic::Agent::Instrumentation::Sinatra::Build::Chain, supportability_name end end end diff --git a/lib/new_relic/agent/instrumentation/thread.rb b/lib/new_relic/agent/instrumentation/thread.rb index e5880206c6..536c5b7467 100644 --- a/lib/new_relic/agent/instrumentation/thread.rb +++ b/lib/new_relic/agent/instrumentation/thread.rb @@ -9,8 +9,6 @@ named :thread executes do - NewRelic::Agent.logger.info('Installing Thread Instrumentation') - if use_prepend? prepend_instrument Thread, NewRelic::Agent::Instrumentation::MonitoredThread::Prepend else diff --git a/lib/new_relic/agent/instrumentation/tilt.rb b/lib/new_relic/agent/instrumentation/tilt.rb index f9c9d2765f..5f27e9b442 100644 --- a/lib/new_relic/agent/instrumentation/tilt.rb +++ b/lib/new_relic/agent/instrumentation/tilt.rb @@ -11,10 +11,6 @@ depends_on { defined?(Tilt) } - executes do - NewRelic::Agent.logger.info('Installing Tilt instrumentation') - end - executes do if use_prepend? prepend_instrument Tilt::Template, NewRelic::Agent::Instrumentation::Tilt::Prepend diff --git a/lib/new_relic/agent/instrumentation/typhoeus.rb b/lib/new_relic/agent/instrumentation/typhoeus.rb index def686f7a3..0699e1e34d 100644 --- a/lib/new_relic/agent/instrumentation/typhoeus.rb +++ b/lib/new_relic/agent/instrumentation/typhoeus.rb @@ -18,7 +18,6 @@ end executes do - NewRelic::Agent.logger.info('Installing Typhoeus instrumentation') require 'new_relic/agent/distributed_tracing/cross_app_tracing' require 'new_relic/agent/http_clients/typhoeus_wrappers' end diff --git a/lib/new_relic/agent/instrumentation/view_component.rb b/lib/new_relic/agent/instrumentation/view_component.rb index 900336c67a..d9f09c0f52 100644 --- a/lib/new_relic/agent/instrumentation/view_component.rb +++ b/lib/new_relic/agent/instrumentation/view_component.rb @@ -15,8 +15,6 @@ end executes do - NewRelic::Agent.logger.info('Installing ViewComponent instrumentation') - if use_prepend? prepend_instrument ViewComponent::Base, NewRelic::Agent::Instrumentation::ViewComponent::Prepend else diff --git a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt index 2b17a16e80..e5c82ebb6f 100644 --- a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +++ b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt @@ -18,8 +18,11 @@ DependencyDetection.defer do end executes do - NewRelic::Agent.logger.info('Installing <%= @name.downcase %> instrumentation') - + # prepend_instrument and chain_instrument call extract_supportability_name + # to get the library name for supportability metrics and info-level logging. + # This is done by spliting on the 2nd to last spot of the instrumented + # module. If this isn't how we want the name to appear, pass in the desired + # name as a third argument. if use_prepend? prepend_instrument <%= @class_name %>, NewRelic::Agent::Instrumentation::<%= @class_name %>::Prepend else From ffea529608356e0ab8f33237f9d21221c62ce647 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:30:45 -0700 Subject: [PATCH 09/59] Stripe testing update (#2891) * Update Stripe test Co-authored-by: James Bunch --------- Co-authored-by: James Bunch --- test/multiverse/suites/stripe/Envfile | 3 +-- .../suites/stripe/stripe_instrumentation_test.rb | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/test/multiverse/suites/stripe/Envfile b/test/multiverse/suites/stripe/Envfile index 77f2812d43..ef6692375d 100644 --- a/test/multiverse/suites/stripe/Envfile +++ b/test/multiverse/suites/stripe/Envfile @@ -7,8 +7,7 @@ instrumentation_methods :chain STRIPE_VERSIONS = [ - # TODO: support Stripe v13+ https://github.com/newrelic/newrelic-ruby-agent/issues/2884 - # [nil, 2.4], + [nil, 2.4], ['12.6.0', 2.4], ['5.38.0', 2.4] ] diff --git a/test/multiverse/suites/stripe/stripe_instrumentation_test.rb b/test/multiverse/suites/stripe/stripe_instrumentation_test.rb index c6b5bd207e..db6c0dc991 100644 --- a/test/multiverse/suites/stripe/stripe_instrumentation_test.rb +++ b/test/multiverse/suites/stripe/stripe_instrumentation_test.rb @@ -199,9 +199,19 @@ def stripe_segment_from_transaction(txn) end def with_stubbed_connection_manager(&block) - Stripe::StripeClient.stub(:default_connection_manager, @connection) do - @connection.stub(:execute_request, @response) do - yield + # Stripe moved StripeClient and requestor logic to APIRequestor in v13.0.0 + # https://github.com/stripe/stripe-ruby/pull/1458 + if Gem::Version.new(Stripe::VERSION) >= Gem::Version.new('13.0.0') + Stripe::APIRequestor.stub(:default_connection_manager, @connection) do + @connection.stub(:execute_request, @response) do + yield + end + end + else + Stripe::StripeClient.stub(:default_connection_manager, @connection) do + @connection.stub(:execute_request, @response) do + yield + end end end end From 15b0df8a57bc9c5624fa6889f369b595584cb21c Mon Sep 17 00:00:00 2001 From: fallwith Date: Fri, 4 Oct 2024 17:38:39 -0700 Subject: [PATCH 10/59] increase db.statement threshold to 4096 increase the db.statement max from 2000 to 4096 as per the updated cross agent spec --- lib/new_relic/agent/span_event_primitive.rb | 6 ++++-- .../transaction/datastore_segment_test.rb | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/new_relic/agent/span_event_primitive.rb b/lib/new_relic/agent/span_event_primitive.rb index 09c96fcf0b..ef2ef8882b 100644 --- a/lib/new_relic/agent/span_event_primitive.rb +++ b/lib/new_relic/agent/span_event_primitive.rb @@ -52,6 +52,8 @@ module SpanEventPrimitive DATASTORE_CATEGORY = 'datastore' CLIENT = 'client' + DB_STATEMENT_MAX_BYTES = 4096 + # Builds a Hash of error attributes as well as the Span ID when # an error is present. Otherwise, returns nil when no error present. def error_attributes(segment) @@ -114,9 +116,9 @@ def for_datastore_segment(segment) # rubocop:disable Metrics/AbcSize agent_attributes[DB_SYSTEM_KEY] = segment.product if allowed?(DB_SYSTEM_KEY) if segment.sql_statement && allowed?(DB_STATEMENT_KEY) - agent_attributes[DB_STATEMENT_KEY] = truncate(segment.sql_statement.safe_sql, 2000) + agent_attributes[DB_STATEMENT_KEY] = truncate(segment.sql_statement.safe_sql, DB_STATEMENT_MAX_BYTES) elsif segment.nosql_statement && allowed?(DB_STATEMENT_KEY) - agent_attributes[DB_STATEMENT_KEY] = truncate(segment.nosql_statement, 2000) + agent_attributes[DB_STATEMENT_KEY] = truncate(segment.nosql_statement, DB_STATEMENT_MAX_BYTES) end [intrinsics, custom_attributes(segment), agent_attributes.merge(agent_attributes(segment))] diff --git a/test/new_relic/agent/transaction/datastore_segment_test.rb b/test/new_relic/agent/transaction/datastore_segment_test.rb index 9385d92db8..a888034664 100644 --- a/test/new_relic/agent/transaction/datastore_segment_test.rb +++ b/test/new_relic/agent/transaction/datastore_segment_test.rb @@ -383,6 +383,7 @@ def test_nosql_statement_added_to_span_event_if_present end def test_span_event_truncates_long_sql_statement + select = 'select * from ' with_config(:'transaction_tracer.record_sql' => 'raw') do in_transaction('wat') do |txn| txn.stubs(:sampled?).returns(true) @@ -392,7 +393,7 @@ def test_span_event_truncates_long_sql_statement operation: 'select' ) - sql_statement = "select * from #{'a' * 2500}" + sql_statement = "#{select}#{'a' * (SpanEventPrimitive::DB_STATEMENT_MAX_BYTES + 500)}" segment.notice_sql(sql_statement) segment.finish @@ -401,12 +402,15 @@ def test_span_event_truncates_long_sql_statement last_span_events = NewRelic::Agent.agent.span_event_aggregator.harvest![1] _, _, agent_attributes = last_span_events[0] + ellipsis = '...' - assert_equal 2000, agent_attributes['db.statement'].bytesize - assert_equal "select * from #{'a' * 1983}...", agent_attributes['db.statement'] + assert_equal SpanEventPrimitive::DB_STATEMENT_MAX_BYTES, agent_attributes['db.statement'].bytesize + assert_equal "#{select}#{'a' * (SpanEventPrimitive::DB_STATEMENT_MAX_BYTES - select.size - ellipsis.size)}#{ellipsis}", + agent_attributes['db.statement'] end def test_span_event_truncates_long_nosql_statement + set_mykey = 'set mykey ' in_transaction('wat') do |txn| txn.stubs(:sampled?).returns(true) @@ -414,7 +418,7 @@ def test_span_event_truncates_long_nosql_statement product: 'Redis', operation: 'set' ) - statement = "set mykey #{'a' * 2500}" + statement = "#{set_mykey}#{'a' * (SpanEventPrimitive::DB_STATEMENT_MAX_BYTES + 500)}" segment.notice_nosql_statement(statement) segment.finish @@ -422,9 +426,11 @@ def test_span_event_truncates_long_nosql_statement last_span_events = NewRelic::Agent.agent.span_event_aggregator.harvest![1] _, _, agent_attributes = last_span_events[0] + ellipsis = '...' - assert_equal 2000, agent_attributes['db.statement'].bytesize - assert_equal "set mykey #{'a' * 1987}...", agent_attributes['db.statement'] + assert_equal SpanEventPrimitive::DB_STATEMENT_MAX_BYTES, agent_attributes['db.statement'].bytesize + assert_equal "#{set_mykey}#{'a' * (SpanEventPrimitive::DB_STATEMENT_MAX_BYTES - set_mykey.size - ellipsis.size)}#{ellipsis}", + agent_attributes['db.statement'] end def test_span_event_truncates_long_attributes From 59d9bce6c7920a8fa0a466a1a8f69627ac860fb9 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 7 Oct 2024 16:55:02 -0700 Subject: [PATCH 11/59] Test Ruby 3.4.0-preview2 --- .github/versions.yml | 4 ++-- .github/workflows/ci.yml | 10 +++++----- .github/workflows/ci_cron.yml | 16 ++++++++-------- .github/workflows/ci_jruby.yml | 4 ++-- .github/workflows/ci_special.yml | 8 ++++---- .github/workflows/config_docs.yml | 2 +- .github/workflows/performance_tests.yml | 2 +- .github/workflows/prerelease.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/release_notes.yml | 2 +- .github/workflows/release_pr.yml | 2 +- .github/workflows/slack_notifications.yml | 4 ++-- 12 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/versions.yml b/.github/versions.yml index 467f91ad92..ec146e2ee9 100644 --- a/.github/versions.yml +++ b/.github/versions.yml @@ -1,8 +1,8 @@ --- # This file is consumed by lib/tasks/gha.rake ruby/setup-ruby: - :tag: v1.191.0 - :sha: 52753b7da854d5c07df37391a986c76ab4615999 + :tag: v1.196.0 + :sha: f26937343756480a8cb3ae1f623b9c8d89ed6984 actions/checkout: :tag: v4.1.7 :sha: 692973e3d937129bcbf40652eb9f2f61becf3332 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0be439be24..156c7fc6a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: - name: Configure git run: 'git config --global init.defaultBranch main' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: '3.3' - run: bundle @@ -49,7 +49,7 @@ jobs: run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev - name: Install Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: ${{ matrix.ruby-version }} @@ -231,7 +231,7 @@ jobs: run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev - name: Install Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: ${{ matrix.ruby-version }} @@ -324,7 +324,7 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - name: Install Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: ${{ matrix.ruby-version }} @@ -364,7 +364,7 @@ jobs: - name: Configure git run: 'git config --global init.defaultBranch main' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: '3.3' - run: bundle diff --git a/.github/workflows/ci_cron.yml b/.github/workflows/ci_cron.yml index 02dd0a08aa..2efa9625f8 100644 --- a/.github/workflows/ci_cron.yml +++ b/.github/workflows/ci_cron.yml @@ -16,7 +16,7 @@ jobs: - name: Configure git run: 'git config --global init.defaultBranch main' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: '3.3' - run: bundle @@ -36,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview1] + ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview2] steps: - name: Configure git @@ -50,7 +50,7 @@ jobs: run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev - name: Install Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: ${{ matrix.ruby-version }} @@ -84,7 +84,7 @@ jobs: "3.3.5": { "rails": "norails,rails61,rails70,rails71,rails72,railsedge" }, - "3.4.0-preview1": { + "3.4.0-preview2": { "rails": "norails,rails61,rails70,rails71,rails72" } } @@ -230,7 +230,7 @@ jobs: fail-fast: false matrix: multiverse: [agent, ai, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest] - ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview1] + ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview2] steps: - name: Configure git run: 'git config --global init.defaultBranch main' @@ -243,7 +243,7 @@ jobs: run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev - name: Install Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: ${{ matrix.ruby-version }} @@ -308,14 +308,14 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: [2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview1] + ruby-version: [2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview2] steps: - name: Configure git run: 'git config --global init.defaultBranch main' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - name: Install Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: ${{ matrix.ruby-version }} diff --git a/.github/workflows/ci_jruby.yml b/.github/workflows/ci_jruby.yml index 4f48127c64..ca72ecb3d2 100644 --- a/.github/workflows/ci_jruby.yml +++ b/.github/workflows/ci_jruby.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - name: Install JRuby - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: jruby-9.4.8.0 @@ -49,7 +49,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - name: Install JRuby - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: jruby-9.4.8.0 diff --git a/.github/workflows/ci_special.yml b/.github/workflows/ci_special.yml index 46e3e0c9f3..c584f6d7b5 100644 --- a/.github/workflows/ci_special.yml +++ b/.github/workflows/ci_special.yml @@ -20,15 +20,15 @@ jobs: - name: Install OS packages run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev - - name: Install Ruby 3.4.0-preview1 - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - name: Install Ruby 3.4.0-preview2 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: - ruby-version: 3.4.0-preview1 + ruby-version: 3.4.0-preview2 - name: Setup bundler run: ./.github/workflows/scripts/setup_bundler env: - RUBY_VERSION: 3.4.0-preview1 + RUBY_VERSION: 3.4.0-preview2 - name: Run Unit Tests uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # tag v3.0.0 diff --git a/.github/workflows/config_docs.yml b/.github/workflows/config_docs.yml index 22aee84aec..b45984345c 100644 --- a/.github/workflows/config_docs.yml +++ b/.github/workflows/config_docs.yml @@ -15,7 +15,7 @@ jobs: pull-requests: write steps: - name: Install Ruby 3.3 - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 diff --git a/.github/workflows/performance_tests.yml b/.github/workflows/performance_tests.yml index 1aceb9e60d..19987a61c8 100644 --- a/.github/workflows/performance_tests.yml +++ b/.github/workflows/performance_tests.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 with: ref: 'main' - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: '3.3' - run: bundle diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 8ceb0aced4..1dbb8d5c6e 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -11,7 +11,7 @@ jobs: pull-requests: write steps: - name: Install Ruby 3.3 - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a96f4a10c7..c0505d04ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: with: fetch-depth: 0 - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 diff --git a/.github/workflows/release_notes.yml b/.github/workflows/release_notes.yml index ed77a6748e..a70fa4b4d3 100644 --- a/.github/workflows/release_notes.yml +++ b/.github/workflows/release_notes.yml @@ -13,7 +13,7 @@ jobs: contents: write pull-requests: write steps: - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 - name: Checkout code diff --git a/.github/workflows/release_pr.yml b/.github/workflows/release_pr.yml index ec1015ecbf..e2507ae607 100644 --- a/.github/workflows/release_pr.yml +++ b/.github/workflows/release_pr.yml @@ -14,7 +14,7 @@ jobs: pull-requests: write steps: - name: Install Ruby 3.3 - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 diff --git a/.github/workflows/slack_notifications.yml b/.github/workflows/slack_notifications.yml index 0dd7074859..5b53187943 100644 --- a/.github/workflows/slack_notifications.yml +++ b/.github/workflows/slack_notifications.yml @@ -8,7 +8,7 @@ jobs: gem_notifications: runs-on: ubuntu-22.04 steps: - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 @@ -47,7 +47,7 @@ jobs: cve_notifications: runs-on: ubuntu-22.04 steps: - - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0 + - uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 From e890bd02caf6460532a0ec4cf11fbddf3270bda7 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Tue, 8 Oct 2024 10:41:51 -0500 Subject: [PATCH 12/59] Update CHANGELOG.md Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f092af903b..e26f1faa46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Version resolves a bug in rdkafka instrumentation when using the karafka-r - **Bugfix: Instrumentation errors when using the karafka-rdkafka gem** - Due to version differences between the rdkafka gem and karafka-rdkafka gem, the agent was installing instrumentation on some versions of karafka-rdkafka that encountered errors. This has now been resolved. Thank you to @krisdigital for bringing this issue to our attention. [PR#2880](https://github.com/newrelic/newrelic-ruby-agent/pull/2880) + Due to version differences between the rdkafka gem and karafka-rdkafka gem, the agent could encounter an error when it tried to install rdkafka instrumentation. This has now been resolved. Thank you to @krisdigital for bringing this issue to our attention. [PR#2880](https://github.com/newrelic/newrelic-ruby-agent/pull/2880) ## v9.14.0 From f01539d4443c87f97641be1db1adc19e728bb5bc Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Tue, 8 Oct 2024 13:28:34 -0500 Subject: [PATCH 13/59] add aws_account_id config --- lib/new_relic/agent/aws.rb | 51 ++----------------- .../agent/configuration/default_source.rb | 7 +++ .../dynamodb/instrumentation.rb | 15 ++---- .../dynamodb/dynamodb_instrumentation_test.rb | 4 +- test/new_relic/agent/aws_test.rb | 20 +++----- 5 files changed, 22 insertions(+), 75 deletions(-) diff --git a/lib/new_relic/agent/aws.rb b/lib/new_relic/agent/aws.rb index 81dcd9e862..79646c61d5 100644 --- a/lib/new_relic/agent/aws.rb +++ b/lib/new_relic/agent/aws.rb @@ -5,58 +5,13 @@ module NewRelic module Agent module Aws - CHARACTERS = %w[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 2 3 4 5 6 7].freeze - HEX_MASK = '7fffffffff80' + def self.create_arn(service, resource, region) + return unless NewRelic::Agent.config[:'aws_account_id'] - def self.create_arn(service, resource, region, account_id) - "arn:aws:#{service}:#{region}:#{account_id}:#{resource}" + "arn:aws:#{service}:#{region}:#{NewRelic::Agent.config[:'aws_account_id']}:#{resource}" rescue => e NewRelic::Agent.logger.warn("Failed to create ARN: #{e}") end - - def self.get_account_id(config) - access_key_id = config.credentials.credentials.access_key_id if config&.credentials&.credentials&.respond_to?(:access_key_id) - return unless access_key_id - - NewRelic::Agent::Aws.convert_access_key_to_account_id(access_key_id) - rescue => e - NewRelic::Agent.logger.debug("Failed to create account id: #{e}") - end - - def self.convert_access_key_to_account_id(access_key) - decoded_key = Integer(decode_to_hex(access_key[4..-1]), 16) - mask = Integer(HEX_MASK, 16) - (decoded_key & mask) >> 7 - end - - def self.decode_to_hex(access_key) - bytes = access_key.delete('=').each_char.map { |c| CHARACTERS.index(c) } - - bytes.each_slice(8).map do |section| - convert_section(section) - end.flatten[0...6].join - end - - def self.convert_section(section) - buffer = 0 - section.each do |chunk| - buffer = (buffer << 5) + chunk - end - - chunk_count = (section.length * 5.0 / 8.0).floor - - if section.length < 8 - buffer >>= (5 - (chunk_count * 8)) % 5 - end - - decoded = [] - chunk_count.times do |i| - shift = 8 * (chunk_count - 1 - i) - decoded << ((buffer >> shift) & 255).to_s(16) - end - - decoded - end end end end diff --git a/lib/new_relic/agent/configuration/default_source.rb b/lib/new_relic/agent/configuration/default_source.rb index e091c8ecf3..08c73b1ae7 100644 --- a/lib/new_relic/agent/configuration/default_source.rb +++ b/lib/new_relic/agent/configuration/default_source.rb @@ -429,6 +429,13 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil) :allowed_from_server => false, :description => 'Your New Relic . Required when using the New Relic REST API v2 to record deployments using the `newrelic deployments` command.' }, + :aws_account_id => { + :default => nil, + :public => true, + :type => String, + :allowed_from_server => false, + :description => 'The AWS account ID for the associated AWS account' + }, :backport_fast_active_record_connection_lookup => { :default => false, :public => true, diff --git a/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb b/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb index cf869660f4..721c41e582 100644 --- a/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +++ b/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb @@ -31,9 +31,8 @@ def instrument_method_with_new_relic(method_name, *args) collection: args[0][:table_name] ) - # TODO: Update this when it has been decided how to handle account id for ARN - # arn = get_arn(args[0]) - # segment&.add_agent_attribute('cloud.resource_id', arn) if arn + arn = get_arn(args[0]) + segment&.add_agent_attribute('cloud.resource_id', arn) if arn @nr_captured_request = nil # clear request just in case begin @@ -50,16 +49,10 @@ def build_request_with_new_relic(*args) @nr_captured_request = yield end - def nr_account_id - return @nr_account_id if defined?(@nr_account_id) - - @nr_account_id = NewRelic::Agent::Aws.get_account_id(config) - end - def get_arn(params) - return unless params[:table_name] && nr_account_id + return unless params[:table_name] - NewRelic::Agent::Aws.create_arn(PRODUCT.downcase, "table/#{params[:table_name]}", config&.region, nr_account_id) + NewRelic::Agent::Aws.create_arn(PRODUCT.downcase, "table/#{params[:table_name]}", config&.region) end end end diff --git a/test/multiverse/suites/dynamodb/dynamodb_instrumentation_test.rb b/test/multiverse/suites/dynamodb/dynamodb_instrumentation_test.rb index 9da2e08885..73c421ac4a 100644 --- a/test/multiverse/suites/dynamodb/dynamodb_instrumentation_test.rb +++ b/test/multiverse/suites/dynamodb/dynamodb_instrumentation_test.rb @@ -8,7 +8,6 @@ class DynamodbInstrumentationTest < Minitest::Test def setup Aws.config.update(stub_responses: true) NewRelic::Agent::Aws.stubs(:create_arn).returns('test-arn') - NewRelic::Agent::Aws.stubs(:get_account_id).returns('123456789') @stats_engine = NewRelic::Agent.instance.stats_engine end @@ -42,8 +41,7 @@ def test_all_attributes_added_to_segment assert_equal 'us-east-2', span[2]['aws.region'] assert_equal 'query', span[2]['aws.operation'] assert_equal '1234321', span[2]['aws.requestId'] - # TODO: Uncomment this when the ARN is added to the segment - # assert_equal 'test-arn', span[2]['cloud.resource_id'] + assert_equal 'test-arn', span[2]['cloud.resource_id'] end def test_create_table_table_name_operation diff --git a/test/new_relic/agent/aws_test.rb b/test/new_relic/agent/aws_test.rb index 61f32c81d0..aae708b2fc 100644 --- a/test/new_relic/agent/aws_test.rb +++ b/test/new_relic/agent/aws_test.rb @@ -10,22 +10,16 @@ def test_create_arn region = 'us-test-region-1' account_id = '123456789' resource = 'test/test-resource' - arn = NewRelic::Agent::Aws.create_arn(service, resource, region, account_id) - expected = 'arn:aws:test-service:us-test-region-1:123456789:test/test-resource' - assert_equal expected, arn - end - - def test_get_account_id - config = mock - mock_credentials = mock - mock_credentials.stubs(:credentials).returns(mock_credentials) - mock_credentials.stubs(:access_key_id).returns('AKIAIOSFODNN7EXAMPLE') # this is a fake access key id from aws docs - config.stubs(:credentials).returns(mock_credentials) + with_config(aws_account_id: account_id) do + arn = NewRelic::Agent::Aws.create_arn(service, resource, region) - account_id = NewRelic::Agent::Aws.get_account_id(config) + assert_equal expected, arn + end + end - assert_equal 36315003739, account_id + def test_doesnt_create_arn_no_account_id + assert_nil NewRelic::Agent::Aws.create_arn('service', 'resource', 'region') end end From a1ad06e9767144bdca72b18d2d032c59d7db0c43 Mon Sep 17 00:00:00 2001 From: fallwith Date: Tue, 8 Oct 2024 13:46:06 -0700 Subject: [PATCH 14/59] tests script: perform cleanup clean up content on each fresh test run instance --- test/script/run_tests | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/script/run_tests b/test/script/run_tests index 45e8e437a9..e6160cd2f5 100755 --- a/test/script/run_tests +++ b/test/script/run_tests @@ -51,7 +51,6 @@ help() { echo " " } - unit_command() { # echo "ENV TEST="$TEST" TESTOPTS="$TESTOPTS"" # echo "bundle exec rake test -q;" @@ -78,6 +77,8 @@ set_test_opts() { # organizes the args for mutiverse and calls the command run_multiverse() { + clean + if [[ -n "$3" ]]; then # echo "running file and name" multiverse_command "$1",file="$2",name="$3"; @@ -95,6 +96,8 @@ run_multiverse() { # calls multiverse but only env 0 or specified and method prepend run_multiverse_quick() { + clean + if [[ "$2" =~ [0-9]+ && ! "$2" =~ ^test ]]; then run_multiverse "$1",env="$2",method=prepend "$3" "$4" else @@ -104,6 +107,8 @@ run_multiverse_quick() { # organizes the args for env tests and calls the command run_env_tests() { + clean + # this will add "rails" before any number so you can pass in just "61" or "61,70" ENVARGS=$(echo "$1" | sed -E -e 's/(\,)|(\,rails)/,rails/g' | sed '/^rails/!s/^/rails/'); @@ -126,6 +131,8 @@ run_env_tests() { # organizes the args for the unit tests and calls the command run_unit_tests() { + clean + find_test_file "$1" "new_relic" if [[ -n "$2" ]]; then # echo "running file and name" @@ -144,6 +151,15 @@ run_unit_tests() { fi } +clean() { + echo 'Cleaning...' + # xargs over -exec to avoid warnings on already-deleted content + find . -name \*.log | xargs rm -f + find . -name tmp -type d | xargs rm -rf + rm -rf lib/coverage test/minitest/minitest_time_report test/multiverse/lib/multiverse/errors.txt + echo 'Done.' +} + # from a given space/newline delimited string of file paths, return the # shortest path # From f676e9c9c9c33b7b7fdca40bf7026ca6f02a2972 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 8 Oct 2024 16:21:11 -0700 Subject: [PATCH 15/59] Add assertion condition for 3.4 support The JSON string output changed in Ruby 3.4 to remove the hash rocket Pre Ruby 3.4: :app_name=>\"test\" Ruby 3.4+: app_name: \"test\" --- .../agent/configuration/manager_test.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/new_relic/agent/configuration/manager_test.rb b/test/new_relic/agent/configuration/manager_test.rb index b574690a98..974c02029f 100644 --- a/test/new_relic/agent/configuration/manager_test.rb +++ b/test/new_relic/agent/configuration/manager_test.rb @@ -533,8 +533,20 @@ def test_unsatisfied_values_stay_cached def test_logger_does_not_receive_excluded_settings log = with_array_logger(:debug) { @manager.log_config('direction', 'source') }.array.join('') - assert_includes(log, ':app_name') - refute_includes(log, ':license_key') + # TODO: OLD RUBIES - RUBY_VERSION < 3.4 + # The JSON string output changed in Ruby 3.4 to remove the hash rocket + # Pre Ruby 3.4: + # :app_name=>\"test\" + # Ruby 3.4+: + # app_name: \"test\" + # Remove the condition once we support only version 3.4+ + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0') + assert_includes(log, 'app_name:') + refute_includes(log, 'license_key:') + else + assert_includes(log, ':app_name') + refute_includes(log, ':license_key') + end end def test_reset_cache_return_early_for_jruby From c15513fd275a966055684aaf5239dee303f28ba9 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 8 Oct 2024 16:24:29 -0700 Subject: [PATCH 16/59] Exclude api_key from reported settings --- lib/new_relic/agent/configuration/default_source.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/new_relic/agent/configuration/default_source.rb b/lib/new_relic/agent/configuration/default_source.rb index e091c8ecf3..77b3240e8a 100644 --- a/lib/new_relic/agent/configuration/default_source.rb +++ b/lib/new_relic/agent/configuration/default_source.rb @@ -427,6 +427,7 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil) :public => true, :type => String, :allowed_from_server => false, + :exclude_from_reported_settings => true, :description => 'Your New Relic . Required when using the New Relic REST API v2 to record deployments using the `newrelic deployments` command.' }, :backport_fast_active_record_connection_lookup => { From fc522468388008cdd56014856c07313c6e2e0a78 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 8 Oct 2024 16:58:36 -0700 Subject: [PATCH 17/59] Add TODO to fix the test before 3.4 is released --- .../config_file_loading_test.rb | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/multiverse/suites/config_file_loading/config_file_loading_test.rb b/test/multiverse/suites/config_file_loading/config_file_loading_test.rb index 15b18c5cd2..953427bea7 100644 --- a/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +++ b/test/multiverse/suites/config_file_loading/config_file_loading_test.rb @@ -158,15 +158,20 @@ def test_warning_logged_when_config_file_yaml_parsing_error assert_log_contains(log, /ERROR.*Failed to read or parse configuration file at config\/newrelic\.yml/) end - def test_warning_logged_when_config_file_erb_error - path = File.join(@cwd, 'config', 'newrelic.yml') - setup_config(path, {}, "\n\n\n<%= this is not ruby %>") # the error is on line 4 - setup_agent - - log = with_array_logger { NewRelic::Agent.manual_start } - - assert_log_contains(log, /ERROR.*Failed ERB processing/) - assert_log_contains(log, /\(erb\):4/) + # TODO: RUBY 3.4 SUPPORT + # Both error class and output have changes in Ruby 3.4 + # See Issue: https://github.com/newrelic/newrelic-ruby-agent/issues/2902 + unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0') + def test_warning_logged_when_config_file_erb_error + path = File.join(@cwd, 'config', 'newrelic.yml') + setup_config(path, {}, "\n\n\n<%= this is not ruby %>") # the error is on line 4 + setup_agent + + log = with_array_logger { NewRelic::Agent.manual_start } + + assert_log_contains(log, /ERROR.*Failed ERB processing/) + assert_log_contains(log, /\(erb\):4/) + end end def test_exclude_commented_out_erb_lines From 55a23dc550ae06e5b49907039aa54c2f785a996d Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 8 Oct 2024 16:58:58 -0700 Subject: [PATCH 18/59] Improve failure output for assert_log_contains --- test/agent_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/agent_helper.rb b/test/agent_helper.rb index f53f4b7af3..ae7dfea555 100644 --- a/test/agent_helper.rb +++ b/test/agent_helper.rb @@ -112,7 +112,7 @@ def assert_log_contains(log, message) lines = log.array assert (lines.any? { |line| line.match(message) }), - "Could not find message. Log contained: #{lines.join("\n")}" + "Could not find message: '#{message.inspect}'. Log contained: #{lines.join("\n")}" end def assert_audit_log_contains(audit_log_contents, needle) From 3d7b502ffaaafd167596e79744ee3fb457e49fb5 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Wed, 9 Oct 2024 09:46:23 -0700 Subject: [PATCH 19/59] stringio CI test --- test/multiverse/suites/config_file_loading/Envfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/multiverse/suites/config_file_loading/Envfile b/test/multiverse/suites/config_file_loading/Envfile index 819a8a1039..1921696d6a 100644 --- a/test/multiverse/suites/config_file_loading/Envfile +++ b/test/multiverse/suites/config_file_loading/Envfile @@ -10,14 +10,23 @@ PSYCH_VERSIONS = [ ['3.3.0', 2.4] ] +def stringio_version + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4') + "gem 'stringio', '3.1.1-dev'" + else + "gem 'stringio'" + end +end + def gem_list(psych_version = nil) <<~RB + #{stringio_version} # stub file system so we can test that newrelic.yml can be loaded from # various places. gem 'fakefs', :require => false gem 'psych'#{psych_version} - gem 'jar-dependencies', '0.4.1' if RUBY_PLATFORM == 'java' + gem 'jar-dependencies', '0.4.1' if RUBY_PLATFORM == 'java' # don't start the agent gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../') From 744ef7ae609f478c647b69338ffcc606ed6b3992 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Wed, 9 Oct 2024 09:47:44 -0700 Subject: [PATCH 20/59] Update stringio version --- test/multiverse/suites/config_file_loading/Envfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/multiverse/suites/config_file_loading/Envfile b/test/multiverse/suites/config_file_loading/Envfile index 1921696d6a..2064256007 100644 --- a/test/multiverse/suites/config_file_loading/Envfile +++ b/test/multiverse/suites/config_file_loading/Envfile @@ -12,7 +12,7 @@ PSYCH_VERSIONS = [ def stringio_version if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4') - "gem 'stringio', '3.1.1-dev'" + "gem 'stringio', '3.1.2.dev'" else "gem 'stringio'" end From 2578d2214bd2b4fa29384f931e28213f10847623 Mon Sep 17 00:00:00 2001 From: fallwith Date: Wed, 9 Oct 2024 12:36:31 -0700 Subject: [PATCH 21/59] berm/bermq: only clean once given than `berm` and `bermq` both follow the same path, prevent duplicate cleaning operations --- test/script/run_tests | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/script/run_tests b/test/script/run_tests index e6160cd2f5..3bbcc2f6f9 100755 --- a/test/script/run_tests +++ b/test/script/run_tests @@ -96,8 +96,6 @@ run_multiverse() { # calls multiverse but only env 0 or specified and method prepend run_multiverse_quick() { - clean - if [[ "$2" =~ [0-9]+ && ! "$2" =~ ^test ]]; then run_multiverse "$1",env="$2",method=prepend "$3" "$4" else From 62435f5490a37e77af70a7b84dc008e2901af6eb Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Wed, 9 Oct 2024 14:49:20 -0500 Subject: [PATCH 22/59] use cloud.aws.account_id for config name --- lib/new_relic/agent/aws.rb | 4 ++-- .../agent/configuration/default_source.rb | 14 +++++++------- test/new_relic/agent/aws_test.rb | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/new_relic/agent/aws.rb b/lib/new_relic/agent/aws.rb index 79646c61d5..cb1d4f53a9 100644 --- a/lib/new_relic/agent/aws.rb +++ b/lib/new_relic/agent/aws.rb @@ -6,9 +6,9 @@ module NewRelic module Agent module Aws def self.create_arn(service, resource, region) - return unless NewRelic::Agent.config[:'aws_account_id'] + return unless NewRelic::Agent.config[:'cloud.aws.account_id'] - "arn:aws:#{service}:#{region}:#{NewRelic::Agent.config[:'aws_account_id']}:#{resource}" + "arn:aws:#{service}:#{region}:#{NewRelic::Agent.config[:'cloud.aws.account_id']}:#{resource}" rescue => e NewRelic::Agent.logger.warn("Failed to create ARN: #{e}") end diff --git a/lib/new_relic/agent/configuration/default_source.rb b/lib/new_relic/agent/configuration/default_source.rb index 08c73b1ae7..4d52226a90 100644 --- a/lib/new_relic/agent/configuration/default_source.rb +++ b/lib/new_relic/agent/configuration/default_source.rb @@ -429,13 +429,6 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil) :allowed_from_server => false, :description => 'Your New Relic . Required when using the New Relic REST API v2 to record deployments using the `newrelic deployments` command.' }, - :aws_account_id => { - :default => nil, - :public => true, - :type => String, - :allowed_from_server => false, - :description => 'The AWS account ID for the associated AWS account' - }, :backport_fast_active_record_connection_lookup => { :default => false, :public => true, @@ -478,6 +471,13 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil) :allowed_from_server => false, :description => 'If `true`, the agent will clear `Tracer::State` in `Agent.drop_buffered_data`.' }, + :'cloud.aws.account_id' => { + :default => nil, + :public => true, + :type => String, + :allowed_from_server => false, + :description => 'The AWS account ID for the associated AWS account' + }, :config_path => { :default => DefaultSource.config_path, :public => true, diff --git a/test/new_relic/agent/aws_test.rb b/test/new_relic/agent/aws_test.rb index aae708b2fc..7af8b8247f 100644 --- a/test/new_relic/agent/aws_test.rb +++ b/test/new_relic/agent/aws_test.rb @@ -12,7 +12,7 @@ def test_create_arn resource = 'test/test-resource' expected = 'arn:aws:test-service:us-test-region-1:123456789:test/test-resource' - with_config(aws_account_id: account_id) do + with_config('cloud.aws.account_id': account_id) do arn = NewRelic::Agent::Aws.create_arn(service, resource, region) assert_equal expected, arn From c14fb1fac06e3f765d8fac5d9ae7d0feb5b246bc Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Wed, 9 Oct 2024 15:06:14 -0500 Subject: [PATCH 23/59] add changelog entry --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e26f1faa46..540c3bd8e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ ## dev -Version resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. +Version adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS sdk, and resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. + +- **Feature: New configuration option cloud.aws.account_id** + + A new configuration option has been added, `cloud.aws.account_id`, that will allow New Relic to provide more details about certain calls made using the AWS sdk. Currently, the DynamoDB instrumentation is the only instrumentation that will make use of this configuration option, but this will be used in future instrumentation as well. [PR#2904](https://github.com/newrelic/newrelic-ruby-agent/pull/2904) - **Bugfix: Instrumentation errors when using the karafka-rdkafka gem** From 1b18a18bb575e97308a68ffbfb621e928bbb9b1a Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Wed, 9 Oct 2024 15:10:38 -0700 Subject: [PATCH 24/59] Skip config_file_loading suite on Ruby 3.4 --- test/multiverse/suites/config_file_loading/Envfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/multiverse/suites/config_file_loading/Envfile b/test/multiverse/suites/config_file_loading/Envfile index 2064256007..c90f1707e8 100644 --- a/test/multiverse/suites/config_file_loading/Envfile +++ b/test/multiverse/suites/config_file_loading/Envfile @@ -4,10 +4,15 @@ omit_collector! +# TODO: RUBY 3.4 +# The CI has a prism-related error when it tries to run this suite +# The problem may be a bug fixed in future preview releases +# Disable ths suite for now, and try again when the next version +# is out. PSYCH_VERSIONS = [ - [nil], - ['4.0.0', 2.4], - ['3.3.0', 2.4] + [nil, 2.4, 3.3], + ['4.0.0', 2.4, 3.3], + ['3.3.0', 2.4, 3.3] ] def stringio_version From 42847f0b8dbd0d3863e9b6d791af0c23f8fef60c Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Thu, 10 Oct 2024 10:23:07 -0500 Subject: [PATCH 25/59] add allow nil to config --- lib/new_relic/agent/configuration/default_source.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/new_relic/agent/configuration/default_source.rb b/lib/new_relic/agent/configuration/default_source.rb index 4d52226a90..38b27bfae4 100644 --- a/lib/new_relic/agent/configuration/default_source.rb +++ b/lib/new_relic/agent/configuration/default_source.rb @@ -475,6 +475,7 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil) :default => nil, :public => true, :type => String, + :allow_nil => true, :allowed_from_server => false, :description => 'The AWS account ID for the associated AWS account' }, From c0091a31848a6008eac03e9bf0b7fac03d26eee2 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Thu, 10 Oct 2024 09:41:34 -0700 Subject: [PATCH 26/59] Simplify excluded_settings test --- .../agent/configuration/manager_test.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/test/new_relic/agent/configuration/manager_test.rb b/test/new_relic/agent/configuration/manager_test.rb index 974c02029f..cc2bc78349 100644 --- a/test/new_relic/agent/configuration/manager_test.rb +++ b/test/new_relic/agent/configuration/manager_test.rb @@ -533,20 +533,8 @@ def test_unsatisfied_values_stay_cached def test_logger_does_not_receive_excluded_settings log = with_array_logger(:debug) { @manager.log_config('direction', 'source') }.array.join('') - # TODO: OLD RUBIES - RUBY_VERSION < 3.4 - # The JSON string output changed in Ruby 3.4 to remove the hash rocket - # Pre Ruby 3.4: - # :app_name=>\"test\" - # Ruby 3.4+: - # app_name: \"test\" - # Remove the condition once we support only version 3.4+ - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0') - assert_includes(log, 'app_name:') - refute_includes(log, 'license_key:') - else - assert_includes(log, ':app_name') - refute_includes(log, ':license_key') - end + assert_includes(log, 'app_name') + refute_includes(log, 'license_key') end def test_reset_cache_return_early_for_jruby From 086420fa0decac70c005209c75c665a6372c3926 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Thu, 10 Oct 2024 12:26:33 -0500 Subject: [PATCH 27/59] Update CHANGELOG.md Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 540c3bd8e9..d0e40a536a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## dev -Version adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS sdk, and resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. +Version adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS SDK, and resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. - **Feature: New configuration option cloud.aws.account_id** From 22b367c57481c7858d1ce500893c5350b255f1de Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Thu, 10 Oct 2024 12:26:38 -0500 Subject: [PATCH 28/59] Update CHANGELOG.md Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e40a536a..9f35013567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Version adds a configuration option to associate the AWS account ID with t - **Feature: New configuration option cloud.aws.account_id** - A new configuration option has been added, `cloud.aws.account_id`, that will allow New Relic to provide more details about certain calls made using the AWS sdk. Currently, the DynamoDB instrumentation is the only instrumentation that will make use of this configuration option, but this will be used in future instrumentation as well. [PR#2904](https://github.com/newrelic/newrelic-ruby-agent/pull/2904) + A new configuration option has been added, `cloud.aws.account_id`, that will allow New Relic to provide more details about certain calls made using the AWS SDK. Currently, the DynamoDB instrumentation is the only instrumentation that will make use of this configuration option, but this will be used in future instrumentation as well. [PR#2904](https://github.com/newrelic/newrelic-ruby-agent/pull/2904) - **Bugfix: Instrumentation errors when using the karafka-rdkafka gem** From 0b65bd70f789db4a712e52735b6c5f6b56d354c3 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Thu, 10 Oct 2024 12:26:49 -0500 Subject: [PATCH 29/59] Update lib/new_relic/agent/configuration/default_source.rb Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- lib/new_relic/agent/configuration/default_source.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/new_relic/agent/configuration/default_source.rb b/lib/new_relic/agent/configuration/default_source.rb index 38b27bfae4..45059d619b 100644 --- a/lib/new_relic/agent/configuration/default_source.rb +++ b/lib/new_relic/agent/configuration/default_source.rb @@ -477,7 +477,7 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil) :type => String, :allow_nil => true, :allowed_from_server => false, - :description => 'The AWS account ID for the associated AWS account' + :description => 'The AWS account ID for the AWS account associated with this app' }, :config_path => { :default => DefaultSource.config_path, From 9fc88282927e679b1a08cb8a9f133995bce26d18 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Thu, 10 Oct 2024 12:39:52 -0700 Subject: [PATCH 30/59] Update newrelic-grape check logic --- lib/new_relic/agent/instrumentation/grape.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/new_relic/agent/instrumentation/grape.rb b/lib/new_relic/agent/instrumentation/grape.rb index 1424ffa06b..c4b24d7379 100644 --- a/lib/new_relic/agent/instrumentation/grape.rb +++ b/lib/new_relic/agent/instrumentation/grape.rb @@ -19,9 +19,13 @@ depends_on do begin - if defined?(Bundler) && - ((Bundler.rubygems.respond_to?(:installed_specs) && Bundler.rubygems.installed_specs.map(&:name).include?('newrelic-grape')) || - Bundler.rubygems.all_specs.map(&:name).include?('newrelic-grape')) + specs = if Bundler.rubygems.respond_to?(:installed_specs) + Bundler.rubygems.installed_specs + else + Bundler.rubygems.all_specs + end + + if specs.map(&:name).include?('newrelic-grape') NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present') false else From 52bb44eddd7dc8f5285c67dc3a5a8e0f217a92c1 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:23:17 -0700 Subject: [PATCH 31/59] Update View Component metric building (#2907) * Use default `View/component` metric name for unidentified View Components --- CHANGELOG.md | 6 +++++- .../view_component/instrumentation.rb | 15 +++++++-------- .../view_component_instrumentation_test.rb | 6 ++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e26f1faa46..f897f40b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ ## dev -Version resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. +Version updates View Componment instrumentation to use a default metric name when one is unavaliable and resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. + +- **Feature: Use default `View/component` metric name for unidentified View Components** + + Previously, when a View Component metric name could not be identified, the agent would set the name as `nil`. Now, the agent defaults to using `View/component` as the metric name when one can not be identified. [PR#2907](https://github.com/newrelic/newrelic-ruby-agent/pull/2907) - **Bugfix: Instrumentation errors when using the karafka-rdkafka gem** diff --git a/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb b/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb index 3005214c36..b565f81e10 100644 --- a/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb +++ b/lib/new_relic/agent/instrumentation/view_component/instrumentation.rb @@ -10,12 +10,7 @@ def render_in_with_tracing(*args) NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME) begin - segment = NewRelic::Agent::Tracer.start_segment( - name: metric_name( - self.class.respond_to?(:identifier) ? self.class.identifier : nil, - self.class.name - ) - ) + segment = NewRelic::Agent::Tracer.start_segment(name: metric_name) yield rescue => e NewRelic::Agent.notice_error(e) @@ -25,8 +20,12 @@ def render_in_with_tracing(*args) end end - def metric_name(identifier, component) - "View/#{metric_path(identifier)}/#{component}" + def metric_name + "View/#{metric_path(self.class.source_location)}/#{self.class.name}" + rescue => e + NewRelic::Agent.logger.error('Error identifying View Component metric name', e) + + 'View/component' end def metric_path(identifier) diff --git a/test/multiverse/suites/view_component/view_component_instrumentation_test.rb b/test/multiverse/suites/view_component/view_component_instrumentation_test.rb index 01e36d291c..f446a1d469 100644 --- a/test/multiverse/suites/view_component/view_component_instrumentation_test.rb +++ b/test/multiverse/suites/view_component/view_component_instrumentation_test.rb @@ -58,14 +58,12 @@ def test_error_raised end end - # Test metric name being built when the controller class doesn't respond to :identifier - # https://github.com/newrelic/newrelic-ruby-agent/pull/2870 - def test_the_metric_name_omits_the_identifier_when_absent + def test_the_metric_name_records_default_name_on_error in_transaction do |txn| FAKE_CLASS.render_in_with_tracing { 11 * 38 } actual_name = txn.segments.last.name - assert_equal 'View/component/DummyViewComponentInstrumentationClass', actual_name + assert_equal 'View/component', actual_name end end end From ae4b9b33ee1950db65e83f24f35e7c8c44c97adc Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Fri, 11 Oct 2024 14:10:46 -0500 Subject: [PATCH 32/59] add exit code to output --- test/multiverse/lib/multiverse/suite.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/multiverse/lib/multiverse/suite.rb b/test/multiverse/lib/multiverse/suite.rb index 5a3efd9005..05489b019f 100755 --- a/test/multiverse/lib/multiverse/suite.rb +++ b/test/multiverse/lib/multiverse/suite.rb @@ -553,7 +553,7 @@ def child_command_line(env, instrumentation_method) def check_for_failure(env) if $? != 0 - OutputCollector.write(suite, env, red("#{suite.inspect} for Envfile entry #{env} failed!")) + OutputCollector.write(suite, env, red("#{suite.inspect} for Envfile entry #{env} failed! (exit: #{$?})")) OutputCollector.failed(suite, env) end Multiverse::Runner.notice_exit_status($?) From d97b9f2229292f7218dca9f6b1b409807d09a9b3 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Fri, 11 Oct 2024 14:14:00 -0500 Subject: [PATCH 33/59] move rdkafka to its own group for multiverse --- .github/workflows/ci.yml | 2 +- .github/workflows/ci_cron.yml | 2 +- test/multiverse/lib/multiverse/runner.rb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 156c7fc6a4..c652217e59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,7 +216,7 @@ jobs: strategy: fail-fast: false matrix: - multiverse: [agent, ai, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest] + multiverse: [agent, ai, background, background_2, kafka, database, frameworks, httpclients, httpclients_2, rails, rest] ruby-version: [2.4.10, 3.3.5] steps: diff --git a/.github/workflows/ci_cron.yml b/.github/workflows/ci_cron.yml index 2efa9625f8..4a81061d2f 100644 --- a/.github/workflows/ci_cron.yml +++ b/.github/workflows/ci_cron.yml @@ -229,7 +229,7 @@ jobs: strategy: fail-fast: false matrix: - multiverse: [agent, ai, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest] + multiverse: [agent, ai, background, background_2, database, kafka, frameworks, httpclients, httpclients_2, rails, rest] ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview2] steps: - name: Configure git diff --git a/test/multiverse/lib/multiverse/runner.rb b/test/multiverse/lib/multiverse/runner.rb index 1224a1c1bd..a7470ed51e 100644 --- a/test/multiverse/lib/multiverse/runner.rb +++ b/test/multiverse/lib/multiverse/runner.rb @@ -102,6 +102,7 @@ def execute_suites(filter, opts) 'ai' => %w[ruby_openai], 'background' => %w[delayed_job sidekiq resque], 'background_2' => %w[rake], + 'kafka' => %w[rdkafka], 'database' => %w[elasticsearch mongo redis sequel], 'rails' => %w[active_record active_record_pg active_support_broadcast_logger active_support_logger rails rails_prepend activemerchant], 'frameworks' => %w[grape padrino roda sinatra], From ba318379432aa24eeb41e390109018d7da0d107a Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Mon, 14 Oct 2024 10:17:10 -0500 Subject: [PATCH 34/59] add config to allow test to pass for jruby --- .../agent/configuration/manager_test.rb | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/new_relic/agent/configuration/manager_test.rb b/test/new_relic/agent/configuration/manager_test.rb index cc2bc78349..7d81efedba 100644 --- a/test/new_relic/agent/configuration/manager_test.rb +++ b/test/new_relic/agent/configuration/manager_test.rb @@ -492,20 +492,22 @@ def test_apply_transformations_reraises_errors end def test_auto_determined_values_stay_cached - name = :knockbreck_manse + with_config(:'security.agent.enabled' => true) do + name = :knockbreck_manse - DependencyDetection.defer do - named(name) - executes { use_prepend? } - end + DependencyDetection.defer do + named(name) + executes { use_prepend? } + end - key = :"instrumentation.#{name}" - with_config(key => 'auto') do - DependencyDetection.detect! + key = :"instrumentation.#{name}" + with_config(key => 'auto') do + DependencyDetection.detect! - @manager.replace_or_add_config(ServerSource.new({})) + @manager.replace_or_add_config(ServerSource.new({})) - assert_equal :prepend, @manager.instance_variable_get(:@cache)[key] + assert_equal :prepend, @manager.instance_variable_get(:@cache)[key] + end end end From 9cdcd2c33c312acbcf72161ca9dbafe728b495a9 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 14 Oct 2024 12:07:17 -0700 Subject: [PATCH 35/59] Create helper method to return rubygems specs Bundler version 2.5.12 deprecated all_specs and added installed_specs. To support newer Bundler versions, try to use installed_specs first, then fall back to all_specs. All callers expect this to be an array, so return an array if Bundler isn't defined. This consolidates the way the rubygems specs are accessed across the multiple places we use them. --- lib/new_relic/agent/instrumentation/grape.rb | 8 +------ lib/new_relic/control/frameworks/rails4.rb | 6 +----- lib/new_relic/environment_report.rb | 6 +----- lib/new_relic/helper.rb | 15 +++++++++++++ lib/new_relic/language_support.rb | 6 +----- test/new_relic/helper_test.rb | 22 ++++++++++++++++++++ 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/lib/new_relic/agent/instrumentation/grape.rb b/lib/new_relic/agent/instrumentation/grape.rb index c4b24d7379..75bae0a0df 100644 --- a/lib/new_relic/agent/instrumentation/grape.rb +++ b/lib/new_relic/agent/instrumentation/grape.rb @@ -19,13 +19,7 @@ depends_on do begin - specs = if Bundler.rubygems.respond_to?(:installed_specs) - Bundler.rubygems.installed_specs - else - Bundler.rubygems.all_specs - end - - if specs.map(&:name).include?('newrelic-grape') + if NewRelic::Helper.rubygems_specs.map(&:name).include?('newrelic-grape') NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present') false else diff --git a/lib/new_relic/control/frameworks/rails4.rb b/lib/new_relic/control/frameworks/rails4.rb index 23d403dd69..b8545f92df 100644 --- a/lib/new_relic/control/frameworks/rails4.rb +++ b/lib/new_relic/control/frameworks/rails4.rb @@ -9,11 +9,7 @@ class Control module Frameworks class Rails4 < NewRelic::Control::Frameworks::Rails3 def rails_gem_list - if Bundler.rubygems.respond_to?(:installed_specs) - Bundler.rubygems.installed_specs.map { |gem| "#{gem.name} (#{gem.version})" } - else - Bundler.rubygems.all_specs.map { |gem| "#{gem.name} (#{gem.version})" } - end + NewRelic::Helper.rubygems_specs.map { |gem| "#{gem.name} (#{gem.version})" } end def append_plugin_list diff --git a/lib/new_relic/environment_report.rb b/lib/new_relic/environment_report.rb index 1661bebeb6..301fe83c0f 100644 --- a/lib/new_relic/environment_report.rb +++ b/lib/new_relic/environment_report.rb @@ -44,11 +44,7 @@ def self.registered_reporters=(logic) #################################### report_on('Gems') do begin - if Bundler.rubygems.respond_to?(:installed_specs) - Bundler.rubygems.installed_specs.map { |gem| "#{gem.name}(#{gem.version})" } - else - Bundler.rubygems.all_specs.map { |gem| "#{gem.name}(#{gem.version})" } - end + NewRelic::Helper.rubygems_specs.map { |gem| "#{gem.name}(#{gem.version})" } rescue # There are certain rubygem, bundler, rails combinations (e.g. gem # 1.6.2, rails 2.3, bundler 1.2.3) where the code above throws an error diff --git a/lib/new_relic/helper.rb b/lib/new_relic/helper.rb index 7d17c89908..3f89b9e36b 100644 --- a/lib/new_relic/helper.rb +++ b/lib/new_relic/helper.rb @@ -82,5 +82,20 @@ def executable_in_path?(executable) File.exist?(executable_path) && File.file?(executable_path) && File.executable?(executable_path) end end + + # Bundler version 2.5.12 deprecated all_specs and added installed_specs. + # To support newer Bundler versions, try to use installed_specs first, + # then fall back to all_specs. + # All callers expect this to be an array, so return an array if Bundler isn't defined + # @api private + def rubygems_specs + return [] unless defined?(Bundler) + + if Bundler.rubygems.respond_to?(:installed_specs) + Bundler.rubygems.installed_specs + else + Bundler.rubygems.all_specs + end + end end end diff --git a/lib/new_relic/language_support.rb b/lib/new_relic/language_support.rb index 140d2455d2..31377e831a 100644 --- a/lib/new_relic/language_support.rb +++ b/lib/new_relic/language_support.rb @@ -90,11 +90,7 @@ def snakeize(string) def bundled_gem?(gem_name) return false unless defined?(Bundler) - if Bundler.rubygems.respond_to?(:installed_specs) - Bundler.rubygems.installed_specs.map(&:name).include?(gem_name) - else - Bundler.rubygems.all_specs.map(&:name).include?(gem_name) - end + NewRelic::Helper.rubygems_specs.map(&:name).include?(gem_name) rescue => e ::NewRelic::Agent.logger.info("Could not determine if third party #{gem_name} gem is installed", e) false diff --git a/test/new_relic/helper_test.rb b/test/new_relic/helper_test.rb index e47a838a40..44a66f4480 100644 --- a/test/new_relic/helper_test.rb +++ b/test/new_relic/helper_test.rb @@ -77,4 +77,26 @@ def test_run_command_sad_exception NewRelic::Helper.run_command('executable that existed at detection time but is not there now') end end + + ## rubygems_specs + def test_rubygems_specs_returns_empty_array_without_bundler + stub(:defined?, nil, ['Bundler']) do + result = NewRelic::Helper.rubygems_specs + + assert_instance_of Array, result + assert_empty Array, result + end + end + + def test_rubygems_specs_works_with_all_specs_when_installed_specs_is_absent + Bundler.rubygems.stub(:respond_to?, nil, [':installed_specs']) do + assert_equal Bundler.rubygems.all_specs, NewRelic::Helper.rubygems_specs + end + end + + def test_rubygems_specs_works_with_installed_specs + skip 'running a version of Bundler that has not defined installed_specs' unless Bundler.rubygems.respond_to?(:installed_specs) + + assert_equal Bundler.rubygems.installed_specs, NewRelic::Helper.rubygems_specs + end end From 6f30dcd5ad8be9670350e7f6580d16b6daecffb0 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 14 Oct 2024 12:13:02 -0700 Subject: [PATCH 36/59] Add changelog entry for all_specs update --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e26f1faa46..3c489d1b98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,16 @@ ## dev -Version resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem. +Version resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem and fixes a bug with Grape instrumentation. - **Bugfix: Instrumentation errors when using the karafka-rdkafka gem** Due to version differences between the rdkafka gem and karafka-rdkafka gem, the agent could encounter an error when it tried to install rdkafka instrumentation. This has now been resolved. Thank you to @krisdigital for bringing this issue to our attention. [PR#2880](https://github.com/newrelic/newrelic-ruby-agent/pull/2880) +- **Bugfix: Stop calling deprecated all_specs method to check for the presence of newrelic-grape** + + In 9.14.0, we released a fix for calls to the deprecated `Bundler.rubygems.all_specs`, but the fix fell short for the agent's Grape instrumentation and deprecation warnings could still be raised. The condition has been simplified and deprecation warnings should no longer be raised. Thank you, [@excelsior](https://github.com/excelsior) for bringing this to our attention. [Issue#](https://github.com/newrelic/newrelic-ruby-agent/issues/2885) [PR#2906](https://github.com/newrelic/newrelic-ruby-agent/pull/2906) + ## v9.14.0 From 2b78cfcee2af4bd4e52765dd34895557b21bb547 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 14 Oct 2024 16:51:15 -0700 Subject: [PATCH 37/59] Update stub for Rubies below 2.7 --- test/new_relic/helper_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/new_relic/helper_test.rb b/test/new_relic/helper_test.rb index 44a66f4480..2482a4cbf5 100644 --- a/test/new_relic/helper_test.rb +++ b/test/new_relic/helper_test.rb @@ -78,7 +78,9 @@ def test_run_command_sad_exception end end - ## rubygems_specs + # + # rubygems_specs + # def test_rubygems_specs_returns_empty_array_without_bundler stub(:defined?, nil, ['Bundler']) do result = NewRelic::Helper.rubygems_specs @@ -89,7 +91,7 @@ def test_rubygems_specs_returns_empty_array_without_bundler end def test_rubygems_specs_works_with_all_specs_when_installed_specs_is_absent - Bundler.rubygems.stub(:respond_to?, nil, [':installed_specs']) do + Bundler.rubygems.stub(:respond_to?, nil) do assert_equal Bundler.rubygems.all_specs, NewRelic::Helper.rubygems_specs end end From c731c929d85cd5be3b1c81e69b13b33888fcdfc5 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 14 Oct 2024 16:54:18 -0700 Subject: [PATCH 38/59] Rubocop --- test/new_relic/helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/new_relic/helper_test.rb b/test/new_relic/helper_test.rb index 2482a4cbf5..2ec6dcef94 100644 --- a/test/new_relic/helper_test.rb +++ b/test/new_relic/helper_test.rb @@ -80,7 +80,7 @@ def test_run_command_sad_exception # # rubygems_specs - # + # def test_rubygems_specs_returns_empty_array_without_bundler stub(:defined?, nil, ['Bundler']) do result = NewRelic::Helper.rubygems_specs From a1d712abc3adc8e76bf155710a01ee40f82615ed Mon Sep 17 00:00:00 2001 From: fallwith Date: Tue, 15 Oct 2024 00:28:24 -0700 Subject: [PATCH 39/59] prevent false 'unsatisfied' dependency status address 2 issues causing dependency detection to falsely label an instrumentation's dependencies as "unsatisfied". - handle Padrino with a special case pending resolution of https://github.com/newrelic/newrelic-ruby-agent/issues/2912 - don't mark an item as unsatisfied the second (or higher) time it comes around through the `detect!` loop --- lib/new_relic/dependency_detection.rb | 15 ++++++++++----- .../suites/sinatra/sinatra_test_cases.rb | 7 +++++++ test/new_relic/dependency_detection_test.rb | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/lib/new_relic/dependency_detection.rb b/lib/new_relic/dependency_detection.rb index 5cd93f705c..d9c7dff358 100644 --- a/lib/new_relic/dependency_detection.rb +++ b/lib/new_relic/dependency_detection.rb @@ -25,11 +25,9 @@ def defer(&block) def detect! @items.each do |item| - if item.dependencies_satisfied? - item.execute - else - item.configure_as_unsatisfied unless item.disabled_configured? - end + next if item.executed || item.disabled_configured? + + item.dependencies_satisfied? ? item.execute : item.configure_as_unsatisfied end end @@ -65,6 +63,13 @@ def dependencies_satisfied? end def configure_as_unsatisfied + # TODO: currently using :unsatisfied for Padrino will clobber the value + # already set for Sinatra, so skip Padrino and circle back with a + # new Padrino specific solution in the future. + # + # https://github.com/newrelic/newrelic-ruby-agent/issues/2912 + return if name == :padrino + NewRelic::Agent.config.instance_variable_get(:@cache)[config_key] = :unsatisfied end diff --git a/test/multiverse/suites/sinatra/sinatra_test_cases.rb b/test/multiverse/suites/sinatra/sinatra_test_cases.rb index c7a04e98fe..316f2ce729 100644 --- a/test/multiverse/suites/sinatra/sinatra_test_cases.rb +++ b/test/multiverse/suites/sinatra/sinatra_test_cases.rb @@ -128,6 +128,13 @@ def test_with_regex_pattern assert_metrics_recorded(["Controller/Sinatra/#{app_name}/#{regex_segment}"]) end + def test_that_the_actively_configured_instrumentation_is_not_marked_as_unsatsfied + get('/pass') + + assert_equal 200, last_response.status + assert_includes(%w[chain prepend], NewRelic::Agent.config[:'instrumentation.sinatra']) + end + # https://support.newrelic.com/tickets/31061 def test_precondition_not_over_called get('/precondition') diff --git a/test/new_relic/dependency_detection_test.rb b/test/new_relic/dependency_detection_test.rb index b4223340a5..d60a0cbadc 100644 --- a/test/new_relic/dependency_detection_test.rb +++ b/test/new_relic/dependency_detection_test.rb @@ -488,4 +488,21 @@ def test_prepend_is_replaced_by_unsatisfied_when_appropriate assert_equal :unsatisfied, dd.config_value end end + + def test_already_executed_items_are_not_executed_again + unexecuted = Minitest::Mock.new + unexecuted.expect :executed, false + unexecuted.expect :dependencies_satisfied?, true + unexecuted.expect :disabled_configured?, false + unexecuted.expect :execute, -> { execution_took_place = true } + executed = Minitest::Mock.new + executed.expect :executed, true + unexecuted.expect :disabled_configured?, false + + DependencyDetection.instance_variable_set(:@items, [unexecuted, executed]) + DependencyDetection.detect! + + unexecuted.verify + executed.verify + end end From 117c75a090c1de9428b619f6fdf02e4e7f0bc1ce Mon Sep 17 00:00:00 2001 From: fallwith Date: Tue, 15 Oct 2024 00:54:37 -0700 Subject: [PATCH 40/59] sinatra dd check - use a string use a string for comparison --- test/multiverse/suites/sinatra/sinatra_test_cases.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/multiverse/suites/sinatra/sinatra_test_cases.rb b/test/multiverse/suites/sinatra/sinatra_test_cases.rb index 316f2ce729..e3b629d801 100644 --- a/test/multiverse/suites/sinatra/sinatra_test_cases.rb +++ b/test/multiverse/suites/sinatra/sinatra_test_cases.rb @@ -132,7 +132,7 @@ def test_that_the_actively_configured_instrumentation_is_not_marked_as_unsatsfie get('/pass') assert_equal 200, last_response.status - assert_includes(%w[chain prepend], NewRelic::Agent.config[:'instrumentation.sinatra']) + assert_includes(%w[chain prepend], NewRelic::Agent.config[:'instrumentation.sinatra'].to_s) end # https://support.newrelic.com/tickets/31061 From d17d815af1044765be4d61bcf59bf06f70854daa Mon Sep 17 00:00:00 2001 From: Patrick Arnett Date: Thu, 17 Oct 2024 01:24:20 -0400 Subject: [PATCH 41/59] Use double splat for Ruby >= 3.0 --- .../instrumentation/ruby_kafka/prepend.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb b/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb index 66cec78a33..063fb6e511 100644 --- a/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb +++ b/lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb @@ -20,10 +20,20 @@ module RubyKafkaConsumer module Prepend include NewRelic::Agent::Instrumentation::RubyKafka - def each_message(*args) - super do |message| - each_message_with_new_relic(message) do - yield(message) + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3') + def each_message(**args) + super do |message| + each_message_with_new_relic(message) do + yield(message) + end + end + end + else + def each_message(*args) + super do |message| + each_message_with_new_relic(message) do + yield(message) + end end end end From 6a247b6aeb4c5613d3dd987fb23607d53c5bd89c Mon Sep 17 00:00:00 2001 From: Patrick Arnett Date: Thu, 17 Oct 2024 01:30:55 -0400 Subject: [PATCH 42/59] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 760d5676e5..3d4ad07655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ Version updates View Componment instrumentation to use a default metric na In 9.14.0, we released a fix for calls to the deprecated `Bundler.rubygems.all_specs`, but the fix fell short for the agent's Grape instrumentation and deprecation warnings could still be raised. The condition has been simplified and deprecation warnings should no longer be raised. Thank you, [@excelsior](https://github.com/excelsior) for bringing this to our attention. [Issue#](https://github.com/newrelic/newrelic-ruby-agent/issues/2885) [PR#2906](https://github.com/newrelic/newrelic-ruby-agent/pull/2906) +- **Bufix: Instrumentation errors when using the ruby-kafka gem** + + Kafka::Consumer#each_message takes keyword arguments, while the prepended method is defined with a single splat positional argument. In Ruby >= 3.0, this signature mismatch raises an ArgumentError. [PR#2915](https://github.com/newrelic/newrelic-ruby-agent/pull/2915) + ## v9.14.0 Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka gems, introduces a configuration-based, automatic way to add custom instrumentation method tracers, correctly captures MIME type for ActionDispatch 7.0+ requests, properly handles Boolean coercion for `newrelic.yml` configuration, fixes a JRuby bug in the configuration manager, fixes a bug related to `Bundler.rubygems.installed_specs`, and fixes a bug to make the agent compatible with ViewComponent v3.15.0+. From 12a9be54c694dfd7ec75197a1df1d04a31c138b3 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Mon, 21 Oct 2024 10:37:04 -0500 Subject: [PATCH 43/59] update changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d4ad07655..f450d5822e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## dev -Version updates View Componment instrumentation to use a default metric name when one is unavaliable, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem and fixes a bug with Grape instrumentation. +Version updates View Componment instrumentation to use a default metric name when one is unavailable, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem, resolves a bug in the ruby-kafka instrumentation, and fixes a bug with Grape instrumentation. - **Feature: Use default `View/component` metric name for unidentified View Components** @@ -16,9 +16,10 @@ Version updates View Componment instrumentation to use a default metric na In 9.14.0, we released a fix for calls to the deprecated `Bundler.rubygems.all_specs`, but the fix fell short for the agent's Grape instrumentation and deprecation warnings could still be raised. The condition has been simplified and deprecation warnings should no longer be raised. Thank you, [@excelsior](https://github.com/excelsior) for bringing this to our attention. [Issue#](https://github.com/newrelic/newrelic-ruby-agent/issues/2885) [PR#2906](https://github.com/newrelic/newrelic-ruby-agent/pull/2906) -- **Bufix: Instrumentation errors when using the ruby-kafka gem** +- **Bugfix: Instrumentation errors when using the ruby-kafka gem** + + Kafka::Consumer#each_message takes keyword arguments, while the prepended method is defined with a single splat positional argument. In Ruby >= 3.0, this signature mismatch raises an ArgumentError. Thank you [@patrickarnett](https://github.com/patrickarnett) for providing this bugfix. [PR#2915](https://github.com/newrelic/newrelic-ruby-agent/pull/2915) - Kafka::Consumer#each_message takes keyword arguments, while the prepended method is defined with a single splat positional argument. In Ruby >= 3.0, this signature mismatch raises an ArgumentError. [PR#2915](https://github.com/newrelic/newrelic-ruby-agent/pull/2915) ## v9.14.0 From c8f18d44783b6486050bb87c2da2d56831d0e73e Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Mon, 21 Oct 2024 13:18:16 -0500 Subject: [PATCH 44/59] Update CHANGELOG.md Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 615ecdf53d..deb63af0bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Version updates View Componment instrumentation to use a default metric na - **Feature: New configuration option cloud.aws.account_id** - A new configuration option has been added, `cloud.aws.account_id`, that will allow New Relic to provide more details about certain calls made using the AWS SDK. Currently, the DynamoDB instrumentation is the only instrumentation that will make use of this configuration option, but this will be used in future instrumentation as well. [PR#2904](https://github.com/newrelic/newrelic-ruby-agent/pull/2904) + A new configuration option has been added, `cloud.aws.account_id`, that will allow New Relic to provide more details about certain calls made using the AWS SDK. One example, is that relationships between AWS services instrumented with New Relic's CloudWatch Metric Streams will have relationships formed in the service map with APM applications. Currently, the DynamoDB instrumentation is the only instrumentation that will make use of this configuration option, but this will be used in future instrumentation as well. [PR#2904](https://github.com/newrelic/newrelic-ruby-agent/pull/2904) - **Feature: Use default `View/component` metric name for unidentified View Components** From 5f8f2b007871f89c53cac9f2d0d45d609e2ddef3 Mon Sep 17 00:00:00 2001 From: fallwith Date: Mon, 21 Oct 2024 15:05:58 -0700 Subject: [PATCH 45/59] DD templating: conditionally invoke requires as per #2844, don't perform `require_relative` on content that won't be used unless all dependency detection checks succeed --- .../templates/dependency_detection.tt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt index e5c82ebb6f..b1af9b4535 100644 --- a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +++ b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt @@ -2,10 +2,6 @@ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. # frozen_string_literal: true -require_relative '<%= @snake_name.downcase %>/instrumentation' -require_relative '<%= @snake_name.downcase %>/chain' -require_relative '<%= @snake_name.downcase %>/prepend' - DependencyDetection.defer do named :<%= @name.match?(/\-|\_/) ? "'#{@snake_name}'" : @name.downcase %> @@ -18,6 +14,10 @@ DependencyDetection.defer do end executes do + require_relative '<%= @snake_name.downcase %>/instrumentation' + require_relative '<%= @snake_name.downcase %>/chain' + require_relative '<%= @snake_name.downcase %>/prepend' + # prepend_instrument and chain_instrument call extract_supportability_name # to get the library name for supportability metrics and info-level logging. # This is done by spliting on the 2nd to last spot of the instrumented From 1c6d8a35f40240168f043379b4d9f9947fa89877 Mon Sep 17 00:00:00 2001 From: fallwith Date: Mon, 21 Oct 2024 16:21:29 -0700 Subject: [PATCH 46/59] DD: require only prepend OR chain DD code when chaining or prepending, only bring in the appropriate chain or prepend code --- .../templates/dependency_detection.tt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt index b1af9b4535..7c82ca7f35 100644 --- a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +++ b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt @@ -15,17 +15,17 @@ DependencyDetection.defer do executes do require_relative '<%= @snake_name.downcase %>/instrumentation' - require_relative '<%= @snake_name.downcase %>/chain' - require_relative '<%= @snake_name.downcase %>/prepend' # prepend_instrument and chain_instrument call extract_supportability_name - # to get the library name for supportability metrics and info-level logging. + # to get the library name for supportability metrics and info-level logging. # This is done by spliting on the 2nd to last spot of the instrumented # module. If this isn't how we want the name to appear, pass in the desired # name as a third argument. if use_prepend? + require_relative '<%= @snake_name.downcase %>/prepend' prepend_instrument <%= @class_name %>, NewRelic::Agent::Instrumentation::<%= @class_name %>::Prepend else + require_relative '<%= @snake_name.downcase %>/chain' chain_instrument NewRelic::Agent::Instrumentation::<%= @class_name %>::Chain end end From 2507052f091da56e21ecea71ec6d918d4b942584 Mon Sep 17 00:00:00 2001 From: fallwith Date: Mon, 21 Oct 2024 17:01:06 -0700 Subject: [PATCH 47/59] DD: update the rendering of the 'named' line the template's rendering of a `named` line was previously attempting to wrap symbol values with single quotes when necessary. but given that everything is routed through the `snake_name` method, nothing will ever need the quotes if we simply use the output of that method, held in `@snake_name`. --- .../instrumentation_generator/templates/dependency_detection.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt index 7c82ca7f35..be9ad8a8df 100644 --- a/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +++ b/lib/tasks/instrumentation_generator/templates/dependency_detection.tt @@ -3,7 +3,7 @@ # frozen_string_literal: true DependencyDetection.defer do - named :<%= @name.match?(/\-|\_/) ? "'#{@snake_name}'" : @name.downcase %> + named :<%= @snake_name %> depends_on do # The class that needs to be defined to prepend/chain onto. This can be used From 300ac4ce14c51ed35ddb4e1942a170186f79f898 Mon Sep 17 00:00:00 2001 From: fallwith Date: Thu, 24 Oct 2024 16:58:46 -0700 Subject: [PATCH 48/59] bugfix: always apply transformations on booleans v9.14.0 introduced improved handling of boolean based configuration parameters and inadvertently broke AWS Lambda layer based functionality due to a bypassing of config transformations for booleans. Boolean based values will now again be routed through their transformations if defined. resolves #2919 --- CHANGELOG.md | 7 +++++-- lib/new_relic/agent/configuration/manager.rb | 2 +- .../agent/configuration/manager_test.rb | 17 +++++++++++++++++ test/new_relic/agent/serverless_handler_test.rb | 12 ++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index deb63af0bf..53a40d58a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## dev -Version updates View Componment instrumentation to use a default metric name when one is unavailable, adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS SDK, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem, resolves a bug in the ruby-kafka instrumentation, and fixes a bug with Grape instrumentation. +Version updates View Componment instrumentation to use a default metric name when one is unavailable, adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS SDK, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem, resolves a bug in the ruby-kafka instrumentation, fixes a bug with Grape instrumentation, and addresses a bug preventing Ruby based AWS Lambda layer contexts from working properly. - **Feature: New configuration option cloud.aws.account_id** @@ -19,12 +19,15 @@ Version updates View Componment instrumentation to use a default metric na - **Bugfix: Stop calling deprecated all_specs method to check for the presence of newrelic-grape** - In 9.14.0, we released a fix for calls to the deprecated `Bundler.rubygems.all_specs`, but the fix fell short for the agent's Grape instrumentation and deprecation warnings could still be raised. The condition has been simplified and deprecation warnings should no longer be raised. Thank you, [@excelsior](https://github.com/excelsior) for bringing this to our attention. [Issue#](https://github.com/newrelic/newrelic-ruby-agent/issues/2885) [PR#2906](https://github.com/newrelic/newrelic-ruby-agent/pull/2906) + In 9.14.0, we released a fix for calls to the deprecated `Bundler.rubygems.all_specs`, but the fix fell short for the agent's Grape instrumentation and deprecation warnings could still be raised. The condition has been simplified and deprecation warnings should no longer be raised. Thank you, [@excelsior](https://github.com/excelsior) for bringing this to our attention. [Issue#2885](https://github.com/newrelic/newrelic-ruby-agent/issues/2885) [PR#2906](https://github.com/newrelic/newrelic-ruby-agent/pull/2906) - **Bugfix: Instrumentation errors when using the ruby-kafka gem** Kafka::Consumer#each_message takes keyword arguments, while the prepended method is defined with a single splat positional argument. In Ruby >= 3.0, this signature mismatch raises an ArgumentError. Thank you [@patrickarnett](https://github.com/patrickarnett) for providing this bugfix. [PR#2915](https://github.com/newrelic/newrelic-ruby-agent/pull/2915) +- **Bugfix: Restore AWS Lambda layer based operational functionality** + + Version 9.14.0 of the agent introduced an optimization related to how the agent handles boolean based configuration parameters which inadvertently caused the agent to stop operating properly in an AWS Lambda layer context. [Issue#2919](https://github.com/newrelic/newrelic-ruby-agent/issues/2919) ## v9.14.0 diff --git a/lib/new_relic/agent/configuration/manager.rb b/lib/new_relic/agent/configuration/manager.rb index f1c5b6bb24..c4f849ff28 100644 --- a/lib/new_relic/agent/configuration/manager.rb +++ b/lib/new_relic/agent/configuration/manager.rb @@ -143,7 +143,7 @@ def evaluate_and_apply_transformations(key, value) return default if default boolean = enforce_boolean(key, value) - return boolean if [true, false].include?(boolean) + evaluated = boolean if [true, false].include?(boolean) apply_transformations(key, evaluated) end diff --git a/test/new_relic/agent/configuration/manager_test.rb b/test/new_relic/agent/configuration/manager_test.rb index 7d81efedba..f5adc12654 100644 --- a/test/new_relic/agent/configuration/manager_test.rb +++ b/test/new_relic/agent/configuration/manager_test.rb @@ -552,6 +552,23 @@ def phony_cache.dup; self[:dup_called] = true; self; end @manager.new_cache end + # https://github.com/newrelic/newrelic-ruby-agent/issues/2919 + def test_that_boolean_based_params_always_go_through_any_defined_transform_sequence + key = :soundwave + defaults = {key => {default: false, + public: true, + type: Boolean, + allowed_from_server: false, + transform: proc { |bool| bool.to_s.reverse }, + description: 'Param what transforms'}} + NewRelic::Agent::Configuration.stub_const(:DEFAULTS, defaults) do + mgr = NewRelic::Agent::Configuration::Manager.new + value = mgr[key] + + assert_equal 'eslaf', value, 'Expected `false` boolean value to be transformed!' + end + end + private def assert_parsed_labels(expected) diff --git a/test/new_relic/agent/serverless_handler_test.rb b/test/new_relic/agent/serverless_handler_test.rb index 75d363d152..5255e6d9d6 100644 --- a/test/new_relic/agent/serverless_handler_test.rb +++ b/test/new_relic/agent/serverless_handler_test.rb @@ -467,6 +467,18 @@ def test_http_uri_handles_errors logger_mock.verify end + # https://github.com/newrelic/newrelic-ruby-agent/issues/2919 + def test_env_var_will_properly_enable_serverless_mode + NewRelic::Agent.config.remove_config(@test_config) + + ENV.stub(:key?, NewRelic::Agent::ServerlessHandler::LAMBDA_ENVIRONMENT_VARIABLE, true) do + NewRelic::Agent.config.send(:reset_cache) + + assert NewRelic::Agent.config[:'serverless_mode.enabled'], + 'Expected the presence of an env var to enable serverless mode!' + end + end + private def handler From 12b5b018314a44e3b8cb5f401340b1f1f58d31ae Mon Sep 17 00:00:00 2001 From: James Bunch Date: Thu, 24 Oct 2024 17:16:45 -0700 Subject: [PATCH 49/59] Update CHANGELOG.md Update dev bugfix title for Lambda layer functionality restoration Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a40d58a0..1ae8fd0d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ Version updates View Componment instrumentation to use a default metric na Kafka::Consumer#each_message takes keyword arguments, while the prepended method is defined with a single splat positional argument. In Ruby >= 3.0, this signature mismatch raises an ArgumentError. Thank you [@patrickarnett](https://github.com/patrickarnett) for providing this bugfix. [PR#2915](https://github.com/newrelic/newrelic-ruby-agent/pull/2915) -- **Bugfix: Restore AWS Lambda layer based operational functionality** +- **Bugfix: Restore AWS Lambda layer operational functionality** Version 9.14.0 of the agent introduced an optimization related to how the agent handles boolean based configuration parameters which inadvertently caused the agent to stop operating properly in an AWS Lambda layer context. [Issue#2919](https://github.com/newrelic/newrelic-ruby-agent/issues/2919) From c472031439e6a652b594cdb3407ffcfc34998991 Mon Sep 17 00:00:00 2001 From: James Bunch Date: Thu, 24 Oct 2024 17:17:06 -0700 Subject: [PATCH 50/59] Update CHANGELOG.md Reference the Lambda bugfix PR now that it exists Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ae8fd0d7d..71a4c36a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ Version updates View Componment instrumentation to use a default metric na - **Bugfix: Restore AWS Lambda layer operational functionality** - Version 9.14.0 of the agent introduced an optimization related to how the agent handles boolean based configuration parameters which inadvertently caused the agent to stop operating properly in an AWS Lambda layer context. [Issue#2919](https://github.com/newrelic/newrelic-ruby-agent/issues/2919) + Version 9.14.0 of the agent introduced an optimization related to how the agent handles boolean configuration parameters which inadvertently caused the agent to stop operating properly in an AWS Lambda layer context. [Issue#2919](https://github.com/newrelic/newrelic-ruby-agent/issues/2919)[PR#2920](https://github.com/newrelic/newrelic-ruby-agent/pull/2920) ## v9.14.0 From 8a8bd454cfb135f5cd8546d215aee58ce1f3482a Mon Sep 17 00:00:00 2001 From: fallwith Date: Thu, 24 Oct 2024 17:28:37 -0700 Subject: [PATCH 51/59] CHANGELOG: improve Lambda bugfix summary Improve the wording for the Lambda bugfix summary Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71a4c36a45..02b20266bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,7 @@ ## dev -Version updates View Componment instrumentation to use a default metric name when one is unavailable, adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS SDK, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem, resolves a bug in the ruby-kafka instrumentation, fixes a bug with Grape instrumentation, and addresses a bug preventing Ruby based AWS Lambda layer contexts from working properly. - +Version updates View Componment instrumentation to use a default metric name when one is unavailable, adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS SDK, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem, resolves a bug in the ruby-kafka instrumentation, fixes a bug with Grape instrumentation, and addresses a bug preventing the agent from running in serverless mode in an AWS Lambda layer. - **Feature: New configuration option cloud.aws.account_id** From 9f26380adf8290fed16644b29eeb56f63299a858 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Mon, 28 Oct 2024 14:59:21 -0500 Subject: [PATCH 52/59] add .vscode to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 695e0997f6..4927f66ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ lib/new_relic/build.rb .tm_properties .bundle .yardoc +.vscode/ artifacts/ test/performance/log/ test/performance/script/log/ From 2e4bd33a91d642886d474f443d8560b39d3b1c92 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Mon, 28 Oct 2024 16:03:03 -0700 Subject: [PATCH 53/59] Add security scan --- .github/versions.yml | 6 ++++ .github/workflows/security.yml | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/security.yml diff --git a/.github/versions.yml b/.github/versions.yml index ec146e2ee9..fa8f0ce7cb 100644 --- a/.github/versions.yml +++ b/.github/versions.yml @@ -36,3 +36,9 @@ adriangl/check-new-commits-action: softprops/action-gh-release: :tag: v2.0.8 :sha: c062e08bd532815e2082a85e87e3ef29c3e6d191 +aquasecurity/trivy-action: + :tag: v0.28.0 + :sha: 915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 +github/codeql-action/upload-sarif: + :tag: v3.27.0 + :sha: 662472033e021d55d94146f66f6058822b0b39fd diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000000..fb9f217603 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,59 @@ +name: Security scan +on: + push: + branches: + - main + pull_request: + schedule: + - cron: '0 9 * * *' # Same time as CI Cron + +jobs: + build: + name: Build and scan image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 + - name: Run Trivy in table mode + # Table output is only useful when running on a pull request or push. + if: contains(fromJSON('["push", "pull_request"]'), github.event_name) + uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # tag v.0.28.0 + with: + format: table + exit-code: 1 + ignore-unfixed: true + severity: 'CRITICAL,HIGH,MEDIUM,LOW' + + - name: Run Trivy in report mode + # Only generate sarif when running nightly on the main branch. + if: ${{ github.event_name == 'schedule' }} + uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # tag v.0.28.0 + with: + format: 'template' + template: '@/contrib/sarif.tpl' + output: 'trivy-results.sarif' + ignore-unfixed: true + severity: 'CRITICAL,HIGH,MEDIUM,LOW' + + - name: Upload Trivy scan results to GitHub Security tab + # Only upload sarif when running nightly on the main branch. + if: ${{ github.event_name == 'schedule' }} + uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # tag v3.27.0 + with: + sarif_file: 'trivy-results.sarif' + + notify_slack_fail: + name: Notify slack fail + needs: [build] + runs-on: ubuntu-22.04 + if: ${{ github.event_name == 'schedule' && failure() }} + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 + - uses: ./.github/actions/workflow-conclusion + - uses: voxmedia/github-action-slack-notify-build@3665186a8c1a022b28a1dbe0954e73aa9081ea9e # tag v1.6.0 + if: ${{ env.WORKFLOW_CONCLUSION == 'failure' }} + env: + SLACK_BOT_TOKEN: ${{ secrets.RUBY_GITHUB_ACTIONS_BOT_WEBHOOK }} + with: + channel: ruby-agent-notifications + status: FAILED + color: danger From 415fe008700ad2f6f5d025860d7f436581b81eb8 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 29 Oct 2024 11:19:04 -0700 Subject: [PATCH 54/59] Add scan-type: fs --- .github/workflows/security.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index fb9f217603..358a03dae4 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -9,7 +9,7 @@ on: jobs: build: - name: Build and scan image + name: Build and scan runs-on: ubuntu-latest steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 @@ -18,19 +18,21 @@ jobs: if: contains(fromJSON('["push", "pull_request"]'), github.event_name) uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # tag v.0.28.0 with: + scan-type: fs format: table exit-code: 1 ignore-unfixed: true - severity: 'CRITICAL,HIGH,MEDIUM,LOW' + severity: CRITICAL,HIGH,MEDIUM,LOW - name: Run Trivy in report mode # Only generate sarif when running nightly on the main branch. if: ${{ github.event_name == 'schedule' }} uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # tag v.0.28.0 with: - format: 'template' + scan-type: fs + format: template template: '@/contrib/sarif.tpl' - output: 'trivy-results.sarif' + output: trivy-results.sarif ignore-unfixed: true severity: 'CRITICAL,HIGH,MEDIUM,LOW' @@ -39,7 +41,7 @@ jobs: if: ${{ github.event_name == 'schedule' }} uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # tag v3.27.0 with: - sarif_file: 'trivy-results.sarif' + sarif_file: trivy-results.sarif notify_slack_fail: name: Notify slack fail From 75d56e2bb0a177c9ed0898cbdedcc2ce9757d40c Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 29 Oct 2024 11:20:48 -0700 Subject: [PATCH 55/59] chore: Rename build job --- .github/workflows/security.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 358a03dae4..ca5ee54795 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -9,7 +9,7 @@ on: jobs: build: - name: Build and scan + name: Trivy Scan runs-on: ubuntu-latest steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 From d7c30b8b0543e8d8362b24fff161dc06bce4a46a Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 29 Oct 2024 11:35:30 -0700 Subject: [PATCH 56/59] Update run conditions --- .github/workflows/security.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index ca5ee54795..82c4c869ef 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -3,7 +3,7 @@ on: push: branches: - main - pull_request: + - dev schedule: - cron: '0 9 * * *' # Same time as CI Cron From fad51f8931f86f30fddb68d686781c52b44c901c Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 29 Oct 2024 13:18:02 -0700 Subject: [PATCH 57/59] Add bundling step --- .github/workflows/security.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 82c4c869ef..391401c771 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -4,6 +4,7 @@ on: branches: - main - dev + pull_request: schedule: - cron: '0 9 * * *' # Same time as CI Cron @@ -12,6 +13,11 @@ jobs: name: Trivy Scan runs-on: ubuntu-latest steps: + - name: Install Ruby 3.3 + uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 + with: + ruby-version: 3.3 + - run: bundle - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 - name: Run Trivy in table mode # Table output is only useful when running on a pull request or push. From bfed2c0c3789c9e643ed5db9f1b0ec75c98167c1 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 29 Oct 2024 13:20:34 -0700 Subject: [PATCH 58/59] bundle after checkout --- .github/workflows/security.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 391401c771..18423fbf79 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -17,8 +17,11 @@ jobs: uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0 with: ruby-version: 3.3 - - run: bundle + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7 + + - run: bundle # Generate a Gemfile.lock to scan + - name: Run Trivy in table mode # Table output is only useful when running on a pull request or push. if: contains(fromJSON('["push", "pull_request"]'), github.event_name) @@ -31,19 +34,18 @@ jobs: severity: CRITICAL,HIGH,MEDIUM,LOW - name: Run Trivy in report mode - # Only generate sarif when running nightly on the main branch. + # Only generate sarif when running nightly on the dev branch. if: ${{ github.event_name == 'schedule' }} uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # tag v.0.28.0 with: scan-type: fs - format: template - template: '@/contrib/sarif.tpl' + format: sarif output: trivy-results.sarif ignore-unfixed: true severity: 'CRITICAL,HIGH,MEDIUM,LOW' - name: Upload Trivy scan results to GitHub Security tab - # Only upload sarif when running nightly on the main branch. + # Only upload sarif when running nightly on the dev branch. if: ${{ github.event_name == 'schedule' }} uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # tag v3.27.0 with: From e1b035fde0e2bb4f4256b7d78ea7a908ae0da555 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:58:25 -0700 Subject: [PATCH 59/59] Prerelease 9.15.0-pre (#2927) * bump version --------- Co-authored-by: newrelic-ruby-agent-bot Co-authored-by: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> --- CHANGELOG.md | 4 ++-- lib/new_relic/version.rb | 2 +- newrelic.yml | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02b20266bf..c2a9f7b273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # New Relic Ruby Agent Release Notes -## dev +## v9.15.0 -Version updates View Componment instrumentation to use a default metric name when one is unavailable, adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS SDK, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem, resolves a bug in the ruby-kafka instrumentation, fixes a bug with Grape instrumentation, and addresses a bug preventing the agent from running in serverless mode in an AWS Lambda layer. +Version 9.15.0 updates View Componment instrumentation to use a default metric name when one is unavailable, adds a configuration option to associate the AWS account ID with the DynamoDB calls from the AWS SDK, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem, resolves a bug in the ruby-kafka instrumentation, fixes a bug with Grape instrumentation, and addresses a bug preventing the agent from running in serverless mode in an AWS Lambda layer. - **Feature: New configuration option cloud.aws.account_id** diff --git a/lib/new_relic/version.rb b/lib/new_relic/version.rb index a64d74cf2e..9e720e3211 100644 --- a/lib/new_relic/version.rb +++ b/lib/new_relic/version.rb @@ -6,7 +6,7 @@ module NewRelic module VERSION # :nodoc: MAJOR = 9 - MINOR = 14 + MINOR = 15 TINY = 0 STRING = "#{MAJOR}.#{MINOR}.#{TINY}" diff --git a/newrelic.yml b/newrelic.yml index a9f475437d..d23ae4183f 100644 --- a/newrelic.yml +++ b/newrelic.yml @@ -114,9 +114,9 @@ common: &default_settings # audit_log.path: log/newrelic_audit.log # An array of CLASS#METHOD (for instance methods) and/or CLASS.METHOD (for class - # methods) strings representing Ruby methods for the agent to automatically add - # custom instrumentation to without the need for altering any of the source code - # that defines the methods. + # methods) strings representing Ruby methods for the agent to automatically + # add custom instrumentation to without the need for altering any of the + # source code that defines the methods. # # Use fully qualified class names (using the :: delimiter) that include any # module or class namespacing. @@ -138,10 +138,10 @@ common: &default_settings # end # end # end - # + # # Given that source code, the newrelic.yml config file might request # instrumentation for both of these methods like so: - # + # # automatic_custom_instrumentation_method_list: # - MyCompany::Image#render_png # - MyCompany::User.notify @@ -216,6 +216,9 @@ common: &default_settings # If true, the agent will clear Tracer::State in Agent.drop_buffered_data. # clear_transaction_state_after_fork: false + # The AWS account ID for the AWS account associated with this app + # cloud.aws.account_id: nil + # If true, the agent will report source code level metrics for traced methods. # See: # https://docs.newrelic.com/docs/apm/agents/ruby-agent/features/ruby-codestream-integration/