commit | 530d6abc3aecec3403293a1600f42ef00806002f | [log] [tgz] |
---|---|---|
author | Takeru Ohta <phjgt308@gmail.com> | Fri Dec 15 16:48:14 2017 +0900 |
committer | Takeru Ohta <phjgt308@gmail.com> | Fri Dec 15 16:48:14 2017 +0900 |
tree | 69db43e1dc6f48afb21c4542f60e755ddb15c8a8 | |
parent | 467a78344b6fe3045a1c11dad4eb655d3e0f9e71 [diff] |
v0.2.3
OpenTraceing API for Erlang
%% Registers `tracer` Context = passage_span_context_null, Sampler = passage_sampler_all:new(), Reporter = passage_reporter_process:new(self(), span), ok = passage_tracer_registry:register(tracer, Context, Sampler, Reporter), %% Starts a root span RootSpan = passage:start_span(example_root, [{tracer, tracer}]), %% Starts a child span ChildSpan = passage:start_span(example_child, [{child_of, RootSpan}]), %% Finishes spans passage:finish_span(ChildSpan), passage:finish_span(RootSpan), %% Receives the finished spans receive {span, FinishedChildSpan} -> ok end, receive {span, FinishedRootSpan} -> ok end.
%% Registers `tracer` Context = passage_span_context_null, Sampler = passage_sampler_all:new(), Reporter = passage_reporter_process:new(self(), span), ok = passage_tracer_registry:register(tracer, Context, Sampler, Reporter), %% Starts a root span ok = passage_pd:start_span(example_root, [{tracer, tracer}]), %% Starts a child span ok = passage_pd:start_span(example_child), %% Finishes spans passage_pd:finish_span(), % child passage_pd:finish_span(), % root %% Receives the finished spans receive {span, FinishedChildSpan} -> ok end, receive {span, FinishedRootSpan} -> ok end.
-module(example). -compile({parse_transform, passage_transform}). % Enables `passage_transform' -passage_trace([{tags, #{foo => "bar", size => "byte_size(Bin)"}}]). -spec foo(binary()) -> binary(). foo(Bin) -> <<"foo", Bin/binary>>.
The above foo
function will be transformed as follows:
foo(Bin) -> passage_pd:start_span('example:foo/1', []), try passage_pd:set_tags( fun () -> #{ 'location.pid' => self(), 'location.application' => example, 'location.module' => example, 'location.line' => 7 foo => bar, size => byte_size(Bin) } end), <<"foo", Bin/binary>> after passage_pd:finish_span() end.