From 0269a8bfac475e125188905c7b30c7dac5bed23a Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Wed, 22 Feb 2023 09:34:52 -0800 Subject: [PATCH 1/5] only accept DT headers if not nil --- lib/new_relic/agent/instrumentation/sidekiq/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/new_relic/agent/instrumentation/sidekiq/server.rb b/lib/new_relic/agent/instrumentation/sidekiq/server.rb index 8c3a0b370c..0985b57676 100644 --- a/lib/new_relic/agent/instrumentation/sidekiq/server.rb +++ b/lib/new_relic/agent/instrumentation/sidekiq/server.rb @@ -21,7 +21,7 @@ def call(worker, msg, queue, *_) NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(msg['args'], :'job.sidekiq.args', NewRelic::Agent::AttributeFilter::DST_NONE) - ::NewRelic::Agent::DistributedTracing::accept_distributed_trace_headers(trace_headers, "Other") if ::NewRelic::Agent.config[:'distributed_tracing.enabled'] + ::NewRelic::Agent::DistributedTracing::accept_distributed_trace_headers(trace_headers, "Other") if ::NewRelic::Agent.config[:'distributed_tracing.enabled'] && trace_headers yield end end From bfd98beae0a8bf54f4fae27f37821addff78af80 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Wed, 22 Feb 2023 16:09:33 -0800 Subject: [PATCH 2/5] Add test --- lib/new_relic/agent/instrumentation/sidekiq/server.rb | 2 +- .../suites/sidekiq/sidekiq_instrumentation_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/new_relic/agent/instrumentation/sidekiq/server.rb b/lib/new_relic/agent/instrumentation/sidekiq/server.rb index 0985b57676..26c9d9b23f 100644 --- a/lib/new_relic/agent/instrumentation/sidekiq/server.rb +++ b/lib/new_relic/agent/instrumentation/sidekiq/server.rb @@ -21,7 +21,7 @@ def call(worker, msg, queue, *_) NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(msg['args'], :'job.sidekiq.args', NewRelic::Agent::AttributeFilter::DST_NONE) - ::NewRelic::Agent::DistributedTracing::accept_distributed_trace_headers(trace_headers, "Other") if ::NewRelic::Agent.config[:'distributed_tracing.enabled'] && trace_headers + ::NewRelic::Agent::DistributedTracing::accept_distributed_trace_headers(trace_headers, "Other") if ::NewRelic::Agent.config[:'distributed_tracing.enabled'] && trace_headers&.any? yield end end diff --git a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb index 377cf1bcfe..70d9606f68 100644 --- a/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +++ b/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb @@ -182,6 +182,14 @@ def test_captures_sidekiq_internal_errors Sidekiq::CLI.instance.handle_exception(exception) end + def test_accept_dt_headers_not_called_if_headers_nil + NewRelic::Agent::DistributedTracing.stubs(:insert_distributed_trace_headers) + NewRelic::Agent::DistributedTracing.expects(:accept_distributed_trace_headers).never + in_transaction do + run_jobs + end + end + def assert_metric_and_call_count(name, expected_call_count) metric_data = $collector.calls_for('metric_data') From cb521978f0b04fe0b875bae987941acf74929226 Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Wed, 22 Feb 2023 16:15:10 -0800 Subject: [PATCH 3/5] add changelog entry --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4950388ae5..bcff549376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # New Relic Ruby Agent Release Notes +## dev + + Upcoming version removes distributed tracing warnings from agent logs when using sidekiq. + + +- **Removes Distributed Tracing related warnings from agent logs when headers are not present in Sidekiq** + + Previously, the agent would log a warning in the newrelic_agent.log every time it attempted to accept empty distributed tracing headers from sidekiq jobs which could result in an excessive number of warnings. Now the agent will no longer create these warnings when using sidekiq. [PR#1834](https://github.com/newrelic/newrelic-ruby-agent/pull/1834) + ## v9.0.0 Version 9.0.0 of the agent removes several deprecated configuration options and API methods, enables Thread tracing by default, adds Fiber instrumentation, removes support for Ruby versions 2.2 and 2.3, removes instrumentation for several deprecated gems, changes how the API method `set_transaction_name` works, and updates `rails_defer_initialization` to be an environment variable only configuration option. From 011af03849992d8e9b32c274e56c8fd048dd7d7e Mon Sep 17 00:00:00 2001 From: Tanna McClure Date: Wed, 22 Feb 2023 16:28:46 -0800 Subject: [PATCH 4/5] Update CHANGELOG.md Co-authored-by: James Bunch --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcff549376..36262d0484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - **Removes Distributed Tracing related warnings from agent logs when headers are not present in Sidekiq** - Previously, the agent would log a warning in the newrelic_agent.log every time it attempted to accept empty distributed tracing headers from sidekiq jobs which could result in an excessive number of warnings. Now the agent will no longer create these warnings when using sidekiq. [PR#1834](https://github.com/newrelic/newrelic-ruby-agent/pull/1834) + Previously, the agent would log a warning to `newrelic_agent.log` every time it attempted to accept empty Distributed Tracing headers from Sidekiq jobs which could result in an excessive number of warnings. Now the agent will no longer create these warnings when using Sidekiq. [PR#1834](https://github.com/newrelic/newrelic-ruby-agent/pull/1834) ## v9.0.0 From 3a2d8eb3142c1e53a0d109216fbc0b00d1976834 Mon Sep 17 00:00:00 2001 From: James Bunch Date: Thu, 23 Feb 2023 11:42:28 -0800 Subject: [PATCH 5/5] Update CHANGELOG.md capitalize Distributed Tracing and Sidekiq. Co-authored-by: Kayla Reopelle (she/her) <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 36262d0484..a86f90688d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## dev - Upcoming version removes distributed tracing warnings from agent logs when using sidekiq. + Upcoming version removes Distributed Tracing warnings from agent logs when using Sidekiq. - **Removes Distributed Tracing related warnings from agent logs when headers are not present in Sidekiq**