Skip to content

Commit

Permalink
Merge pull request #1797 from newrelic/allow_set_txn_name_to_change_c…
Browse files Browse the repository at this point in the history
…ategory

Allow `set_transaction_name` to change name and category of current transaction.
  • Loading branch information
tannalynn authored Feb 6, 2023
2 parents 61e8c56 + 7192742 commit 315107e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v9.0.0

Version 9.0.0 of the agent enables thread tracing, removes several deprecated configuration options, and removes support for Ruby versions 2.2 and 2.3.
Version 9.0.0 of the agent enables thread tracing, removes several deprecated configuration options, removes support for Ruby versions 2.2 and 2.3, and changes how the API method `set_transaction_name` works..


- **Remove Deprecated Configuration Options**
Expand Down Expand Up @@ -70,6 +70,12 @@
- Rainbows
- Sunspot


- **Changes how the API method `set_transaction_name` works**

When the method `NewRelic::Agent.set_transaction_name` is called, it will now always change the name and category of the currently running transaction to what is passed in to the method. This is a change from how it functioned in previous agent versions. Previously, if `set_transaction_name` was called with a new transaction name and a new category that did not match the category that was already assigned to a transaction, neither the new name nor category would be saved to the transaction.


- **Dropped method: `NewRelic::Agent.disable_transaction_tracing`**

The previously deprecated `NewRelic::Agent.disable_transaction_tracing` method has been removed. Users are encouraged to use `NewRelic::Agent.disable_all_tracing` or `NewRelic::Agent.ignore_transaction`.
Expand Down
6 changes: 2 additions & 4 deletions lib/new_relic/agent/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,8 @@ def set_default_transaction_name(name, category)
def set_overriding_transaction_name(name, category)
return log_frozen_name(name) if name_frozen?

if influences_transaction_name?(category)
self.overridden_name = name
@category = category if category
end
self.overridden_name = name
@category = category if category
end

def log_frozen_name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ def ignored_txn
def test_metric_names_when_child_has_different_category
TestTransactor.new.parent_txn(:task)

# background task does not record apdex
assert_metrics_recorded([
'Controller/TestTransactor/parent',
'OtherTransaction/Background/TestTransactor/child',
'Nested/Controller/SetTransactionNameTest::TestTransactor/child_txn',
['Nested/Controller/SetTransactionNameTest::TestTransactor/child_txn', 'Controller/TestTransactor/parent'],
'Apdex/TestTransactor/parent'
['Nested/Controller/SetTransactionNameTest::TestTransactor/child_txn', 'OtherTransaction/Background/TestTransactor/child'], # check child method segment metric still exists
['Nested/Controller/SetTransactionNameTest::TestTransactor/parent_txn', 'OtherTransaction/Background/TestTransactor/child'] # check parent segment metric still exists
])
end

Expand Down

0 comments on commit 315107e

Please sign in to comment.