Project

General

Profile

Bug #17765 » segfault_gsub.rb

lenwood (Paul Martensen), 03/31/2021 11:57 AM

 
def sanitize_for_prometheus(string_or_symbol)
reg = /[^a-zA-Z_0-9]/
string_or_symbol.to_s.downcase.gsub(reg, '_')
end

def rand_string_or_symbol
@o ||= [('a'..'z').to_a, ('A'..'Z').to_a, (0..9).to_a, '-', '.'].flatten
str = @o.sample(50).join
rand > 0.5 ? str.to_sym : str
end

loop { sanitize_for_prometheus rand_string_or_symbol }
(2-2/2)