From 300ac4ce14c51ed35ddb4e1942a170186f79f898 Mon Sep 17 00:00:00 2001 From: fallwith Date: Thu, 24 Oct 2024 16:58:46 -0700 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 4/4] 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**