ObserverWeb.Tracer.Tool.Duration (Observer Web v0.2.7)
View SourceMeasures how long traced functions take to run, per process, optionally reduced through an
aggregation mode (:sum, :avg, :min, :max, :dist).
Ported and adapted from https://github.com/gabiz/tracer's Tracer.Tool.Duration:
- Fixes a typo in the upstream aggregation lookup that maps the atom
:mix(instead of:min) toEnum.min/1- upstream's:minmode is unreachable and raises. - Upstream streams each duration live as it completes when no aggregation mode is selected,
and only reports finalized aggregates through
handle_stop/1otherwise. Observer Web's tool sessions only ever produce a single report at the end (seeObserverWeb.Tracer.Server), so this always collects every sample and reports them all at once - individually when there's no aggregation mode, reduced when there is. - Requires
return_trace()in the match spec to see:return_fromevents -ObserverWeb.Tracer.Tool.forced_match_spec_keys/1forces this in regardless of the match specs selected in the UI.
Samples are grouped (and, when an aggregation mode is selected, reduced) by the reporting node
in addition to {mod, fun, arity} and the raw message value, so tracing the same function
across multiple nodes doesn't collapse their durations together - matching how Live Tracing
identifies which node ("service") each event came from.
Summary
Types
@type aggregation() :: :sum | :avg | :min | :max | :dist | nil
@type t() :: %ObserverWeb.Tracer.Tool.Duration{ aggregation: aggregation(), collect: ObserverWeb.Tracer.Tool.Collect.t(), stacks: %{optional(pid()) => list()} }