chore(emqx_opentelemetry): remove unused `event` functionality
This commit is contained in:
parent
bce35b2dd8
commit
24db03a7df
|
@ -25,8 +25,6 @@
|
||||||
|
|
||||||
-callback end_trace_send(emqx_types:packet() | [emqx_types:packet()]) -> ok.
|
-callback end_trace_send(emqx_types:packet() | [emqx_types:packet()]) -> ok.
|
||||||
|
|
||||||
-callback event(EventName :: term(), Attributes :: term()) -> ok.
|
|
||||||
|
|
||||||
-type channel_info() :: #{atom() => _}.
|
-type channel_info() :: #{atom() => _}.
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
|
@ -35,9 +33,7 @@
|
||||||
unregister_provider/1,
|
unregister_provider/1,
|
||||||
trace_process_publish/3,
|
trace_process_publish/3,
|
||||||
start_trace_send/2,
|
start_trace_send/2,
|
||||||
end_trace_send/1,
|
end_trace_send/1
|
||||||
event/1,
|
|
||||||
event/2
|
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export_type([channel_info/0]).
|
-export_type([channel_info/0]).
|
||||||
|
@ -79,6 +75,7 @@ unregister_provider(Module) ->
|
||||||
-spec provider() -> module() | undefined.
|
-spec provider() -> module() | undefined.
|
||||||
provider() ->
|
provider() ->
|
||||||
persistent_term:get(?PROVIDER, undefined).
|
persistent_term:get(?PROVIDER, undefined).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% trace API
|
%% trace API
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -99,13 +96,6 @@ start_trace_send(Delivers, ChannelInfo) ->
|
||||||
end_trace_send(Packets) ->
|
end_trace_send(Packets) ->
|
||||||
?with_provider(?FUNCTION_NAME(Packets), ok).
|
?with_provider(?FUNCTION_NAME(Packets), ok).
|
||||||
|
|
||||||
event(Name) ->
|
|
||||||
event(Name, #{}).
|
|
||||||
|
|
||||||
-spec event(term(), term()) -> ok.
|
|
||||||
event(Name, Attributes) ->
|
|
||||||
?with_provider(?FUNCTION_NAME(Name, Attributes), ok).
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -28,8 +28,7 @@
|
||||||
-export([
|
-export([
|
||||||
trace_process_publish/3,
|
trace_process_publish/3,
|
||||||
start_trace_send/2,
|
start_trace_send/2,
|
||||||
end_trace_send/1,
|
end_trace_send/1
|
||||||
event/2
|
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-include_lib("emqx/include/emqx.hrl").
|
||||||
|
@ -37,7 +36,6 @@
|
||||||
-include_lib("opentelemetry_api/include/otel_tracer.hrl").
|
-include_lib("opentelemetry_api/include/otel_tracer.hrl").
|
||||||
|
|
||||||
-define(EMQX_OTEL_CTX, otel_ctx).
|
-define(EMQX_OTEL_CTX, otel_ctx).
|
||||||
-define(IS_ENABLED, emqx_enable).
|
|
||||||
-define(USER_PROPERTY, 'User-Property').
|
-define(USER_PROPERTY, 'User-Property').
|
||||||
|
|
||||||
-define(TRACE_ALL_KEY, {?MODULE, trace_all}).
|
-define(TRACE_ALL_KEY, {?MODULE, trace_all}).
|
||||||
|
@ -103,12 +101,11 @@ trace_process_publish(Packet, ChannelInfo, ProcessFun) ->
|
||||||
false ->
|
false ->
|
||||||
ProcessFun(Packet);
|
ProcessFun(Packet);
|
||||||
RootCtx ->
|
RootCtx ->
|
||||||
RootCtx1 = otel_ctx:set_value(RootCtx, ?IS_ENABLED, true),
|
|
||||||
Attrs = maps:merge(packet_attributes(Packet), channel_attributes(ChannelInfo)),
|
Attrs = maps:merge(packet_attributes(Packet), channel_attributes(ChannelInfo)),
|
||||||
SpanCtx = otel_tracer:start_span(RootCtx1, ?current_tracer, process_message, #{
|
SpanCtx = otel_tracer:start_span(RootCtx, ?current_tracer, process_message, #{
|
||||||
attributes => Attrs
|
attributes => Attrs
|
||||||
}),
|
}),
|
||||||
Ctx = otel_tracer:set_current_span(RootCtx1, SpanCtx),
|
Ctx = otel_tracer:set_current_span(RootCtx, SpanCtx),
|
||||||
%% put ctx to packet, so it can be further propagated
|
%% put ctx to packet, so it can be further propagated
|
||||||
Packet1 = put_ctx_to_packet(Ctx, Packet),
|
Packet1 = put_ctx_to_packet(Ctx, Packet),
|
||||||
_ = otel_ctx:attach(Ctx),
|
_ = otel_ctx:attach(Ctx),
|
||||||
|
@ -159,17 +156,6 @@ end_trace_send(Packets) ->
|
||||||
packets_list(Packets)
|
packets_list(Packets)
|
||||||
).
|
).
|
||||||
|
|
||||||
%% NOTE: adds an event only within an active span (Otel Ctx must be set in the calling process dict)
|
|
||||||
-spec event(opentelemetry:event_name(), opentelemetry:attributes_map()) -> ok.
|
|
||||||
event(Name, Attributes) ->
|
|
||||||
case otel_ctx:get_value(?IS_ENABLED, false) of
|
|
||||||
true ->
|
|
||||||
?add_event(Name, Attributes),
|
|
||||||
ok;
|
|
||||||
false ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue