kevinlang

kevinlang

Finch: Failed to lookup telemetry handlers

I have a simple Mix Task in one of my projects for making a request to a service with Finch. Here is a simple example of doing such a thing.

defmodule Mix.Tasks.Example.Request do
  use Mix.Task

  def run([]) do
    Finch.start_link(name: MyFinch)

    Finch.build(:get, "https://github.com")
    |> Finch.request(MyFinch)
  end
end

If I run this with mix example.request, I get the following output:

$ mix example.request
Compiling 1 file (.ex)

09:47:57.913 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:57.920 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:57.921 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:57.921 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:58.160 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:58.161 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:58.162 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:58.162 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:58.388 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

09:47:58.388 [warning] Failed to lookup telemetry handlers. Ensure the telemetry application has been started. 

The request completes as expected, but I get all of these warnings related to my telemetry application not being started. I don’t want to start any telemetry application, though. It’s a simple one-off Mix task that has nothing to do with the rest of my app per se and I don’t want to run app.start or similar.

Interestingly, if I do the same thing with a simple exs script, I get no warnings.

Mix.install([:finch])

Finch.start_link(name: MyFinch)

Finch.build(:get, "https://github.com")
|> Finch.request(MyFinch)

I have three questions:

  1. Why do I get these warnings?
  2. How can I silence them?
  3. Why do they only show up when run in a Mix task within the application, but not in a standalone Mix install script? I’m guessing something specified in my mix.exs file or in my config.exs file(s) is causing this, but not sure which.

Cheers,

Marked As Solved

kevinlang

kevinlang

Found it. The discrepancy lies in the fact that Mix.install/1 starts the application for each dependency by default.

Solution is to just add Application.ensure_started(:telemetry) at the beginning of the Mix task.

Where Next?

Popular in Questions Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement