Faulty.Fingerprint (Faulty v0.1.7)

Copy Markdown View Source

Generates unique fingerprints for errors to enable proper grouping and deduplication.

The fingerprint is based on the error kind, source location (when available), and a normalized version of the error reason. This approach ensures that:

  • Similar errors are grouped together
  • Different error types are properly separated
  • Volatile details in error messages don't prevent grouping
  • Errors without source information are still differentiated by type

Summary

Functions

Generates a SHA256 fingerprint for an error.

Normalizes an error reason for fingerprinting purposes.

Functions

generate(kind, reason, source_line, source_function)

@spec generate(String.t(), String.t(), String.t(), String.t()) :: String.t()

Generates a SHA256 fingerprint for an error.

Parameters

  • kind - The error kind (e.g., "Elixir.ArgumentError", "error")
  • reason - The error reason/message
  • source_line - Source location as "file:line" or "-" if unknown
  • source_function - Source function as "Module.function/arity" or "-" if unknown

Examples

iex> Faulty.Fingerprint.generate("error", "Erlang error: {:port_died, :normal}", "-", "-")
"4F3263C8ABD35E3985DEB0E6422D111D12B357D665604BCF2DE101C3EAC86951"

iex> Faulty.Fingerprint.generate("error", "Erlang error: {:tls_alert, {:bad_record_mac, \"TLS error\"}}", "-", "-")
"D04D58179897BD41292783B5360F2E14AF691D59C168D8D8E4F316819E09C466"

normalize_reason_for_fingerprint(reason)

@spec normalize_reason_for_fingerprint(String.t()) :: String.t()

Normalizes an error reason for fingerprinting purposes.

Extracts the essential error type while removing volatile details like specific messages, timestamps, or runtime-specific information that would prevent proper error grouping.

Examples

iex> Faulty.Fingerprint.normalize_reason_for_fingerprint("Erlang error: {:port_died, :normal}")
"erlang_error:port_died"

iex> Faulty.Fingerprint.normalize_reason_for_fingerprint("ArgumentError: invalid input here")
"elixir_exception:ArgumentError"