commit | 9f2fc2934f97cbe342df3b2e6f8fa769deaffbda | [log] [tgz] |
---|---|---|
author | Nick Vatamaniuc <nickva@users.noreply.github.com> | Fri May 14 14:47:12 2021 -0400 |
committer | GitHub <noreply@github.com> | Fri May 14 14:47:12 2021 -0400 |
tree | b4921790dbaecd37a9d105eebee039997ec03bfc | |
parent | 2bbc1847e172e28c766fcc62fb66f6643fb52679 [diff] | |
parent | 8e7455e453c8a19dfcc7b0f3787644027988f000 [diff] |
Merge pull request #1 from apache/skip-parse-transform-for-erlang-24-compat Skip compiling example file as it's failing on Erlang 24
OpenTracing 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' -compile({passage_default_tracer, "foo_tracer"}). % Specifies the default tracer (optional) -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.