Skip to content

Commit

Permalink
Re-use id and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
cschiewek committed Mar 14, 2024
1 parent 2148001 commit bd5d2b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/deps
/doc
/.elixir_ls
/.elixir-tools
erl_crash.dump
*.ez
src/*.erl
Expand Down
7 changes: 2 additions & 5 deletions lib/absinthe/phase/document/execution/resolution.ex
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ defmodule Absinthe.Phase.Document.Execution.Resolution do
defp reduce_resolution(%{middleware: []} = res), do: res

defp reduce_resolution(%{middleware: [middleware | remaining_middleware]} = res) do
start_id = :erlang.unique_integer()
metadata = %{id: start_id, telemetry_span_context: start_id, middleware: middleware, resolution: res}
id = :erlang.unique_integer()
metadata = %{id: id, telemetry_span_context: id, middleware: middleware, resolution: res}
:telemetry.execute(@middleware_start, %{system_time: System.system_time()}, metadata)

res =
Expand All @@ -244,10 +244,7 @@ defmodule Absinthe.Phase.Document.Execution.Resolution do
res -> reduce_resolution(res)
end

stop_id = :erlang.unique_integer()
metadata = %{id: stop_id, telemetry_span_context: stop_id, middleware: middleware, resolution: res}
:telemetry.execute(@middleware_stop, %{system_time: System.system_time()}, metadata)

res
end

Expand Down
6 changes: 2 additions & 4 deletions lib/absinthe/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,10 @@ defmodule Absinthe.Pipeline do
run_phase(todo, result, [phase | done])

{:ok, result} ->
start_id = :erlang.unique_integer()
metadata = %{id: start_id, telemetry_span_context: start_id, phase: phase, options: options}
id = :erlang.unique_integer()
metadata = %{id: id, telemetry_span_context: id, phase: phase, options: options}
:telemetry.execute(@phase_start, %{system_time: System.system_time()}, metadata)
result = run_phase(todo, result, [phase | done])
start_id = :erlang.unique_integer()
metadata = %{id: start_id, telemetry_span_context: start_id, phase: phase, options: options}
:telemetry.execute(@phase_stop, %{system_time: System.system_time()}, metadata)
result

Expand Down

0 comments on commit bd5d2b4

Please sign in to comment.