jmurphyweb
Help understanding Ecto Telemetry events (according to Appsignal)
I’m trying to understand more about the telemetry events emitted from a poorly performing query.
I’m looking at the AppSignal dashboard which records the events and puts them into a timeline.
The query has many preloads, but they don’t seem to show up in the timeline:



My questions:
- Why is only one of the preloads showing up in each of the screenshots above?
- Is that dead-time between the first query and the last preload just time spend doing the preloads? Is that expected? if not is this likely a telemetry events issue or an appsignal issue?
The offending code:
# in data_plugs
@decorate transaction_event()
def add_project_offers_to_conn(conn, _ops) do
project = conn.assigns.project
offers = Production.list_offers([project_id: project.id], [:custom_fields])
conn
|> assign(:proj_offers, offers)
end
def list_offers(filters, preloads \\ []) when is_list(filters) and is_list(preloads) do
preloads =
preloads ++
[
:engagement,
:original_offer,
:replacement_offer,
:job_title,
:department,
:contract_type,
:document,
altered_documents: :document,
envelope_events: EnvelopeEventAPI.preload_query()
]
query =
from(o in Offer, preload: ^preloads)
|> Queries.apply_filters(filters)
Repo.all(query)
end
Marked As Solved
jmurphyweb
I now have all preloads showing up in appsignal:
MyApp.Repo
def default_options(_atom) do
[
telemetry_options: [
appsignal_parent_span: Appsignal.Tracer.current_span()
]
]
end
MyApp.Telemetry
def handle_event([:ev2, :repo, :query], measurements, metadata, config) do
:ok = send_preload_to_appsignal(measurements, metadata, config)
:ok
end
defp send_preload_to_appsignal(
%{total_time: total_time},
%{repo: repo, query: query, options: options},
_config
) do
parent_span = options[:appsignal_parent_span]
# if current_span is not nil then the event is already sent by appsignal library
if parent_span && is_nil(Appsignal.Tracer.current_span()) do
# appsignal library uses :os.system_time so using here for consistency
time = :os.system_time()
"http_request"
|> Appsignal.Tracer.create_span(parent_span, start_time: time - total_time)
|> Appsignal.Span.set_name("Query #{inspect(repo)}")
|> Appsignal.Span.set_attribute("appsignal:category", "query.ecto")
|> Appsignal.Span.set_sql(query)
|> Appsignal.Tracer.close_span(end_time: time)
end
:ok
end
3
Popular in Questions
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Other popular topics
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
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)?
Would
mix ecto.rollback -v 200809061...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









