-
-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hi Samuel,
Big fan of async and use it daily, thanks for all that you do.
I'm in a situation with lots of ruby projects and want to share a default set of trace configurations (e.g. with a specific backend and set of providers) and make it as easy as possible to share, update, etc. In other words, install this gem and you're good to go.
I've found that encapsulating these configs within a gem is challenging because of load order. If I can ensure this setup logic runs before traces is loaded, everything works great, but if another gem loads traces first, I can't find a good way to perform this setup and "reload" everything without some hack-adjacent code.
Concretely, if the backend isn't configured before this piece runs:
if self.enabled?
# Extend the specified class in order to emit traces.
def self.Provider(klass, &block)
klass.extend(Singleton)
provider = klass.traces_provider
klass.prepend(provider)
provider.module_exec(&block) if block_given?
return provider
end
else
def self.Provider(klass, &block)
# Tracing disabled.
end
endI can't find a good way of loading providers without reloading the module.
Curious to hear how you've seen this done and if I'm completely thinking about this the wrong way