coop

coop

Instrumenting Absinthe via Telemetry

I’m trying to expose graphql operations in a dashboard but I’m having trouble parsing the operation name from the query or mutation. At this stage I’d like to expose the total time for either a query or mutation, I have the following query:

query {
  me {
    id
  }
}

And I believe I should be able to pull out the appropriate duration metric by attaching to [:absinthe, :execute, :operation, :stop] with something like:

:telemetry.attach_many(
  :demo,
  [
    [:absinthe, :execute, :operation, :stop]
  ],
  fn event_name, measurements, metadata, _config ->
    IO.inspect(metadata)
  end,
  []
)

metadata seems to be an id, blueprint and options. If I take a look at blueprint’s source code I can’t see where I can access the name of the query - in this case me. I would love to be able to report the duration of the me query.

Absinthe.Language.Document.get_operation(metadata.blueprint.input) gets me what the client passes as the friendly name but given that can be anything I’d prefer to get me but I cannot figure it out. I know it’s somewhere because absinthe uses it internally to figure out which query to run.

Alternatively I’m thinking about this the wrong way and there is a different way to get what I want. Any help would be appreciated.

Thanks!

Most Liked

dlobo

dlobo

I’ve been looking at this too trying to see if we can connect absinthe with appsignal. Blueprint just seems like a really big data structure, but I did find

metadata.options a lot easier to check. It is a keyword list and seems to have the “operation_name” for a query

lobo

Where Next?

Popular in Questions Top

dotdotdotPaul
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
jerry
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
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
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

Other popular topics Top

SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement