@@ -106,8 +106,6 @@ defmodule PromEx do
106106
107107 alias Telemetry.Metrics . { Counter , Distribution , LastValue , Sum , Summary }
108108
109- alias TelemetryMetricsPrometheus.Core
110-
111109 @ type telemetry_metrics ( ) :: Counter . t ( ) | Distribution . t ( ) | LastValue . t ( ) | Sum . t ( ) | Summary . t ( )
112110 @ type measurements_mfa ( ) :: { module ( ) , atom ( ) , list ( ) }
113111
@@ -122,10 +120,9 @@ defmodule PromEx do
122120 @ spec get_metrics ( prom_ex_module :: module ( ) ) :: String . t ( ) | :prom_ex_down
123121 def get_metrics ( prom_ex_module ) do
124122 prom_ex_process_name = prom_ex_module . __metrics_collector_name__ ( )
123+ store = prom_ex_module . __store__ ( )
125124
126- if Process . whereis ( prom_ex_process_name ) ,
127- do: Core . scrape ( prom_ex_process_name ) ,
128- else: :prom_ex_down
125+ PromEx.Storage . scrape ( store , prom_ex_process_name )
129126 end
130127
131128 @ callback init_opts :: PromEx.Config . t ( )
@@ -147,6 +144,8 @@ defmodule PromEx do
147144 raise "Failed to initialize #{ inspect ( calling_module ) } due to missing :otp_app option"
148145 end
149146
147+ store = Keyword . get ( opts , :store , PromEx.Storage.Core )
148+
150149 # Generate process names under calling module namespace
151150 ets_cron_flusher_name = Module . concat ( [ calling_module , ETSCronFlusher ] )
152151 manual_metrics_name = Module . concat ( [ calling_module , ManualMetricsManager ] )
@@ -202,7 +201,7 @@ defmodule PromEx do
202201 children =
203202 [ ]
204203 |> PromEx . ets_cron_flusher_child_spec ( __MODULE__ , ets_flush_interval , unquote ( ets_cron_flusher_name ) )
205- |> PromEx . metrics_collector_child_spec ( telemetry_metrics , unquote ( metrics_collector_name ) )
204+ |> PromEx . metrics_collector_child_spec ( unquote ( store ) , telemetry_metrics , unquote ( metrics_collector_name ) )
206205 |> PromEx . manual_metrics_child_spec (
207206 manual_metrics ,
208207 manual_metrics_start_delay ,
@@ -334,6 +333,9 @@ defmodule PromEx do
334333 @ doc false
335334 def __ets_cron_flusher_name__ , do: unquote ( ets_cron_flusher_name )
336335
336+ @ doc false
337+ def __store__ , do: unquote ( store )
338+
337339 defoverridable PromEx
338340 end
339341 end
@@ -372,13 +374,8 @@ defmodule PromEx do
372374 end
373375
374376 @ doc false
375- def metrics_collector_child_spec ( acc , metrics , process_name ) do
376- spec = {
377- Core ,
378- name: process_name , metrics: metrics , require_seconds: false , consistent_units: true , start_async: false
379- }
380-
381- [ spec | acc ]
377+ def metrics_collector_child_spec ( acc , store , metrics , process_name ) do
378+ [ PromEx.Storage . child_spec ( store , process_name , metrics ) | acc ]
382379 end
383380
384381 @ doc false
0 commit comments