Skip to content

Commit

Permalink
Merge pull request #2920 from newrelic/hammet_to_latimer_to_kurosawa_…
Browse files Browse the repository at this point in the history
…and_co_to_bolzoni_and_co

bugfix: always apply transformations on booleans
  • Loading branch information
fallwith authored Oct 25, 2024
2 parents 56889c5 + 8a8bd45 commit 24faee8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## dev

Version <dev> 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 <dev> 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**

Expand All @@ -19,12 +18,15 @@ Version <dev> 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 operational functionality**

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

Expand Down
2 changes: 1 addition & 1 deletion lib/new_relic/agent/configuration/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/new_relic/agent/configuration/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions test/new_relic/agent/serverless_handler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 24faee8

Please sign in to comment.