spandex-project/spandex

Umbrella application and decorator configuration

emhagman opened this issue · 3 comments

Hi!

First off, thanks for making this. I really appreciate it and I enjoyed your talk at the BEAM conference. We use an umbrella app and most of spandex is working; however, I noticed this line:

https://github.com/spandex-project/spandex/blob/master/lib/decorators.ex#L27

I am trying to figure out which OTP app would be chosen here in Application.get_env during compile time. I've moved the Datadog.ApiServer and my Tracer into a common application that is shared across my apps in the umbrella app.

Currently, I have the decorator set in every config.ex for each app but I was wondering if this is overkill or if you had any idea with OTP app is the one during compilation time for the decorators.

The way Umbrella app configuration works is that is applies the configs alphabetically (lexicographically) one after the other, so if you have config :spandex, :decorators, tracer: MyApp.Tracer defined in each one, it's just going to keep overwriting the value over and over. That's fine as long as they're all the same, but it could be confusing if you set it to a different value in each app and expected that app to use its associated configuration, because that's simply not how configuration works for umbrella apps.

I don't personally use umbrella apps (mostly due to confusion points like this), so this is possibly a shortcoming in Spandex that could be handled differently to make it more useful in an umbrella project. Let me know if you have thoughts about how you wish it worked, and we'll try to do better as we migrate to OpenTelemetry in the future.

Thanks, that helps a lot. So in theory, I only need to set it in my common application and everything should work? I just have a common tracer for now that they all use.

Yes, if you have just one tracer, you should be able to just configure it once globally. I’ll go ahead and close this for now, but let us know if you run into any issues!