Skip to content

Commit

Permalink
Mix format.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Nov 20, 2024
1 parent dbad092 commit b24d354
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
14 changes: 11 additions & 3 deletions lib/dpul_collections/index_metrics_tracker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ defmodule DpulCollections.IndexMetricsTracker do
end

def register_fresh_index(source) do
GenServer.cast(__MODULE__, { :fresh_index, source })
GenServer.cast(__MODULE__, {:fresh_index, source})
end

def register_polling_started(source) do
GenServer.cast(__MODULE__, { :poll_started, source })
GenServer.cast(__MODULE__, {:poll_started, source})
end

@impl true
Expand All @@ -29,7 +29,13 @@ defmodule DpulCollections.IndexMetricsTracker do
if get_in(state, [source, :start_time]) != nil && get_in(state, [source, :end_time]) == nil do
state = put_in(state, [source, :end_time], :erlang.monotonic_time())
duration = state[source][:end_time] - state[source][:start_time]
:telemetry.execute([:dpulc, :indexing_pipeline, event(source), :time_to_poll], %{duration: duration}, %{source: source})

:telemetry.execute(
[:dpulc, :indexing_pipeline, event(source), :time_to_poll],
%{duration: duration},
%{source: source}
)

{:noreply, state}
else
{:noreply, state}
Expand All @@ -39,9 +45,11 @@ defmodule DpulCollections.IndexMetricsTracker do
def event(Figgy.HydrationProducerSource) do
:hydrator
end

def event(Figgy.TransformationProducerSource) do
:transformer
end

def event(Figgy.IndexingProducerSource) do
:indexer
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ defmodule DpulCollections.IndexingPipeline.DatabaseProducer do
if last_queried_marker == nil do
DpulCollections.IndexMetricsTracker.register_fresh_index(source_module)
end

total_demand = stored_demand + demand

records =
Expand Down
2 changes: 1 addition & 1 deletion lib/dpul_collections_web/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ defmodule DpulCollectionsWeb.Telemetry do
reporter_options: [
nav: "Indexing Pipeline"
]
),
)
]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,18 @@ defmodule DpulCollections.IndexingPipeline.FiggyFullIntegrationTest do
{Figgy.HydrationConsumer, cache_version: cache_version, batch_size: 50},
{IndexMetricsTracker, []}
]

test_pid = self()
:ok = :telemetry.attach("hydration-full-run", [:dpulc, :indexing_pipeline, :hydrator, :time_to_poll], fn _,measurements,_,_ -> send(test_pid, {:hydrator_time_to_poll_hit, measurements}) end, nil)

:ok =
:telemetry.attach(
"hydration-full-run",
[:dpulc, :indexing_pipeline, :hydrator, :time_to_poll],
fn _, measurements, _, _ ->
send(test_pid, {:hydrator_time_to_poll_hit, measurements})
end,
nil
)

Supervisor.start_link(children, strategy: :one_for_one, name: DpulCollections.TestSupervisor)

Expand Down

0 comments on commit b24d354

Please sign in to comment.