Module: Eussiror::Fingerprint

Defined in:
lib/eussiror/fingerprint.rb

Constant Summary collapse

DIGEST_LENGTH =

Number of hex characters kept from the SHA256 digest.

12
GEM_PATH_PATTERNS =

Lines from these path fragments are excluded when looking for the "first application line" in a backtrace.

%w[/gems/ /ruby/ /rubygems vendor/bundle].freeze

Class Method Summary collapse

Class Method Details

.compute(exception) ⇒ Object

Computes a stable, short fingerprint for a given exception.

The fingerprint is based on:

- The exception class name
- The first 200 characters of the message
- The first backtrace line that belongs to the application (not a gem)

Returns a 12-character lowercase hex string.



22
23
24
25
26
27
28
29
30
# File 'lib/eussiror/fingerprint.rb', line 22

def self.compute(exception)
  parts = [
    exception.class.name,
    exception.message.to_s[0, 200],
    first_app_backtrace_line(exception)
  ]

  Digest::SHA256.hexdigest(parts.join("|"))[0, DIGEST_LENGTH]
end