feat(audit): meter audit events that go missing before the store write (NAN-6472) - #6963
Open
pfreixes wants to merge 1 commit into
Open
feat(audit): meter audit events that go missing before the store write (NAN-6472)#6963pfreixes wants to merge 1 commit into
pfreixes wants to merge 1 commit into
Conversation
…e (NAN-6472) The store meters every ClickHouse write attempt, so a failed write is alertable. The two catch blocks upstream of it were log-only, which left an event we meant to record vanishing entirely invisible to metrics. They are not the same failure though. Throwing before the finish listener is registered loses the event; throwing during target resolution still emits it, just without a target. So dropped and degraded get separate counters, keeping one number to alert on for events actually lost. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
store.record()already meters every ClickHouse write attempt, so a failed write is alertable — but the twocatchblocks that fire before it, when event construction or target resolution throws, were log-only. An event we intended to record disappearing was invisible to metrics.nango.audit.emit.droppedtherefore stays the single number to alert on for events actually lost, andnango.audit.resolve.failedcovers the recorded-but-incomplete case.Both carry a
sourcetag so the dedicated auth, sync-command and MFA middlewares report distinctly once they land, and so NAN-6471's shared emit tail can absorb both increments without changing the metric contract.Deliberately not metered
DropAuditStore.record()returnsOkwhile discarding, so any deployment withoutCLICKHOUSE_URLdrops every event silently. That is correct behaviour for self-hosting rather than a fault, and no counter here sees it.emit()'s early return when there is no account — unreachable in practice, since the listener is only registered when one exists.Test plan
ts-build,npm run lint(exit 0), prettier cleannango.audit.emit.dropped— audit volume is low enough that any non-zero value is worth looking at🤖 Generated with Claude Code