Bellwether.Shape (bellwether v0.1.0)

Copy Markdown

Redaction. Turns a term into a Shape: code-derived parts intact, data-derived parts replaced by their type.

iex> Bellwether.Shape.shape({:error, {:timeout, "site-acme-1"}})
"{:error, {:timeout, binary(11)}}"

The rule is code survives, data becomes its type. Atoms, struct names and module/function/arity are written in source and are never customer data; binaries, numbers, pids and references come from the world and are replaced.

This works because the atoms are the diagnosis. :error, :timeout and :unlocked carry nearly all the debugging value of a crash and none of its sensitivity.

The documented exception is dynamically created atoms. Those would leak, and they are already avoided because they exhaust the atom table — which is unrecoverable, since it never shrinks.

The rule is absolute: no payload leaves a device un-Shaped.

Summary

Functions

Shape term into a string safe to put on the wire.

Types

opts()

@type opts() :: [
  max_depth: pos_integer(),
  max_length: pos_integer(),
  sizes: boolean()
]

Functions

shape(term, opts \\ [])

@spec shape(term(), opts()) :: String.t()

Shape term into a string safe to put on the wire.

Options

  • :max_depth - nesting beyond this becomes ...
  • :max_length - list and map entries beyond this are elided with a count
  • :sizes - keep byte sizes on binaries (default true). Set false when fingerprinting: a size measures the data it came from, so binary(6) and binary(7) would split one Issue in two.