Tapper v0.2.0 Tapper.Tracer.Server

The Trace server.

There is one server per trace, which persists until the trace is finished, at which point it sends its spans to a reporter.

Summary

Functions

via Tapper.Tracer.update/3

Handles time-out

Initializes the Tracer’s state

prepare the SpanInfo of the initial span in this Tracer

convert trace to protocol spans, and invoke reporter module or function

Starts a Tracer, registering a name derived from the Tapper.Id

update a span (identified by span id) in a trace with an updater function, taking care of case where span does not exist

locate the server via the Tapper.Id

Functions

apply_update(value, trace, span_id, timestamp, default_endpoint)
apply_updates(trace, deltas, span_id, timestamp, endpoint)
handle_cast(msg, state)

via Tapper.Tracer.update/3

handle_info(msg, state)

Handles time-out.

Invoked if ttl expires between messages: automatically ends trace, annotating any un-finished spans.

See also

init(args)

Initializes the Tracer’s state.

Arguments (as list)

  • config - worker config from Tapper.Tracer.Supervisor’s worker spec.
  • trace_init - trace parameters i.e. {trace_id, span_id, parent_span_id, sample, debug}
  • pid - pid of process that called Tapper.start/1 or Tapper.join/6.
  • timestamp (Tapper.Timestamp.t) - timestamp of trace receive/start event.
  • opts - options passed to start or join, see below.

Options

  • name (String) - name of the span.
  • annotations - a list of annotations, specified by Tapper.Tracer.annotation_delta/2 etc.
  • type (:client or :server) - determines whether the first annotation should be cs (:client) or sr (:server).
  • endpoint (Tapper.Endpoint) - sets the endpoint for the initial cr or sr annotation, defaults to one derived from Tapper configuration (see Tapper.Application).
  • remote (Tapper.Endpoint) - an endpoint to set as the sa (:client) or ca (:server) binary annotation.
  • ttl (integer, ms) - set the no-activity time-out for this trace in milliseconds; defaults to 30,000 ms.
  • reporter (module atom or function) - override the configured reporter for this trace; useful for testing.

NB passed the list of arguments supplied by Tapper.Tracer.Server.start_link/5 via Tapper.Tracer.Supervisor.start_tracer/3.

initial_span_info(span_id, parent_id, timestamp, endpoint, opts)

prepare the SpanInfo of the initial span in this Tracer

report_trace(trace)

convert trace to protocol spans, and invoke reporter module or function.

start_link(config, arg, pid, timestamp, opts)

Starts a Tracer, registering a name derived from the Tapper.Id.

Arguments

NB called by Tapper.Tracer.Supervisor when starting a trace with start_tracer/2.

See also

update_span(trace, span_id, span_updater)
update_span(Tapper.Tracer.Trace.t, Tapper.SpanId.t, (Tapper.Tracer.Trace.SpanInfo.t -> Tapper.Tracer.Trace.SpanInfo.t)) :: Tapper.Tracer.Trace.t

update a span (identified by span id) in a trace with an updater function, taking care of case where span does not exist.

via_tuple(trace_id)

locate the server via the Tapper.Id.