Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sile/passage
OpenTracing API for Erlang
https://github.com/sile/passage
erlang opentracing
Last synced: 6 days ago
JSON representation
OpenTracing API for Erlang
- Host: GitHub
- URL: https://github.com/sile/passage
- Owner: sile
- License: mit
- Created: 2017-10-20T14:41:35.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-25T13:48:46.000Z (almost 6 years ago)
- Last Synced: 2024-09-23T02:48:15.197Z (about 2 months ago)
- Topics: erlang, opentracing
- Language: Erlang
- Homepage:
- Size: 83 KB
- Stars: 5
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
passage
=======[![hex.pm version](https://img.shields.io/hexpm/v/passage.svg)](https://hex.pm/packages/passage)
[![Build Status](https://travis-ci.org/sile/passage.svg?branch=master)](https://travis-ci.org/sile/passage)
[![Code Coverage](https://codecov.io/gh/sile/passage/branch/master/graph/badge.svg)](https://codecov.io/gh/sile/passage/branch/master)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)[OpenTracing](http://opentracing.io/) API for Erlang
[Documentation](https://hexdocs.pm/passage/)
Examples
---------```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.
```### Process Dictionary Version
```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
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.
```### Parse Transform
```erlang
-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:
```erlang
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.
```References
------------ [The OpenTracing Semantic Specification(v1.1)](https://github.com/opentracing/specification/blob/1.1/specification.md)