Skip to content

fix: improve default fingerprint aggregation to reduce alert noise#13

Merged
Royal-lobster merged 1 commit intomainfrom
fix/fingerprint-aggregation
Apr 6, 2026
Merged

fix: improve default fingerprint aggregation to reduce alert noise#13
Royal-lobster merged 1 commit intomainfrom
fix/fingerprint-aggregation

Conversation

@Royal-lobster
Copy link
Copy Markdown
Member

@Royal-lobster Royal-lobster commented Apr 6, 2026

Summary

  • Normalize titles with the same built-in normalizers used for messages (UUIDs, hex addresses, timestamps, numbers) so dynamic values in titles don't split fingerprints
  • Reduce default stackDepth from 3 to 1 so the same error from different callers (e.g. PrismaClientKnownRequestError via getUserPositions vs getUserTrades) groups into a single aggregation stream
  • Users can restore previous behavior with fingerprint: { stackDepth: 3 }

Context

In production, a single root-cause error (missing DB table) was creating 6+ separate alert streams because each HTTP endpoint had a different caller in the stack trace. With these changes, they collapse into one stream with proper exponential ramp-up.

Test plan

  • Added test: same error from different callers groups with default stackDepth
  • Added test: dynamic hex addresses in titles produce same fingerprint
  • All 135 existing tests pass

🤖 Generated with Claude Code

Closes #15

Normalize titles with the same rules used for messages so dynamic values
(UUIDs, hex addresses, numbers) don't create separate fingerprints.
Reduce default stackDepth from 3 to 1 so the same error originating from
one throw site but reached via different callers groups into a single
aggregation stream.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves alert fingerprinting by normalizing titles to remove dynamic values and reducing the default stack depth from 3 to 1 to better group similar errors. A performance improvement was suggested to lazily compute the normalized title only when it is actually needed as a fallback for the error name.

Comment thread src/core/fingerprinter.ts
Comment on lines +72 to +75
const normalizedTitle = normalizeMessage(title, config.normalizers)
const normalizedMessage = normalizeMessage(message, config.normalizers)
const stackKey = extractStackKey(error, config.stackDepth)
const errorName = error?.name ?? title
const errorName = error?.name ?? normalizedTitle
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The normalizedTitle is computed eagerly using multiple regex replacements even when an error object is provided. Since error.name takes precedence in the errorName assignment, this computation is redundant when an error is present. It is more efficient to compute it only when needed.

Suggested change
const normalizedTitle = normalizeMessage(title, config.normalizers)
const normalizedMessage = normalizeMessage(message, config.normalizers)
const stackKey = extractStackKey(error, config.stackDepth)
const errorName = error?.name ?? title
const errorName = error?.name ?? normalizedTitle
const normalizedMessage = normalizeMessage(message, config.normalizers)
const stackKey = extractStackKey(error, config.stackDepth)
const errorName = error?.name ?? normalizeMessage(title, config.normalizers)

@Royal-lobster Royal-lobster merged commit 417688e into main Apr 6, 2026
3 checks passed
@Royal-lobster Royal-lobster deleted the fix/fingerprint-aggregation branch April 6, 2026 11:28
@github-actions github-actions bot mentioned this pull request Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build out @iqai/alert-logger — health policy, CJS compat, description field, fingerprint dedup

1 participant