sile / jaeger_passage

@@ -0,0 +1,160 @@
Loading
1 +
%% @doc A reporter that sends the spans to an jaeger agent
2 +
%%
3 +
%% === Examples ===
4 +
%%
5 +
%% ```
6 +
%% %% Starts `example_reporter'
7 +
%% {ok, Reporter} = jaeger_passage_reporter:start(example_reporter, [{protocol, udp}]).
8 +
%% [example_reporter] = jaeger_passage_reporter:which_reporters().
9 +
%%
10 +
%% %% Registers `example_tracer'
11 +
%% Context = jaeger_passage_span_context.
12 +
%% Sampler = passage_sampler_all:new().
13 +
%% ok = passage_tracer_registry:register(example_tracer, Context, Sampler, Reporter).
14 +
%%
15 +
%% %% Starts and finishes a span
16 +
%% Span = passage:start_span(example, [{tracer, example_tracer}]).
17 +
%%
18 +
%% passage:finish_span(Span). % The span will send to the jaeger agent on the localhost
19 +
%% '''
20 +
%%
21 +
%% === Refereces ===
22 +
%%
23 +
%% <ul>
24 +
%% <li><a href="http://jaeger.readthedocs.io/en/latest/architecture/#agent">Jaeger - Architecture - Agent</a></li>
25 +
%% <li><a href="http://jaeger.readthedocs.io/en/latest/deployment/#agent">Jaeger - Deployment - Agent</a></li>
26 +
%% </ul>
27 +
-module(jaeger_passage_reporter_udp).
28 +
29 +
-behaviour(gen_server).
30 +
31 +
-include("constants.hrl").
32 +
33 +
%%------------------------------------------------------------------------------
34 +
%% Exported API
35 +
%%------------------------------------------------------------------------------
36 +
-export_type([start_option/0, start_options/0]).
37 +
38 +
%%------------------------------------------------------------------------------
39 +
%% Application Internal API
40 +
%%------------------------------------------------------------------------------
41 +
-export([start_link/2]).
42 +
43 +
%%------------------------------------------------------------------------------
44 +
%% 'gen_server' Callback API
45 +
%%------------------------------------------------------------------------------
46 +
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
47 +
48 +
%%------------------------------------------------------------------------------
49 +
%% Macros & Records
50 +
%%------------------------------------------------------------------------------
51 +
-define(STATE, ?MODULE).
52 +
53 +
-record(?STATE,
54 +
        {
55 +
          socket               :: gen_udp:socket(),
56 +
          thrift_format        :: thrift_protocol:format(),
57 +
          agent_host           :: inet:hostname(),
58 +
          agent_port           :: inet:port_number(),
59 +
          default_service_name :: atom(),
60 +
          process_tags         :: passage:tags()
61 +
        }).
62 +
63 +
%%------------------------------------------------------------------------------
64 +
%% Exported Types
65 +
%%------------------------------------------------------------------------------
66 +
67 +
-type start_options() :: [start_option()].
68 +
%% Options for {@link start/2}.
69 +
70 +
-type start_option() :: {thrift_format, thrift_protocol:format()}
71 +
                      | {agent_host, inet:hostname()}
72 +
                      | {agent_port, inet:port_number()}.
73 +
%% <ul>
74 +
%%   <li><b>thrift_format</b>: The format for encoding thrift messages. The default value is `compact'.</li>
75 +
%%   <li><b>agent_host</b>: The hostname of the jaeger agent. The default value is `"127.0.0.1"'.</li>
76 +
%%   <li><b>agent_port</b>: The port of the jaeger agent. The default values for the thrift format `compact' and `binary' are `6831' and `6832' respectively.</li>
77 +
%%   <li><b>default_service_name</b>: The default service name. If a reporting span has `location.application' tag, the value is used as the service name instead of this. The default value is `ReporterId'.</li>
78 +
%%   <li><b>process_tags</b>: The tags of the reporting process. The default value is `#{}'.</li>
79 +
%% </ul>
80 +
81 +
%%------------------------------------------------------------------------------
82 +
%% Application Internal Functions
83 +
%%------------------------------------------------------------------------------
84 +
%% @private
85 +
-spec start_link(jaeger_passage_reporter:reporter_id(), start_options()) -> {ok, pid()} | {error, Reason} when
86 +
      Reason :: {already_started, pid()} | term().
87 +
start_link(ReporterId, Options) ->
88 +
    Name = jaeger_passage_local_ns:reporter_name(ReporterId),
89 +
    gen_server:start_link(Name, ?MODULE, {ReporterId, Options}, []).
90 +
91 +
%%------------------------------------------------------------------------------
92 +
%% 'gen_server' Callback Functions
93 +
%%------------------------------------------------------------------------------
94 +
%% @private
95 +
init({ReporterId, Options}) ->
96 +
    Format = proplists:get_value(thrift_format, Options, compact),
97 +
    DefaultPort =
98 +
        case Format of
99 +
            compact -> 6831;
100 +
            binary  -> 6832
101 +
        end,
102 +
    AgentHost = proplists:get_value(agent_host, Options, "127.0.0.1"),
103 +
    AgentPort = proplists:get_value(agent_port, Options, DefaultPort),
104 +
    DefaultServiceName = proplists:get_value(default_service_name, Options, ReporterId),
105 +
    Tags0 = proplists:get_value(process_tags, Options, #{}),
106 +
107 +
    {ok, Hostname} = inet:gethostname(),
108 +
    {ok, Version} = application:get_key(vsn),
109 +
    Tags1 =
110 +
        maps:merge(
111 +
          Tags0,
112 +
          #{
113 +
            ?JAEGER_CLIENT_VERSION_TAG_KEY => list_to_binary(["jaeger_passage-", Version]),
114 +
            ?TRACER_HOSTNAME_TAG_KEY => list_to_binary(Hostname),
115 +
            'erlang.node' => node()
116 +
           }),
117 +
    {ok, Socket} = gen_udp:open(0),
118 +
    State =
119 +
        #?STATE{
120 +
            socket        = Socket,
121 +
            thrift_format = Format,
122 +
            agent_host    = AgentHost,
123 +
            agent_port    = AgentPort,
124 +
            default_service_name  = DefaultServiceName,
125 +
            process_tags  = Tags1
126 +
           },
127 +
    {ok, State}.
128 +
129 +
%% @private
130 +
handle_call(_Request, _From, State) ->
131 +
    {noreply, State}.
132 +
133 +
%% @private
134 +
handle_cast({report, Span}, State) ->
135 +
    handle_report(Span, State);
136 +
handle_cast(_Request, State) ->
137 +
    {noreply, State}.
138 +
139 +
%% @private
140 +
handle_info(_Info, State) ->
141 +
    {noreply, State}.
142 +
143 +
%% @private
144 +
terminate(_Reason, _State) ->
145 +
    ok.
146 +
147 +
%% @private
148 +
code_change(_OldVsn, State, _Extra) ->
149 +
    {ok, State}.
150 +
151 +
%%------------------------------------------------------------------------------
152 +
%% Internal Functions
153 +
%%------------------------------------------------------------------------------
154 +
-spec handle_report(passage_span:span(), #?STATE{}) -> {noreply, #?STATE{}}.
155 +
handle_report(Span, State = #?STATE{default_service_name = DefaultName, process_tags = Tags}) ->
156 +
    Name = maps:get('location.application', passage_span:get_tags(Span), DefaultName),
157 +
    Message = jaeger_passage_thrift:make_emit_batch_message(Name, Tags, [Span]),
158 +
    Encoded = thrift_protocol:encode_message(Message, State#?STATE.thrift_format),
159 +
    ok = gen_udp:send(State#?STATE.socket, State#?STATE.agent_host, State#?STATE.agent_port, Encoded),
160 +
    {noreply, State}.

@@ -0,0 +1,185 @@
Loading
1 +
%% @doc A reporter that sends the spans to an jaeger agent
2 +
%%
3 +
%% === Examples ===
4 +
%%
5 +
%% ```
6 +
%% %% Starts `example_reporter'
7 +
%% {ok, Reporter} = jaeger_passage_reporter:start(example_reporter, [{protocol, http}]).
8 +
%% [example_reporter] = jaeger_passage_reporter:which_reporters().
9 +
%%
10 +
%% %% Registers `example_tracer'
11 +
%% Context = jaeger_passage_span_context.
12 +
%% Sampler = passage_sampler_all:new().
13 +
%% ok = passage_tracer_registry:register(example_tracer, Context, Sampler, Reporter).
14 +
%%
15 +
%% %% Starts and finishes a span
16 +
%% Span = passage:start_span(example, [{tracer, example_tracer}]).
17 +
%%
18 +
%% passage:finish_span(Span). % The span will send to the jaeger agent on the localhost
19 +
%% '''
20 +
%%
21 +
%% === Refereces ===
22 +
%%
23 +
%% <ul>
24 +
%% <li><a href="http://jaeger.readthedocs.io/en/latest/architecture/#agent">Jaeger - Architecture - Agent</a></li>
25 +
%% <li><a href="http://jaeger.readthedocs.io/en/latest/deployment/#agent">Jaeger - Deployment - Agent</a></li>
26 +
%% </ul>
27 +
-module(jaeger_passage_reporter_http).
28 +
29 +
-behaviour(gen_server).
30 +
31 +
-include("constants.hrl").
32 +
33 +
%%------------------------------------------------------------------------------
34 +
%% Exported API
35 +
%%------------------------------------------------------------------------------
36 +
-export_type([start_option/0, start_options/0]).
37 +
38 +
%%------------------------------------------------------------------------------
39 +
%% Application Internal API
40 +
%%------------------------------------------------------------------------------
41 +
-export([start_link/2]).
42 +
43 +
%%------------------------------------------------------------------------------
44 +
%% 'gen_server' Callback API
45 +
%%------------------------------------------------------------------------------
46 +
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
47 +
48 +
%%------------------------------------------------------------------------------
49 +
%% Macros & Records
50 +
%%------------------------------------------------------------------------------
51 +
-define(STATE, ?MODULE).
52 +
53 +
-record(?STATE,
54 +
        {
55 +
          endpoint             :: string(),
56 +
          options              :: start_options(),
57 +
          http_client          :: http_client(),
58 +
          default_service_name :: atom(),
59 +
          process_tags         :: passage:tags()
60 +
        }).
61 +
62 +
-define(CONTENT_TYPE, {"Content-Type", "application/x-thrift"}).
63 +
64 +
%%------------------------------------------------------------------------------
65 +
%% Exported Types
66 +
%%------------------------------------------------------------------------------
67 +
68 +
-type start_options() :: [start_option()].
69 +
%% Options for {@link start/2}.
70 +
71 +
-type start_option() :: {endpoint, string()}
72 +
                      | {http_client, http_client()}
73 +
                      | {default_service_name, atom()}
74 +
                      | {process_tags, passage:tags()}.
75 +
%% <ul>
76 +
%%   <li><b>endpoint</b>: The jaeger endpoint URL for sending thrift messages. The default value is `http://127.0.0.1:14268'.</li>
77 +
%%   <li><b>http_client</b>: The callback to call to send span to jaeger. The httpc client is used by default.</li>
78 +
%%   <li><b>default_service_name</b>: The default service name. If a reporting span has `location.application' tag, the value is used as the service name instead of this. The default value is `ReporterId'.</li>
79 +
%%   <li><b>process_tags</b>: The tags of the reporting process. The default value is `#{}'.</li>
80 +
%% </ul>
81 +
%% Example of a http_client calback
82 +
%% Client = fun(Url, Method, Headers, Body, ReporterOptions) ->
83 +
%%    User = proplists:get_value(user, ReporterOptions),
84 +
%%    Password = proplists:get_value(password, ReporterOptions),
85 +
%%    ibrowse:send_req(Url, Headers, Method, Body, [{basic_auth, {User,  Password}}])
86 +
%% end.
87 +
88 +
89 +
-type http_client() :: fun((
90 +
        Url    :: string(),
91 +
        Method :: post,
92 +
        Headers :: [{string(), string()}],
93 +
        Body :: string() | binary(),
94 +
        ReporterOptions :: start_options()) ->
95 +
    ok).
96 +
97 +
%%------------------------------------------------------------------------------
98 +
%% Application Internal Functions
99 +
%%------------------------------------------------------------------------------
100 +
%% @private
101 +
-spec start_link(jaeger_passage_reporter:reporter_id(), start_options()) -> {ok, pid()} | {error, Reason} when
102 +
      Reason :: {already_started, pid()} | term().
103 +
start_link(ReporterId, Options) ->
104 +
    Name = jaeger_passage_local_ns:reporter_name(ReporterId),
105 +
    gen_server:start_link(Name, ?MODULE, {ReporterId, Options}, []).
106 +
107 +
%%------------------------------------------------------------------------------
108 +
%% 'gen_server' Callback Functions
109 +
%%------------------------------------------------------------------------------
110 +
%% @private
111 +
init({ReporterId, Options}) ->
112 +
    Endpoint = proplists:get_value(endpoint, Options, "http://127.0.0.1:14268"),
113 +
    EndpointURL = Endpoint ++ "/api/traces",
114 +
115 +
    HttpClient = proplists:get_value(http_client, Options, fun httpc_client/5),
116 +
    is_function(HttpClient, 5) orelse error(badarg, [ReporterId, Options]),
117 +
118 +
    DefaultServiceName = proplists:get_value(default_service_name, Options, ReporterId),
119 +
    Tags0 = proplists:get_value(process_tags, Options, #{}),
120 +
121 +
    {ok, Hostname} = inet:gethostname(),
122 +
    {ok, Version} = application:get_key(vsn),
123 +
    Tags1 =
124 +
        maps:merge(
125 +
          Tags0,
126 +
          #{
127 +
            ?JAEGER_CLIENT_VERSION_TAG_KEY => list_to_binary(["jaeger_passage-", Version]),
128 +
            ?TRACER_HOSTNAME_TAG_KEY => list_to_binary(Hostname),
129 +
            'erlang.node' => node()
130 +
           }),
131 +
    State =
132 +
        #?STATE{
133 +
            endpoint              = EndpointURL,
134 +
            http_client           = HttpClient,
135 +
            options               = Options,
136 +
            default_service_name  = DefaultServiceName,
137 +
            process_tags          = Tags1
138 +
           },
139 +
    {ok, State}.
140 +
141 +
%% @private
142 +
handle_call(_Request, _From, State) ->
143 +
    {noreply, State}.
144 +
145 +
%% @private
146 +
handle_cast({report, Span}, State) ->
147 +
    handle_report(Span, State);
148 +
handle_cast(_Request, State) ->
149 +
    {noreply, State}.
150 +
151 +
%% @private
152 +
handle_info(_Info, State) ->
153 +
    {noreply, State}.
154 +
155 +
%% @private
156 +
terminate(_Reason, _State) ->
157 +
    ok.
158 +
159 +
%% @private
160 +
code_change(_OldVsn, State, _Extra) ->
161 +
    {ok, State}.
162 +
163 +
%%------------------------------------------------------------------------------
164 +
%% Internal Functions
165 +
%%------------------------------------------------------------------------------
166 +
-spec handle_report(passage_span:span(), #?STATE{}) -> {noreply, #?STATE{}}.
167 +
handle_report(Span, State = #?STATE{default_service_name = DefaultName, process_tags = Tags, endpoint = URI, http_client = HttpClient, options = Options}) ->
168 +
    Name = maps:get('location.application', passage_span:get_tags(Span), DefaultName),
169 +
    Message = jaeger_passage_thrift:make_batch(Name, Tags, [Span]),
170 +
    Encoded = thrift_protocol:encode_struct(Message, binary),
171 +
    Headers = [?CONTENT_TYPE],
172 +
    HttpClient(URI, post, Headers, Encoded, Options),
173 +
    {noreply, State}.
174 +
175 +
-spec httpc_client(
176 +
        Url    :: string(),
177 +
        Method :: post,
178 +
        Headers :: [{string(), string()}],
179 +
        Body :: string() | binary(),
180 +
        ReporterOptions :: start_options()) ->
181 +
    ok.
182 +
183 +
httpc_client(Url, Method, _Headers, Body, _ReporterOptions) ->
184 +
    httpc:request(Method, {Url, [], "application/x-thrift", Body}, [], []),
185 +
    ok.

@@ -33,7 +33,7 @@
Loading
33 33
      Tracer :: passage:tracer_id(),
34 34
      Sampler :: passage_sampler:sampler().
35 35
start_tracer(Tracer, Sampler) ->
36 -
    start_tracer(Tracer, Sampler, []).
36 +
    start_tracer(Tracer, Sampler, [{protocol, udp}]).
37 37
38 38
%% @doc Starts a tracer for Jaeger.
39 39
%%

@@ -29,7 +29,6 @@
Loading
29 29
-module(jaeger_passage_reporter).
30 30
31 31
-behaviour(passage_reporter).
32 -
-behaviour(gen_server).
33 32
34 33
-include("constants.hrl").
35 34
@@ -44,36 +43,11 @@
Loading
44 43
-export_type([reporter_id/0]).
45 44
-export_type([start_option/0, start_options/0]).
46 45
47 -
%%------------------------------------------------------------------------------
48 -
%% Application Internal API
49 -
%%------------------------------------------------------------------------------
50 -
-export([start_link/2]).
51 -
52 46
%%------------------------------------------------------------------------------
53 47
%% 'passage_reporter' Callback API
54 48
%%------------------------------------------------------------------------------
55 49
-export([report/2]).
56 50
57 -
%%------------------------------------------------------------------------------
58 -
%% 'gen_server' Callback API
59 -
%%------------------------------------------------------------------------------
60 -
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
61 -
62 -
%%------------------------------------------------------------------------------
63 -
%% Macros & Records
64 -
%%------------------------------------------------------------------------------
65 -
-define(STATE, ?MODULE).
66 -
67 -
-record(?STATE,
68 -
        {
69 -
          socket               :: gen_udp:socket(),
70 -
          thrift_format        :: thrift_protocol:format(),
71 -
          agent_host           :: inet:hostname(),
72 -
          agent_port           :: inet:port_number(),
73 -
          default_service_name :: atom(),
74 -
          process_tags         :: passage:tags()
75 -
        }).
76 -
77 51
%%------------------------------------------------------------------------------
78 52
%% Exported Types
79 53
%%------------------------------------------------------------------------------
@@ -83,28 +57,28 @@
Loading
83 57
-type start_options() :: [start_option()].
84 58
%% Options for {@link start/2}.
85 59
86 -
-type start_option() :: {thrift_format, thrift_protocol:format()}
87 -
                      | {agent_host, inet:hostname()}
88 -
                      | {agent_port, inet:port_number()}
60 +
-type start_option() :: jaeger_passage_reporter_udp:start_option()
61 +
                      | jaeger_passage_reporter_http:start_option()
62 +
                      | {protocol, udp | http}
89 63
                      | {default_service_name, atom()}
90 64
                      | {process_tags, passage:tags()}.
65 +
66 +
%% Common reporter options
67 +
%% <ul>
68 +
%%   <li><b>protocol</b>: Communication protocol used to connect to jaeger. The value is used to select reporter module. Possible values are: `udp' | `http'. The default value is `udp'.</li>
69 +
%%   <li><b>default_service_name</b>: The default service name. If a reporting span has `location.application' tag, the value is used as the service name instead of this. The default value is `ReporterId'.</li>
70 +
%%   <li><b>process_tags</b>: The tags of the reporting process. The default value is `#{}'.</li>
71 +
%% </ul>
72 +
%% UDP reporter specific options
91 73
%% <ul>
92 74
%%   <li><b>thrift_format</b>: The format for encoding thrift messages. The default value is `compact'.</li>
93 75
%%   <li><b>agent_host</b>: The hostname of the jaeger agent. The default value is `"127.0.0.1"'.</li>
94 76
%%   <li><b>agent_port</b>: The port of the jaeger agent. The default values for the thrift format `compact' and `binary' are `6831' and `6832' respectively.</li>
95 -
%%   <li><b>default_service_name</b>: The default service name. If a reporting span has `location.application' tag, the value is used as the service name instead of this. The default value is `ReporterId'.</li>
96 -
%%   <li><b>process_tags</b>: The tags of the reporting process. The default value is `#{}'.</li>
97 77
%% </ul>
98 -
99 -
%%------------------------------------------------------------------------------
100 -
%% Application Internal Functions
101 -
%%------------------------------------------------------------------------------
102 -
%% @private
103 -
-spec start_link(reporter_id(), start_options()) -> {ok, pid()} | {error, Reason} when
104 -
      Reason :: {already_started, pid()} | term().
105 -
start_link(ReporterId, Options) ->
106 -
    Name = jaeger_passage_local_ns:reporter_name(ReporterId),
107 -
    gen_server:start_link(Name, ?MODULE, {ReporterId, Options}, []).
78 +
%% HTTP reporter specific options
79 +
%% <ul>
80 +
%%   <li><b>endpoint</b>: The jaeger endpoint URL for sending thrift messages. The default value is `http://127.0.0.1:14268'.</li>
81 +
%% </ul>
108 82
109 83
%%------------------------------------------------------------------------------
110 84
%% Exported Functions
@@ -113,7 +87,7 @@
Loading
113 87
-spec start(reporter_id()) -> {ok, passage_reporter:reporter()} | {error, Reason} when
114 88
      Reason :: {already_started, pid()} | term().
115 89
start(ReporterId) ->
116 -
    start(ReporterId, []).
90 +
    start(ReporterId, [{protocol, udp}]).
117 91
118 92
%% @doc Starts a reporter process.
119 93
-spec start(reporter_id(), start_options()) -> {ok, Reporter} | {error, Reason} when
@@ -123,8 +97,13 @@
Loading
123 97
    Args = [ReporterId, Options],
124 98
    is_atom(ReporterId) orelse error(badarg, Args),
125 99
    is_list(Options) orelse error(badarg, Args),
126 -
127 -
    case jaeger_passage_reporter_sup:start_child(ReporterId, Options) of
100 +
    ReporterModule = case proplists:get_value(protocol, Options, udp) of
101 +
        udp -> jaeger_passage_reporter_udp;
102 +
        http -> jaeger_passage_reporter_http;
103 +
        _ -> error(badarg, Args)
104 +
    end,
105 +
    ReporterOptions = proplists:delete(protocol, Options),
106 +
    case jaeger_passage_reporter_sup:start_child(ReporterId, ReporterModule, ReporterOptions) of
128 107
        {error, Reason} -> {error, Reason};
129 108
        {ok, _Pid}      -> {ok, passage_reporter:new(?MODULE, ReporterId)}
130 109
    end.
@@ -158,74 +137,3 @@
Loading
158 137
report(ReporterId, Span) ->
159 138
    Server = jaeger_passage_local_ns:reporter_name(ReporterId),
160 139
    gen_server:cast(Server, {report, Span}).
161 -
162 -
%%------------------------------------------------------------------------------
163 -
%% 'gen_server' Callback Functions
164 -
%%------------------------------------------------------------------------------
165 -
%% @private
166 -
init({ReporterId, Options}) ->
167 -
    Format = proplists:get_value(thrift_format, Options, compact),
168 -
    DefaultPort =
169 -
        case Format of
170 -
            compact -> 6831;
171 -
            binary  -> 6832
172 -
        end,
173 -
    AgentHost = proplists:get_value(agent_host, Options, "127.0.0.1"),
174 -
    AgentPort = proplists:get_value(agent_port, Options, DefaultPort),
175 -
    DefaultServiceName = proplists:get_value(default_service_name, Options, ReporterId),
176 -
    Tags0 = proplists:get_value(process_tags, Options, #{}),
177 -
178 -
    {ok, Hostname} = inet:gethostname(),
179 -
    {ok, Version} = application:get_key(vsn),
180 -
    Tags1 =
181 -
        maps:merge(
182 -
          Tags0,
183 -
          #{
184 -
            ?JAEGER_CLIENT_VERSION_TAG_KEY => list_to_binary(["jaeger_passage-", Version]),
185 -
            ?TRACER_HOSTNAME_TAG_KEY => list_to_binary(Hostname),
186 -
            'erlang.node' => node()
187 -
           }),
188 -
    {ok, Socket} = gen_udp:open(0),
189 -
    State =
190 -
        #?STATE{
191 -
            socket        = Socket,
192 -
            thrift_format = Format,
193 -
            agent_host    = AgentHost,
194 -
            agent_port    = AgentPort,
195 -
            default_service_name  = DefaultServiceName,
196 -
            process_tags  = Tags1
197 -
           },
198 -
    {ok, State}.
199 -
200 -
%% @private
201 -
handle_call(_Request, _From, State) ->
202 -
    {noreply, State}.
203 -
204 -
%% @private
205 -
handle_cast({report, Span}, State) ->
206 -
    handle_report(Span, State);
207 -
handle_cast(_Request, State) ->
208 -
    {noreply, State}.
209 -
210 -
%% @private
211 -
handle_info(_Info, State) ->
212 -
    {noreply, State}.
213 -
214 -
%% @private
215 -
terminate(_Reason, _State) ->
216 -
    ok.
217 -
218 -
%% @private
219 -
code_change(_OldVsn, State, _Extra) ->
220 -
    {ok, State}.
221 -
222 -
%%------------------------------------------------------------------------------
223 -
%% Internal Functions
224 -
%%------------------------------------------------------------------------------
225 -
-spec handle_report(passage_span:span(), #?STATE{}) -> {noreply, #?STATE{}}.
226 -
handle_report(Span, State = #?STATE{default_service_name = DefaultName, process_tags = Tags}) ->
227 -
    Name = maps:get('location.application', passage_span:get_tags(Span), DefaultName),
228 -
    Message = jaeger_passage_thrift:make_emit_batch_message(Name, Tags, [Span]),
229 -
    Encoded = thrift_protocol:encode_message(Message, State#?STATE.thrift_format),
230 -
    ok = gen_udp:send(State#?STATE.socket, State#?STATE.agent_host, State#?STATE.agent_port, Encoded),
231 -
    {noreply, State}.

@@ -15,7 +15,7 @@
Loading
15 15
%%------------------------------------------------------------------------------
16 16
%% Application Internal API
17 17
%%------------------------------------------------------------------------------
18 -
-export([make_emit_batch_message/3]).
18 +
-export([make_emit_batch_message/3, make_batch/3]).
19 19
20 20
%%------------------------------------------------------------------------------
21 21
%% Macros
@@ -49,6 +49,12 @@
Loading
49 49
       body         = ?STRUCT(Batch)
50 50
      }.
51 51
52 +
-spec make_batch(atom(), passage:tags(), [passage_span:span()]) ->
53 +
                                     thrift_protocol:struct().
54 +
make_batch(ServiceName, ServiceTags, Spans) ->
55 +
    Process = make_process(ServiceName, ServiceTags),
56 +
    ?STRUCT(Process, make_spans(Spans)).
57 +
52 58
%%------------------------------------------------------------------------------
53 59
%% Internal Functions
54 60
%%------------------------------------------------------------------------------

@@ -9,7 +9,7 @@
Loading
9 9
%% Application Internal API
10 10
%%------------------------------------------------------------------------------
11 11
-export([start_link/0]).
12 -
-export([start_child/2]).
12 +
-export([start_child/3]).
13 13
-export([stop_child/1]).
14 14
-export([which_children/0]).
15 15
@@ -25,14 +25,15 @@
Loading
25 25
start_link() ->
26 26
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
27 27
28 -
-spec start_child(ReporterId, Options) -> {ok, pid()} | {error, Reason} when
28 +
-spec start_child(ReporterId, ReporterModule, Options) -> {ok, pid()} | {error, Reason} when
29 29
      ReporterId :: jaeger_passage_reporter:reporter_id(),
30 +
      ReporterModule :: module(),
30 31
      Options :: jaeger_passage_reporter:start_options(),
31 32
      Reason :: {already_started, pid()} | term().
32 -
start_child(ReporterId, Options) ->
33 +
start_child(ReporterId, ReporterModule, Options) ->
33 34
    Child = #{
34 35
      id      => ReporterId,
35 -
      start   => {jaeger_passage_reporter, start_link, [ReporterId, Options]},
36 +
      start   => {ReporterModule, start_link, [ReporterId, Options]},
36 37
      restart => permanent
37 38
     },
38 39
    supervisor:start_child(?MODULE, Child).
Files Coverage
src 85.32%
Project Totals (11 files) 85.32%
74.3
TRAVIS_OS_NAME=linux
74.1
TRAVIS_OS_NAME=linux
74.4
TRAVIS_OS_NAME=linux
74.2
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading