diff --git a/CHANGELOG.md b/CHANGELOG.md index 987744cb91..0a335c2961 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,16 @@ ## v8.14.0 -Version 8.14.0 of the agent restores desired Capistrano-based changelog lookup functionalty when a deployment is performed, delivers support for instrumenting Rails custom event notifications, and fixes potential compatibility issues with Redis gems, and fixes bugs related to initialization in Rails. +Version 8.14.0 of the agent restores desired Capistrano-based changelog lookup functionalty when a deployment is performed, speeds up GUID generation, delivers support for instrumenting Rails custom event notifications, fixes potential compatibility issues with the RedisClient gem, and fixes bugs related to initialization in Rails. - **Deployment Recipe: Restore desired Capistrano-based changelog lookup behavior** The New Relic Ruby agent offers [a Capistrano recipe for recording app deployments](https://docs.newrelic.com/docs/apm/agents/ruby-agent/features/record-deployments-ruby-agent/#capistrano3). The recipe code was significantly cleaned up with [PR#1498](https://github.com/newrelic/newrelic-ruby-agent/pull/1498) which inadvertently changed the way the recipe handles the changelog for a deployment. Community member [@arthurwozniak](https://github.com/arthurwozniak) spotted and corrected this change in order to restore the desired changelog lookup functionality while retaining all of the previous cleanup. Thank you very much for your contribution, [@arthurwozniak](https://github.com/arthurwozniak)! [PR#1653](https://github.com/newrelic/newrelic-ruby-agent/pull/1653) +- **Speed up GUID generation** + + The agent leverages random numbers in its GUID (globally unique identifier) generation and would previously always freshly calculate the result of 16^16 or 32^32 before generating a random number. Given that those 16^16 and 32^32 operations are expected, it makes sense to calculate their results up front and store them in constants to be referred to later. Doing so has resulted in a performance gain for the generation of GUIDs. Many thanks to [@tungmq](https://github.com/tungmq) for contributing this optimisation and the benchmarks to support it! [PR#1693[(https://github.com/newrelic/newrelic-ruby-agent/pull/1693) + - **Support for Rails ActiveSupport::Notifications for custom events** When the new `active_support_custom_events_names` configuration parameter is set equal to an array of custom event names to subscribe to, the agent will now subscribe to each of the names specified and report instrumentation for the events when they take place. [Creating custom events](https://guides.rubyonrails.org/active_support_instrumentation.html#creating-custom-events) is simple and now reporting instrumentation for them to New Relic is simple as well. [PR#1659](https://github.com/newrelic/newrelic-ruby-agent/pull/1659) diff --git a/test/new_relic/agent/guid_generator_test.rb b/test/new_relic/agent/guid_generator_test.rb index ff2978af8b..62e3136bdb 100644 --- a/test/new_relic/agent/guid_generator_test.rb +++ b/test/new_relic/agent/guid_generator_test.rb @@ -19,6 +19,42 @@ def test_generate_guid_custom_length # the result should be exactly 32 hexadecimal characters assert_match(/[a-f0-9]{32}/, guid) end + + def test_max_rand_16_constant + canned = 1234567890123456 + NewRelic::Agent::GuidGenerator.stub_const(:MAX_RAND_16, canned..canned) do + guid = NewRelic::Agent::GuidGenerator.generate_guid(16) + + assert_equal '000462d53c8abac0', guid + end + end + + def test_max_rand_32_constant + canned = 12345678901234567890123456789012 + NewRelic::Agent::GuidGenerator.stub_const(:MAX_RAND_32, canned..canned) do + guid = NewRelic::Agent::GuidGenerator.generate_guid(32) + + assert_equal '0000009bd30a3c645943dd1690a03a14', guid + end + end + + def test_non_rjust + canned = NewRelic::Agent::GuidGenerator::MAX_RAND_32 + NewRelic::Agent::GuidGenerator.stub_const(:MAX_RAND_32, canned..canned) do + guid = NewRelic::Agent::GuidGenerator.generate_guid(32) + + assert_equal '100000000000000000000000000000000', guid + end + end + + def test_rjust + canned = 1138 + NewRelic::Agent::GuidGenerator.stub_const(:MAX_RAND_16, canned..canned) do + guid = NewRelic::Agent::GuidGenerator.generate_guid(16) + + assert_equal '0000000000000472', guid + end + end end end end