Skip to content

Commit

Permalink
Merge pull request #1587 from newrelic/in_transaction_category_requir…
Browse files Browse the repository at this point in the history
…ed_kwarg

Update NewRelic::Agent::Tracer.in_transaction to identify category as a required kwarg
  • Loading branch information
tannalynn authored Nov 4, 2022
2 parents 8867bbe + 1137ef4 commit bade258
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

Unicorn, Rainbows, or FastCGI web applications using Rack v3.0.0 may previously have had the "dispatcher" value incorrectly reported as "Webrick" instead of "Unicorn", "Rainbows", or "FastCGI". This issue has now been addressed. [PR#1585](https://github.com/newrelic/newrelic-ruby-agent/pull/1585)

* **Bugfix: Category is a required keyword arg for NewRelic::Agent::Tracer.in_transaction**

When support for Ruby 2.0 was dropped in version 8.0.0 of the agent, the agent API methods were updated to use the required keyword argument feature built into Ruby, rather than manually raising ArgumentErrors. The API method `NewRelic::Agent::Tracer.in_transaction` removed the ArgumentError raised by the agent, but did not update the method arguments to identify category as a required keyword argument. This is now resolved. Thank you to @tatzsuzuki for bringing this to our attention. [PR#](https://github.com/newrelic/newrelic-ruby-agent/pull/1587)


## v8.12.0

Expand Down
2 changes: 1 addition & 1 deletion lib/new_relic/agent/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def transaction_sampled?
# @api public
def in_transaction(name: nil,
partial_name: nil,
category: nil,
category:,
options: {})

finishable = start_transaction_or_segment(
Expand Down
8 changes: 8 additions & 0 deletions test/new_relic/agent/tracer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ def test_in_transaction
assert_metrics_recorded(['test'])
end

def test_in_transaction_missing_category
assert_raises ArgumentError do
NewRelic::Agent::Tracer.in_transaction(name: 'test') do
# No-op
end
end
end

def test_in_transaction_with_early_failure
yielded = false
NewRelic::Agent::Transaction.any_instance.stubs(:start).raises("Boom")
Expand Down

0 comments on commit bade258

Please sign in to comment.