Embedded resources generate "Failed to lookup telemetry handlers." warning during compilation

I noticed that from some time I’m getting some [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. warnings when i compile my project.

Looking into it, I found that these warnings are generated when compiling my embedded resources, here is the stacktrace:

{
  current_stacktrace,
  [
    {telemetry_handler_table, list_for_event, 1,[{file,"/var/home/sezdocs/projects/rebuilt/platform/marketplace/deps/telemetry/src/telemetry_handler_table.erl"},{line,53}]},
    {telemetry,execute,3,[{file,"/var/home/sezdocs/projects/rebuilt/platform/marketplace/deps/telemetry/src/telemetry.erl"},{line,154}]},
    {'Elixir.Ash.Actions.Create',run,4,[{file,"lib/ash/actions/create/create.ex"},{line,44}]},
    {'Elixir.Ash.EmbeddableType.ShadowApi',create,2,[{file,"lib/ash/embeddable_type.ex"},{line,62}]},
    {'Elixir.Marketplace.Markets.Property.Showing',cast_input,2,[{file,"deps/ash/lib/ash/embeddable_type.ex"},{line,157}]},
    {'Elixir.Ash.Type',cast_input,3,[{file,"lib/ash/type/type.ex"},{line,498}]},
    {'Elixir.Ash.Type',set_default,3,[{file,"lib/ash/type/type.ex"},{line,1170}]},
    {'Elixir.Ash.Type',set_type_transformation,1,[{file,"lib/ash/type/type.ex"},{line,1160}]}
  ]
}

As you can see, it reaches the Ash.Actions.Create.run/4 function which calls:

Ash.Tracer.telemetry_span [:ash, Ash.Api.Info.short_name(api), :create],
                                  metadata do

Is there some way to remove/disable that call so I don’t get more these warnings?

Oh, how interesting. I’ve been trying to find this issue for ages :laughing: I’ve seen it in another project and couldn’t track it down. how did you get that stacktrace?? I can’t check on that other project at this exact moment, but I pushed something up to ash main that I believe should address the issue. Please try it out and let me know.

Thank you for for helping me figure this one out :bowing_man:

Using the dumbest method possible haha, basically I used grep to search for that warning message in my project deps directory.

grep -r "Failed to lookup telemetry handlers" *

From that, I found that the warning was generated from the file deps/telemetry/src/telemetry_handler_table.erl in the function list_for_event/1.

Then i changed that function to print the stacktrace:

-spec list_for_event(telemetry:event_name()) -> [#handler{}].
list_for_event(EventName) ->
    try
        ets:lookup(?MODULE, EventName)
    catch
        error:badarg ->
            erlang:display(?MODULE),
            erlang:display(EventName),
            erlang:display(erlang:process_info(self(), current_stacktrace)),
            ?LOG_WARNING("Failed to lookup telemetry handlers. "
                         "Ensure the telemetry application has been started. ", []),
            []
    end.

Finally i recompiled the telemetry dep with mix deps.compile telemetry and recompiled my project mix compile --force

Far from dumb, that is genius :slight_smile: We’ll done!

1 Like