Copyright © 2017 Takeru Ohta <phjgt308@gmail.com>
API for operating active spans.
Most of the functions and types provided in this module are based on the OpenTracing API.
%% 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.
baggage_item_name() = binary()
Baggage item name.
baggage_item_value() = binary()
Baggage item value.
baggage_items() = #{baggage_item_name() => baggage_item_value()}
Baggage items.
Baggage items are just key/value pairs that cross OS process boundaries.finish_span_option() = {time, erlang:timestamp()} | {lifetime, pid()}
erlang:timestamp().finish_span_options() = [finish_span_option()]
Options for finish_span/2.
log_field_name() = atom()
Log field name.
log_field_value() = term()
Log field value.
log_fields() = #{log_field_name() => log_field_value()}
Span log fields.
See also: Standard log fields (OpenTracing API)log_option() = {time, erlang:timestamp()} | error | {error, boolean()}
erlang:timestamp().event field with the value error will be added automatically.
In addition, the tag #{error => true} will be set to the calling span.
log_options() = [log_option()]
Options for log/3.
maybe_span() = passage_span:span() | undefined
Sampled or unsampled span.
undefined means the span is unsampled.
operation_name() = atom()
Operation name.
ref() = {ref_type(), passage_span:span()}
Span reference.
Note that the values of tags, references and logs of a reference are set to empty when the associated span is created.
See also: References between Spans (The OpenTracing Semantic Specification)ref_type() = child_of | follows_from
Span reference type.
refs() = [ref()]
Span references.
start_span_option() = {tracer, tracer_id()} | {tags, tags()} | {ref_type(), maybe_span()} | {time, erlang:timestamp()}
erlang:timestamp().#{}.start_span_options() = [start_span_option()]
Options for start_span/2.
tag_name() = atom()
Tag name.
tag_value() = term()
Tag value.
tags() = #{tag_name() => tag_value()}
Span tags.
See also: Standard span tags (OpenTracing API)tracer_id() = atom()
Tracer identifier.
| extract_span/4 | Extracts a span from Carrier. |
| finish_span/1 | Equivalent to finish_span(Span, []). |
| finish_span/2 | Finishes the span. |
| get_baggage_items/1 | Returns the baggage items carried by Span. |
| inject_span/4 | Injects Span into Carrier. |
| log/2 | Equivalent to log(Span, Fields, []). |
| log/3 | Logs the Fields to Span. |
| set_baggage_items/2 | Sets the baggage items of Span to Items. |
| set_operation_name/2 | Sets the operation name of Span to Name. |
| set_tags/2 | Sets the tags of Span to Tags. |
| set_tracer/2 | Sets the tracer of Span to Tracer. |
| start_span/1 | Equivalent to start_span(OperationName, []). |
| start_span/2 | Starts a span. |
| strip_span/1 | Strips the tags, logs and references from the given span. |
extract_span(Tracer, Format, IterateFun, Carrier) -> maybe_span()
Extracts a span from Carrier.
Carrier has no span context, this function will return undefined.
finish_span(Span::maybe_span()) -> ok
Equivalent to finish_span(Span, []).
finish_span(Span::maybe_span(), Options::finish_span_options()) -> ok
Finishes the span.
The finished span will be sent an external observer via the reporter associated with the tracer of the span.
Note that if you call this function on the same span more than once, duplicate reports will be sent.get_baggage_items(Span::maybe_span()) -> baggage_items()
Returns the baggage items carried by Span.
inject_span(Span, Format, InjectFun, Carrier) -> Carrier
Injects Span into Carrier.
log(Span::maybe_span(), Fields) -> maybe_span()
Equivalent to log(Span, Fields, []).
log(Span::maybe_span(), Fields, Options::log_options()) -> maybe_span()
Logs the Fields to Span.
set_baggage_items(Span::maybe_span(), Items) -> maybe_span()
Sets the baggage items of Span to Items.
Note that the existing items which have different keys with Items are preserved.
set_operation_name(Span::maybe_span(), Name::operation_name()) -> maybe_span()
Sets the operation name of Span to Name.
set_tags(Span::maybe_span(), Tags) -> maybe_span()
Sets the tags of Span to Tags.
Tags are preserved.
set_tracer(Span::maybe_span(), Tracer::tracer_id()) -> maybe_span()
Sets the tracer of Span to Tracer.
At the finish of the span, the reporter of Tracer will be used to report it.
start_span(OperationName::operation_name()) -> maybe_span()
Equivalent to start_span(OperationName, []).
start_span(OperationName::operation_name(), Options::start_span_options()) -> maybe_span()
Starts a span.
If any of the following conditions is matched,
a valid span object (i.e., non undefined) will be returned.
undefined) span references.sampling.priority tag exists and the value is a positive integer.tracer is specified and its sampler has determined to sample next span.strip_span(Span::maybe_span()) -> maybe_span()
Strips the tags, logs and references from the given span.
Generated by EDoc, Nov 1 2017, 22:10:30.