Skip to content

Commit

Permalink
Merge pull request #308 from tsloughter/batch-repeat-timeout
Browse files Browse the repository at this point in the history
batch_processor: go to idle state after export timeout
  • Loading branch information
tsloughter authored Nov 9, 2021
2 parents 17bc408 + 4a05b37 commit b0f4c6b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/opentelemetry/src/otel_batch_processor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ idle(_, export_spans, Data) ->
idle(EventType, Event, Data) ->
handle_event_(idle, EventType, Event, Data).

%% receiving an `export_spans' timeout while exporting means the `ExportingTimeout'
%% is shorter than the `SendInterval'. Postponing the event will ensure we export
%% after
exporting({timeout, export_spans}, export_spans, _) ->
{keep_state_and_data, [postpone]};
exporting(enter, _OldState, Data=#data{exporting_timeout_ms=ExportingTimeout,
Expand All @@ -160,7 +163,7 @@ exporting(state_timeout, exporting_timeout, Data=#data{handed_off_table=Exportin
%% repeat the state to force another span exporting immediately
Data1 = kill_runner(Data),
new_export_table(ExportingTable),
{repeat_state, Data1};
{next_state, idle, Data1};
%% important to verify runner_pid and FromPid are the same in case it was sent
%% after kill_runner was called but before it had done the unlink
exporting(info, {'EXIT', FromPid, _}, Data=#data{runner_pid=FromPid}) ->
Expand Down

0 comments on commit b0f4c6b

Please sign in to comment.