Created
October 15, 2019 09:27
-
-
Save electron0zero/5258149307ef6e68c62c32c4d61962fa to your computer and use it in GitHub Desktop.
Example of Ruby class attribute to store BGThreadPool metrics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BGThreadPoolT | |
# class attribute to store BGThreadPool metrics | |
class_attribute :metrics | |
# @note don't set this in code, it should only be set once on load | |
# setting it again will result in loss of metrics | |
self.metrics = Concurrent::Array.new | |
def add_things | |
self.class.metrics << "test #{self.object_id}" | |
return nil | |
end | |
end | |
b1 = BGThreadPoolT.new | |
b1.add_things | |
b2 = BGThreadPoolT.new | |
b2.add_things | |
b2.add_things | |
b2.add_things | |
ap BGThreadPoolT.metrics |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment