# `Juggernaut.Peer.Footprint`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/peer/footprint.ex#L1)

Which of the project's functions a job executed (design notes §7.3): the footprint a
cached kill rests on.

Recorded with call-count tracing in a trace session of its own
(`docs/dependencies/trace-call-count.md`), so it never touches the default session a
test may use, and no process needs trace flags. The first measured job of a worker
loads every module of the project's applications whose source is under the worker's
directory (the sandbox), and turns call counting on for each, once; every measured job
then sets the counters to zero, runs, and reads the functions whose count rose.

A function whose counting is off when read (its module was loaded again during the
job) makes the footprint `:incomplete`: the controller then records no cache entry,
never one resting on part of what ran.

This module runs inside workers and is never mutated.

# `function_ref`

```elixir
@type function_ref() :: {String.t(), module(), atom(), arity()}
```

# `arm`

```elixir
@spec arm([module()]) :: %{
  session: term(),
  functions: [{module(), atom(), arity(), String.t()}]
}
```

Turns call counting on for `modules` (those with a source under the current directory)
once per VM, and returns the armed state: the session and every function counted.

# `arm_apps`

```elixir
@spec arm_apps() :: :ok
```

Arms call counting for the project's applications (`Juggernaut.Peer.Boot.state/0`)
and returns `:ok`; a no-op once armed. The worker calls it before a measured job.

# `disarm`

```elixir
@spec disarm() :: :ok
```

Ends counting and forgets the armed state (for tests).

# `measure`

```elixir
@spec measure(boolean(), [atom()], (-&gt; result)) ::
  {result, [function_ref()] | :incomplete | nil}
when result: term()
```

Runs `fun` and returns `{its result, the footprint}` when `measure?`, else
`{its result, nil}`. The footprint is a list of `{source, module, fun, arity}` (sources
relative to the current directory) or `:incomplete`. `apps` are the project's
applications.

# `modules_of`

```elixir
@spec modules_of([atom()]) :: [module()]
```

The loaded modules of `apps` whose source is under the current directory.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
