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!