Spandex Decorators crash during app release: Decorator.Decorate.before_compile/1

Hey All! I recently inherited a phoenix project and had to add datadog tracing to it(using Spandex). Everything was added and working properly following the Spandex docs, however when I try to build my docker image I always get this error on the mix release phase:

(CompileError) lib/my_service/vouchers/vouchers.ex:1: module nil is not loaded and could not be found
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    /lib/my_service/vouchers/vouchers.ex:1: Decorator.Decorate.before_compile/1

The vouchers.ex module is literally:

defmodule MyService.Vouchers do
  # Use this module to decorate all the methods here
  use ModuleTracer

And the ModuleTracer is a custom module within my tracer to include in all the modules where I want all the functions to be “spanned”

defmodule ModuleTracer do
    defmacro __using__(_opts) do
      quote do
        use Spandex.Decorators

        @decorate_all span()

If I “use” this module anywhere in the application mix release fails with the above mentioned error, if I don’t use it the build succeeds. The error is always in the module, which “uses” ModuleTracer. Am I missing something really simple or am I trying to achieve the impossible?

Erlang/OTP 22 [erts-10.7] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Elixir 1.9.4 (compiled with Erlang/OTP 22)

Just a random shot in the dark: is the library only included for the dev environment in mix.exs?

No, unfortunately that is not the case.
I am really puzzled by this.

Can you show the source of ModuleTracer.__using__?

I’ve opened an issue in the Spandex’s repo: It has a lot of additional information as far as what I did. It’s interesting that this problem is reproducible on a fresh phoenix app as well. I am starting to suspect that there might be something wrong with the Dockerfile as well, but have no clue as to what exactly…