28
28
collect /1 ,
29
29
checkpoint_generation /1 ,
30
30
shutdown /1 ,
31
- collect_ /4 ]).
31
+ collect_ /5 ]).
32
32
33
33
-export ([init /1 ,
34
34
handle_call /3 ,
@@ -143,40 +143,19 @@ handle_call(shutdown, _From, State) ->
143
143
{reply , ok , State };
144
144
145
145
handle_call (collect , _From , State = # state {id = ReaderId ,
146
- exporter = Exporter ,
147
- callbacks_tab = CallbacksTab ,
148
- streams_tab = StreamsTab ,
149
- metrics_tab = MetricsTab ,
150
- exemplars_tab = ExemplarsTab ,
151
- resource = Resource ,
152
- producers = Producers
153
- }) ->
154
- TRef = update_timer (State # state .tref , State # state .export_interval_ms ),
155
- Reply = collect_and_export (ReaderId , Exporter , CallbacksTab , ViewAggregationTab , MetricsTab , Resource ),
156
- {reply , Reply , State # state {tref = TRef }};
157
-
158
- handle_call (collect , _From , State = # state {id = ReaderId ,
159
- exporter = {ExporterModule , Config },
160
- export_interval_ms = ExporterIntervalMs ,
161
- tref = TRef ,
162
- callbacks_tab = CallbacksTab ,
163
- streams_tab = StreamsTab ,
164
- metrics_tab = MetricsTab ,
165
- exemplars_tab = ExemplarsTab ,
166
- resource = Resource ,
167
- producers = Producers
168
- }) ->
169
- TRef = update_timer (State # state .tref , State # state .export_interval_ms ),
170
-
171
- Metrics = run_collection (CallbacksTab , StreamsTab , MetricsTab , ExemplarsTab , ReaderId , Producers ),
172
-
173
- Reply = otel_exporter :export_metrics (ExporterModule , Metrics , Resource , Config ),
174
-
175
- {reply , Reply , State # state {tref = TRef }};
176
-
177
- % % no exporter, do nothing at all
178
- handle_call (collect , _From , State ) ->
179
- {reply , ok , State };
146
+ exporter = Exporter ,
147
+ export_interval_ms = ExporterIntervalMs ,
148
+ tref = TRef ,
149
+ callbacks_tab = CallbacksTab ,
150
+ streams_tab = StreamsTab ,
151
+ metrics_tab = MetricsTab ,
152
+ exemplars_tab = ExemplarsTab ,
153
+ resource = Resource ,
154
+ producers = Producers
155
+ }) ->
156
+ NewTRef = update_timer (TRef , ExporterIntervalMs ),
157
+ Reply = collect_and_export (ReaderId , Exporter , CallbacksTab , StreamsTab , MetricsTab , ExemplarsTab , Producers , Resource ),
158
+ {reply , Reply , State # state {tref = NewTRef }};
180
159
181
160
handle_call (_ , _From , State ) ->
182
161
{noreply , State }.
@@ -193,11 +172,19 @@ handle_cast(_, State) ->
193
172
code_change (State ) ->
194
173
{ok , State }.
195
174
196
- update_timer (undefined , undefined ) ->
197
- undefined ;
198
- update_timer (TRef , ExporterIntervalMs ) ->
175
+ collect_and_export (_ReaderId , undefined , _CallbacksTab , _StreamsTab , _MetricsTab , _ExemplarsTab , _Producers , _Resource ) ->
176
+ ok ;
177
+ collect_and_export (ReaderId , {ExporterModule , Config }, CallbacksTab , StreamsTab , MetricsTab , ExemplarsTab , Producers , Resource ) ->
178
+ Metrics = run_collection (CallbacksTab , StreamsTab , MetricsTab , ExemplarsTab , ReaderId , Producers ),
179
+ otel_exporter :export_metrics (ExporterModule , Metrics , Resource , Config ).
180
+
181
+ update_timer (TRef , ExporterIntervalMs )
182
+ when TRef =/= undefined andalso
183
+ ExporterIntervalMs =/= undefined ->
199
184
erlang :cancel_timer (TRef , [{async , true }]),
200
- erlang :send_after (ExporterIntervalMs , self (), collect ).
185
+ erlang :send_after (ExporterIntervalMs , self (), collect );
186
+ update_timer (_TRef , _ExporterIntervalMs ) ->
187
+ ok .
201
188
202
189
run_collection (CallbacksTab , StreamsTab , MetricsTab , ExemplarsTab , ReaderId , Producers ) ->
203
190
% % collect from view aggregations table and then export
0 commit comments