Module passage_pd

Process Dictionary version of passage.

Copyright © 2017 Takeru Ohta <phjgt308@gmail.com>

Description

Process Dictionary version of passage.

The functions in this module operate on the span which stored in the process dictionary of the calling process.

Examples

  %% 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.

Data Types

with_span_option()

with_span_option() = {error_if_exception, boolean()} | passage:start_span_option()

with_span_options()

with_span_options() = [with_span_option()]

Options for with_span/3

Function Index

current_span/0Returns the current span stored in the process dictionary of the calling process.
finish_span/0Equivalent to finish_span([]).
finish_span/1Pops the current span from process dictionary and finishes the span.
get_baggage_items/0Returns the baggage items carried by the current span.
log/1Equivalent to log(Fields, []).
log/2Logs the Fields to the current span.
set_baggage_items/1Sets the baggage items of the current span to Items.
set_operation_name/1Sets the operation name of the current span to OperationName.
set_tags/1Sets the tags of the current span to Tags.
set_tracer/1Sets the tracer of the current span to Tracer.
start_span/1Equivalent to start_span(OperationName, []).
start_span/2Starts a span.
with_parent_span/2Saves ParentSpan in the current process dictionary then executes Fun.
with_span/2Equivalent to with_span(OperationName, [], Fun).
with_span/3Starts a span enclosing Fun.

Function Details

current_span/0

current_span() -> passage:maybe_span()

Returns the current span stored in the process dictionary of the calling process.

finish_span/0

finish_span() -> ok

Equivalent to finish_span([]).

finish_span/1

finish_span(Options::passage:finish_span_options()) -> ok

Pops the current span from process dictionary and finishes the span.

The finished span will be sent an external observer via the reporter associated with the tracer of the span.

get_baggage_items/0

get_baggage_items() -> passage:baggage_items()

Returns the baggage items carried by the current span.

log/1

log(Fields) -> ok

Equivalent to log(Fields, []).

log/2

log(Fields, Options::passage:log_options()) -> ok

Logs the Fields to the current span.

set_baggage_items/1

set_baggage_items(Items) -> ok

Sets the baggage items of the current span to Items.

Note that the existing items which have different keys with Items are preserved.

See also: Set a baggage item (The OpenTracing Semantic Specification)

set_operation_name/1

set_operation_name(OperationName::passage:operation_name()) -> ok

Sets the operation name of the current span to OperationName.

set_tags/1

set_tags(Tags) -> ok

Sets the tags of the current span to Tags.

Note that the existing tags which have different keys with Tags are preserved.

set_tracer/1

set_tracer(Tracer::passage:tracer_id()) -> ok

Sets the tracer of the current span to Tracer.

At the finish of the span, the reporter of Tracer will be used to report it.

This change affects all descendants of the span.

start_span/1

start_span(OperationName::passage:operation_name()) -> ok

Equivalent to start_span(OperationName, []).

start_span/2

start_span(OperationName::passage:operation_name(), Options::passage:start_span_options()) -> ok

Starts a span.

The started span will be pushed to the process dictionary of the calling process.

If there is no sampled span references, the value of span will be undefined.

with_parent_span/2

with_parent_span(ParentSpan, Fun) -> Result

Saves ParentSpan in the current process dictionary then executes Fun.

Before returning from the function, ParentSpan will be popped from the process dictionary.

with_span/2

with_span(OperationName::passage:operation_name(), Fun) -> Result

Equivalent to with_span(OperationName, [], Fun).

with_span/3

with_span(OperationName::passage:operation_name(), Options::with_span_options(), Fun) -> Result

Starts a span enclosing Fun.


Generated by EDoc