# `TraceGuard.TaskCollector`
[🔗](https://github.com/HataluliRandima/trace_guard/blob/v0.1.0/lib/trace_guard/task_collector.ex#L1)

**Internal module.** Not part of TraceGuard's public API: it may change in
any release. Use the functions in `TraceGuard` instead.

Receives the events of propagated (wrapped) work for one trace.

One collector exists per trace that called `TraceGuard.wrap/1`, started
under the `TraceGuard.TaskCollectors` `DynamicSupervisor`, whose
`max_children` is `:max_task_collectors`.

A collector always terminates, whichever happens first:

  * the owning request process asks for its events (`:drain`) or discards
    it when the request completes;
  * the owning request process exits (it is monitored);
  * `:task_collector_lifetime` elapses.

It stores at most `:max_events` events (senders are also budgeted through
the shared `:atomics` counter) and labels them by sending process in
order of first appearance, per kind: `"task-1"`, `"task-2"`,
`"server-1"`, ...

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

---

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