Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: always apply transformations on booleans #2920

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
kaylareopelle marked this conversation as resolved.
Show resolved Hide resolved

- **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
Loading