Merge pull request #11498 from zhongwencool/fix-otel-stop-error-log
fix: stop otel deps application in terminate crashed
This commit is contained in:
commit
f72ba6819f
|
@ -17,7 +17,7 @@
|
||||||
-module(emqx_otel).
|
-module(emqx_otel).
|
||||||
-include_lib("emqx/include/logger.hrl").
|
-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([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]).
|
-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, []).
|
gen_server:start_link({local, ?MODULE}, ?MODULE, Conf, []).
|
||||||
|
|
||||||
init(Conf) ->
|
init(Conf) ->
|
||||||
erlang:process_flag(trap_exit, true),
|
|
||||||
{ok, #{}, {continue, {setup, Conf}}}.
|
{ok, #{}, {continue, {setup, Conf}}}.
|
||||||
|
|
||||||
handle_continue({setup, Conf}, State) ->
|
handle_continue({setup, Conf}, State) ->
|
||||||
|
@ -42,7 +41,6 @@ handle_info(_Msg, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
terminate(_Reason, _State) ->
|
terminate(_Reason, _State) ->
|
||||||
cleanup(),
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
setup(Conf = #{enable := true}) ->
|
setup(Conf = #{enable := true}) ->
|
||||||
|
|
|
@ -42,6 +42,7 @@ start_otel(Conf) ->
|
||||||
|
|
||||||
-spec stop_otel() -> ok | {error, term()}.
|
-spec stop_otel() -> ok | {error, term()}.
|
||||||
stop_otel() ->
|
stop_otel() ->
|
||||||
|
ok = emqx_otel:cleanup(),
|
||||||
case supervisor:terminate_child(?MODULE, ?WORKER) of
|
case supervisor:terminate_child(?MODULE, ?WORKER) of
|
||||||
ok -> supervisor:delete_child(?MODULE, ?WORKER);
|
ok -> supervisor:delete_child(?MODULE, ?WORKER);
|
||||||
{error, not_found} -> ok;
|
{error, not_found} -> ok;
|
||||||
|
|
Loading…
Reference in New Issue