Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tagging.rb giving me an undefined method 'merge' for nil::NilClass #3088

Closed
arjitj2 opened this issue Aug 29, 2023 · 3 comments · Fixed by #3102
Closed

tagging.rb giving me an undefined method 'merge' for nil::NilClass #3088

arjitj2 opened this issue Aug 29, 2023 · 3 comments · Fixed by #3102
Labels
bug Involves a bug community Was opened by a community member

Comments

@arjitj2
Copy link

arjitj2 commented Aug 29, 2023

Current behaviour
This line: https://github.com/DataDog/dd-trace-rb/blob/master/lib/datadog/tracing/metadata/tagging.rb#L114

This error:

/app/vendor/bundle/ruby/3.0.0/gems/ddtrace-1.12.1/lib/datadog/tracing/metadata/tagging.rb:114:in `tags': undefined method `merge' for nil:NilClass (NoMethodError)

Expected behaviour
Maybe it should be

def tags
  meta.merge(metrics)
end

because meta and metrics are defined in the protected right below this function, which set @meta & @metrics if not already set.

Also, I might be going crazy, but I don't see tags being called anywhere in a way that seems intentional. set_tags at L62 takes a tags argument and uses it, but that seems like pretty much it.

TraceOperation includes the module but I don't see it using tags anywhere that isn't a passed argument to each respective function.

Steps to reproduce
not sure how to provide this because this is just the output of a pretty specific rails console command i'm runing

@arjitj2 arjitj2 added bug Involves a bug community Was opened by a community member labels Aug 29, 2023
@GustavoCaso
Copy link
Member

@arjitj2 Thank you so much for reporting the issue.

I think your code suggestion is reasonable to me.

By looking at the code, it looks like you might have hit an edge case in which you ask for the tags for a TraceOpertaion or SpanOpertaion before calling any of these methods:

set_tags(tags)
clear_tag(key)
get_metric(key)
set_metric(key, value)

Those methods call meta or metrics, which set up @meta and @metrcis

I don't currently work on the APM product, so I will default @TonyCTHsu or @marcotc make the final call.

@arjitj2
Copy link
Author

arjitj2 commented Aug 30, 2023

@arjitj2 Thank you so much for reporting the issue.

I think your code suggestion is reasonable to me.

By looking at the code, it looks like you might have hit an edge case in which you ask for the tags for a TraceOpertaion or SpanOpertaion before calling any of these methods:

set_tags(tags)
clear_tag(key)
get_metric(key)
set_metric(key, value)

Those methods call meta or metrics, which set up @meta and @metrcis

I don't currently work on the APM product, so I will default @TonyCTHsu or @marcotc make the final call.

@GustavoCaso yup that checks out-- I was trying to access span.tags to tag a metric before the span closed. I think that's what caused this issue.

I worked around it by just using my own tags hash instead of span.tags, though I still think this undefined method error was rough to figure out.

Thanks!

@GustavoCaso
Copy link
Member

I worked around it by just using my own tags hash instead of span.tags, though I still think this undefined method error was rough to figure out.

Agree. We most probably should fix on our end to avoid that unwanted behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug community Was opened by a community member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants