Open
Description
Describe the bug
If you have multiple graphql endpoints, setting a custom namespace doesn't work.
To Reproduce
I have two graphql endpoints, /api/graphql/user
and /api/graphql/admin
scope "/api/graphql/admin" do
pipe_through [
MyAppWeb.GraphqlAdmin.Plug.AppsignalNamespace,
]
forward("/", MyAppWeb.Plug.AbsintheAdmin,
schema: MyAppWeb.GraphqlAdmin.Schema
)
end
defmodule MyAppWeb.GraphqlAdmin.Plug.AppsignalNamespace do
def init(default), do: default
def call(conn, _) do
Appsignal.Span.set_namespace(Appsignal.Tracer.root_span(), "graphql_admin")
conn
end
end
Calls to /api/graphql/admin
still end up in the graphql
namespace.
This line seems to be responsible:
https://github.com/appsignal/appsignal-elixir/blob/main/lib/appsignal/absinthe.ex#L55
Could you modify it to conditionally apply the namespace only if it's currently set to the default?