Skip to content

Advice for sharing configs across many projects #17

@cmschuetz

Description

@cmschuetz

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
end

I 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions