-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathopentelemetry_absinthe.ex
36 lines (30 loc) · 1.05 KB
/
opentelemetry_absinthe.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
defmodule OpentelemetryAbsinthe do
@moduledoc """
Module for automatic instrumentation of Absinthe resolution.
It works by listening to [:absinthe, :execute, :operation, :start/:stop] telemetry events,
which are emitted by Absinthe only since v1.5; therefore it won't work on previous versions.
(you can still call `OpentelemetryAbsinthe.Instrumentation.setup()` in your application startup
code, it just won't do anything.)
"""
alias OpentelemetryAbsinthe.AsyncHandler
alias OpentelemetryAbsinthe.BatchHandler
alias OpentelemetryAbsinthe.ExecuteHandler
alias OpentelemetryAbsinthe.ParseHandler
alias OpentelemetryAbsinthe.ValidateHandler
@tracer_id __MODULE__
@doc """
Initializes and configures the telemetry handlers.
"""
def setup(_opts \\ []) do
config = %{
tracer_id: @tracer_id
}
# Base GraphQL events
ParseHandler.attach(config)
ValidateHandler.attach(config)
ExecuteHandler.attach(config)
# Absinthe specific events
AsyncHandler.attach(config)
BatchHandler.attach(config)
end
end