Skip to content

Commit 0ec0ada

Browse files
lukegaleazachdaniel
authored andcommitted
Add GraphQL tracer integration for AppSignal monitoring
- Add tracer parameter to Ash.Query.for_read calls in GraphQL resolvers - Enables proper AppSignal tracing for GraphQL operations - Works with Scribble.Telemetry.AppsignalAshGraphql for descriptive span names Closes: AppSignal tracing for GraphQL operations
1 parent 65db98e commit 0ec0ada

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

documentation/topics/monitoring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A tracer can be configured in the domain. It will fallback to the global tracer
1212

1313
```elixir
1414
graphql do
15-
trace MyApp.Tracer
15+
tracer MyApp.Tracer
1616
end
1717
```
1818

lib/graphql/resolver.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ defmodule AshGraphql.Graphql.Resolver do
369369
|> Ash.Query.for_read(action, %{},
370370
actor: opts[:actor],
371371
domain: domain,
372-
authorize?: AshGraphql.Domain.Info.authorize?(domain)
372+
authorize?: AshGraphql.Domain.Info.authorize?(domain),
373+
tracer: AshGraphql.Domain.Info.tracer(domain)
373374
)
374375
|> load_fields(
375376
[
@@ -492,7 +493,8 @@ defmodule AshGraphql.Graphql.Resolver do
492493
|> Ash.Query.for_read(action, %{},
493494
actor: Map.get(context, :actor),
494495
domain: domain,
495-
authorize?: AshGraphql.Domain.Info.authorize?(domain)
496+
authorize?: AshGraphql.Domain.Info.authorize?(domain),
497+
tracer: AshGraphql.Domain.Info.tracer(domain)
496498
),
497499
query <-
498500
load_fields(

test/read_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,4 +1629,19 @@ defmodule AshGraphql.ReadTest do
16291629
} = result
16301630
end
16311631
end
1632+
1633+
test "domain tracer configuration is correctly retrieved" do
1634+
# Create a test domain with tracer configuration
1635+
defmodule TestDomainWithTracer do
1636+
use Ash.Domain,
1637+
extensions: [AshGraphql.Domain]
1638+
1639+
graphql do
1640+
tracer MyApp.Tracer
1641+
end
1642+
end
1643+
1644+
# Verify that the tracer configuration is correctly retrieved
1645+
assert AshGraphql.Domain.Info.tracer(TestDomainWithTracer) == [MyApp.Tracer]
1646+
end
16321647
end

0 commit comments

Comments
 (0)