You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get undefined method category for NewRelic::Agent::Transaction::Class when I used it in a piece of code to test out how NewRelic::Agent::Tracer.in_transaction works in my local environment. I also test the same snippet of code in my test environment but couldn't find the information I set (e.g. partial_name) on any page of NewRelic online. I'm not sure those two are related. All other logs and errors have been shown without any problems.
NewRelic::Agent::Tracer.in_transaction(partial_name: 'NR_NAME')doRails.logger.info('NR_INFO')# I found this is loggedend
239: defself.prefix_for_category(txn,category=nil)=>240: category ||= (txn && txn.category)241: casecategory242: when:controllerthen ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
...
254: else"#{category.to_s}/"# for internal use only255: end256: end[1]pry(#<Class>)> txn.categoryNoMethodError: undefinedmethod`category' for NewRelic::Agent::Transaction:Classfrom (pry):7:in `prefix_for_category'
Expected Behavior
partial_name set is recorded and displayed in NR.
Steps to Reproduce
Put the snippet of code I presented above anywhere you want. In my case, I put them in a Rails controller and a worker triggered by Amazon SQS.
Your Environment
Include as many relevant details about your environment as possible including the running version of the Ruby agent, the Ruby version being used and any other relevant environment information
Hello @tatzsuzuki, thank you for bringing this to our attention.
When the agent dropped support for Ruby 2.0, we updated our api methods to use the built in required keyword arguments feature and removed ArgumentErrors we raised when that argument was missing. Unfortunately it looks like the NewRelic::Agent::Tracer.in_transaction was updated to remove the ArgumentError we would raise if category was not provided, but didn't actually update the method args to identify category as required. This results in this error being logged in the agent logs instead of being helpful and saying . I've made a pull request #1587 to resolve that and make sure category is being treated as a required kwarg.
Since that is the case, you do need to pass in a category kwarg as well as partial_name in order to use the in_transaction method. Adding this argument will resolve this error, and also prevent any ArgumentErrors from being raise in future versions where this is fixed. Hopefully that helps, let me know if there is anything else I can do!
Description
I get
undefined method category for NewRelic::Agent::Transaction::Class
when I used it in a piece of code to test out howNewRelic::Agent::Tracer.in_transaction
works in my local environment. I also test the same snippet of code in my test environment but couldn't find the information I set (e.g. partial_name) on any page of NewRelic online. I'm not sure those two are related. All other logs and errors have been shown without any problems.When the ruby interpreter reaches the line raises the error,
txn
is a class but category is defined as an instance attribute.Expected Behavior
partial_name
set is recorded and displayed in NR.Steps to Reproduce
Put the snippet of code I presented above anywhere you want. In my case, I put them in a Rails controller and a worker triggered by Amazon SQS.
Your Environment
Include as many relevant details about your environment as possible including the running version of the Ruby agent, the Ruby version being used and any other relevant environment information
Additional context
none
For Maintainers Only or Hero Triaging this bug
Suggested Priority (P1,P2,P3,P4,P5):
Suggested T-Shirt size (S, M, L, XL, Unknown):
The text was updated successfully, but these errors were encountered: