commit | 3348a523d26f6040c904a84eda00959b8f62c997 | [log] [tgz] |
---|---|---|
author | Takeru Ohta <phjgt308@gmail.com> | Tue Oct 24 05:18:48 2017 +0900 |
committer | Takeru Ohta <phjgt308@gmail.com> | Tue Oct 24 05:18:48 2017 +0900 |
tree | 0a86ccaf3ff90c12b3684d948420ab63bfbaf968 | |
parent | 2d422ed23a78e8ea6ad9754e735ea6d5c151b49a [diff] |
Update README.md
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_root_span(example_root, 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_root_span(example_root, 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}}, {eval_tags, #{size => "byte_size(Bin)"}}]). -spec foo(binary()) -> binary(). foo(Bin) -> <<"foo", Bin/binary>>.
The above foo function will be transformed as follows:
foo(Bin) -> try passage_pd:start_span(foo, [{tags, #{application => example, module => example}}]), passage_pd:set_tags(#{process => self(), size => byte_size(Bin)}), <<"foo", Bin/binary>> after passage_pd:finish_span() end.