Skip to content

Commit

Permalink
Merge pull request #1174 from Vic-ai/master
Browse files Browse the repository at this point in the history
Add end_time_mono to telemetry :stop events
  • Loading branch information
benwilson512 authored Jun 7, 2022
2 parents 453fd12 + ffb03e7 commit 2768d10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lib/absinthe/middleware/batch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ defmodule Absinthe.Middleware.Batch do
timeout = Keyword.get(batch_opts, :timeout, 5_000)
result = Task.await(task, timeout)

duration = System.monotonic_time() - start_time_mono
emit_stop_event(duration, metadata, result)
end_time_mono = System.monotonic_time()
duration = end_time_mono - start_time_mono
emit_stop_event(duration, end_time_mono, metadata, result)

result
end)
Expand Down Expand Up @@ -178,10 +179,10 @@ defmodule Absinthe.Middleware.Batch do
metadata
end

defp emit_stop_event(duration, metadata, result) do
defp emit_stop_event(duration, end_time_mono, metadata, result) do
:telemetry.execute(
@batch_stop,
%{duration: duration},
%{duration: duration, end_time_mono: end_time_mono},
Map.put(metadata, :result, result)
)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/middleware/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defmodule Absinthe.Middleware.Telemetry do

:telemetry.execute(
@field_stop,
%{duration: end_time_mono - start_time_mono},
%{duration: end_time_mono - start_time_mono, end_time_mono: end_time_mono},
%{
id: id,
telemetry_span_context: id,
Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/phase/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule Absinthe.Phase.Telemetry do
with %{id: id, start_time_mono: start_time_mono} <- blueprint.telemetry do
:telemetry.execute(
@subscription_stop,
%{duration: end_time_mono - start_time_mono},
%{duration: end_time_mono - start_time_mono, end_time_mono: end_time_mono},
%{id: id, telemetry_span_context: id, blueprint: blueprint, options: options}
)
end
Expand All @@ -72,7 +72,7 @@ defmodule Absinthe.Phase.Telemetry do
with %{id: id, start_time_mono: start_time_mono} <- blueprint.telemetry do
:telemetry.execute(
@operation_stop,
%{duration: end_time_mono - start_time_mono},
%{duration: end_time_mono - start_time_mono, end_time_mono: end_time_mono},
%{id: id, telemetry_span_context: id, blueprint: blueprint, options: options}
)
end
Expand Down

0 comments on commit 2768d10

Please sign in to comment.