Tapper v0.6.0 Tapper.Tracer.Server View Source
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.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor
finishes the trace asynchronously: sets the async flag & annotation on the trace, and defers to the timeout mechanism to wrap up the asynchronous spans
finishes the trace: sets the trace's end timestamp, calls the reporter and exits the tracer
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
Link to this section Functions
apply_update(value, trace, span_id, timestamp, default_endpoint) View Source
apply_updates(trace, deltas, span_id, timestamp, endpoint) View Source
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
debug(arg1, message) View Source
finish_async(trace, timestamp) View Source
finishes the trace asynchronously: sets the async flag & annotation on the trace, and defers to the timeout mechanism to wrap up the asynchronous spans.
finish_sync(trace, timestamp) View Source
finishes the trace: sets the trace's end timestamp, calls the reporter and exits the tracer.
handle_cast(msg, state) View Source
via Tapper.Tracer.update/3
handle_info(msg, state) View Source
Handles time-out.
Invoked if ttl expires between messages: automatically ends trace, annotating any un-finished spans.
See also
Tapper.start/1
andTapper.join/6
- setting the TTL for a trace using thettl
option.Tapper.finish/2
andTapper.async/0
- declaring a trace or span asynchronous.Tapper.Tracer.Timeout
- timeout behaviour.
init(list) View Source
Initializes the Tracer's state.
Arguments (as list)
config
- worker config from Tapper.Tracer.Supervisor's worker spec.id
-%Tapper.Id{}
shared
- whether we originated the trace (false
), or if we joined it (true
).pid
- pid of process that calledTapper.start/1
orTapper.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 byTapper.Tracer.annotation_delta/2
etc.type
(:client
or:server
) - determines whether the first annotation should becs
(:client
) orsr
(:server
).endpoint
(Tapper.Endpoint
) - sets the endpoint for the initialcr
orsr
annotation, defaults to one derived from Tapper configuration (seeTapper.Application
).remote
(Tapper.Endpoint
) - an endpoint to set as thesa
(:client) orca
(: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/6
via Tapper.Tracer.Supervisor.start_tracer/4
.
initial_span_info(span_id, parent_id, shared, timestamp, endpoint, opts) View Source
prepare the SpanInfo of the initial span in this Tracer
report_trace(trace) View Source
convert trace to protocol spans, and invoke reporter module or function.
server_trace(arg1, fun) View Source
start_link(config, id, shared, pid, timestamp, opts) View Source
Starts a Tracer, registering a name derived from the Tapper.Id
.
Arguments
config
- worker config fromTapper.Tracer.Supervisor
worker spec.id
-%Tapper.Id{}
shared
- whether we originated the trace (false
), or if we joined it (true
); seeTapper.Tracer.Trace.Convert.span_duration/2
.pid
- pid of process that calledTapper.start/1
orTapper.join/6
.timestamp
(Tapper.Timestamp.t
) - timestamp of trace receive/start event.opts
- options which were passed to start or join, seeTapper.Tracer.Server.init/1
.
NB called by Tapper.Tracer.Supervisor
when starting a trace with start_tracer/2
.
See also
update_span(trace, span_id, span_updater)
View Source
update_span(
Tapper.Tracer.Trace.t(),
Tapper.SpanId.t(),
(Tapper.Tracer.Trace.SpanInfo.t() -> Tapper.Tracer.Trace.SpanInfo.t())
) :: Tapper.Tracer.Trace.t()
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(id) View Source
locate the server via the Tapper.Id
.