interagent / pliny

An opinionated toolkit for writing excellent APIs in Ruby.
MIT License
802 stars 73 forks source link

fix: handle args correctly in ruby 3.1.2 #351

Closed jabrown85 closed 1 year ago

jabrown85 commented 1 year ago

While upgrading a pliny app to 3.1.2, we saw invalid argument errors when trying to use the metrics. This was due to the fact that the in ruby 3, the *names grabs the **options. This difference causes a metric explosion as hashes with values are sent in as their own metric.

This ruby code shows the issue if you run this in 2.7.4 and 3.1.2:

def foo(*names, **opts, &block)
  puts "names: #{names.inspect}"
  puts "opts: #{opts.inspect}"
  puts "block: #{block}"
end

foo("foo", {bar: :baz}) do
  puts "block"
end