Closed weixiyen closed 7 years ago
I assume that the error is happening on stop_layer
?
It looks like we did change the API on that to not include the full_name
argument as a distinct argument, and instead let the callback function handle it.
I'll have to setup my testing environment for Absinthe again to be positive, but it likely would work if you remove full_name
on line 15 of the Gist.
Correct it seems it's just stop_layer that didn't match.
Your recommendation fixes the issue, thanks!
defmodule ScoutApm.Absinthe.Plug do
alias ScoutApm.Internal.Layer
def init(default), do: default
def call(conn, _default) do
ScoutApm.TrackedRequest.start_layer("Controller", action_name(conn))
conn
|> Plug.Conn.register_before_send(&before_send/1)
end
def before_send(conn) do
full_name = action_name(conn)
uri = "#{conn.request_path}"
ScoutApm.TrackedRequest.stop_layer(
fn layer ->
layer
|> Layer.update_name(full_name)
|> Layer.update_uri(uri)
end
)
conn
end
# Takes a connection, extracts the phoenix controller & action, then manipulates & cleans it up.
# Returns a string like "PageController#index"
defp action_name(conn) do
action_name = conn.params["operationName"]
"GraphQL##{action_name}"
end
end
@weixiyen I'm going to reopen this until we get our documentation & that gist updated.
Thank you for reporting this, and I'm glad it's working for you.
The Absinthe Plug no longer works as of version 0.2.7 https://gist.github.com/itsderek23/d9435b21c9a44cd9629e93c4e8c2750e
Seems it's due to TrackedRequest.start_layer and TrackedRequest.stop_layer accepting modules instead of strings as the first argument.
Would it be possible to make an update to that gist?
Thanks!