Merge pull request #11498 from zhongwencool/fix-otel-stop-error-log

fix: stop otel deps application in terminate crashed
This commit is contained in:
zhongwencool 2023-08-24 06:40:24 +08:00 committed by GitHub
commit f72ba6819f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View File

@ -17,7 +17,7 @@
-module(emqx_otel).
-include_lib("emqx/include/logger.hrl").
-export([start_link/1]).
-export([start_link/1, cleanup/0]).
-export([get_cluster_gauge/1, get_stats_gauge/1, get_vm_gauge/1, get_metric_counter/1]).
-export([init/1, handle_continue/2, handle_call/3, handle_cast/2, handle_info/2, terminate/2]).
@ -25,7 +25,6 @@ start_link(Conf) ->
gen_server:start_link({local, ?MODULE}, ?MODULE, Conf, []).
init(Conf) ->
erlang:process_flag(trap_exit, true),
{ok, #{}, {continue, {setup, Conf}}}.
handle_continue({setup, Conf}, State) ->
@ -42,7 +41,6 @@ handle_info(_Msg, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
cleanup(),
ok.
setup(Conf = #{enable := true}) ->

View File

@ -42,6 +42,7 @@ start_otel(Conf) ->
-spec stop_otel() -> ok | {error, term()}.
stop_otel() ->
ok = emqx_otel:cleanup(),
case supervisor:terminate_child(?MODULE, ?WORKER) of
ok -> supervisor:delete_child(?MODULE, ?WORKER);
{error, not_found} -> ok;