Skip to content

feat(auditor): add metrics instrumentation to SetStatus, GetStatus and GetTokenRequest#1677

Open
Rama542 wants to merge 1 commit into
LFDT-Panurus:mainfrom
Rama542:feat/auditor-metrics-setstatus-getstatus
Open

feat(auditor): add metrics instrumentation to SetStatus, GetStatus and GetTokenRequest#1677
Rama542 wants to merge 1 commit into
LFDT-Panurus:mainfrom
Rama542:feat/auditor-metrics-setstatus-getstatus

Conversation

@Rama542

@Rama542 Rama542 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Closes #1674

I was going through the auditor service and noticed something a bit inconsistent.
Audit(), Append() and Release() all have proper duration histograms and error
counters, but the three query methods SetStatus, GetStatus and GetTokenRequest
have nothing at all. In production these are actually called very frequently since
every finality update goes through SetStatus and every audit query hits GetStatus
or GetTokenRequest, so there is a real blind spot there when trying to debug slow
queries or unusual error spikes.

The fix is straightforward since the pattern is already established in the same
file. I added duration histograms and error counters for all three methods and
wired them in exactly the same way Audit() and Append() already do it. No
behaviour changes, purely additive.

Changes:

  • metrics.go: added SetStatusDuration, SetStatusErrors, GetStatusDuration,
    GetStatusErrors, GetTokenRequestDuration, GetTokenRequestErrors to the
    Metrics struct and registered them in newMetrics
  • auditor.go: wired the new metrics into SetStatus, GetStatus and
    GetTokenRequest using the existing start/defer/observe pattern
  • auditor_internal_test.go: updated counter and histogram call counts in
    TestNewMetrics_WithProvider from 3 counters / 2 histograms to 6 counters /
    5 histograms, and added the new metric calls to TestMetricsProviderCall

Tests pass and golangci-lint reports 0 issues.

@Rama542 Rama542 force-pushed the feat/auditor-metrics-setstatus-getstatus branch 2 times, most recently from f3c20f4 to 5ea734f Compare May 7, 2026 14:44
@Rama542

Rama542 commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Hi @adecaro 👋

This PR closes #1674.

Fixed a race condition in the unit tests.
All tests now pass locally. Please review when you get a chance 🙏

…d GetTokenRequest

Audit(), Append() and Release() already recorded duration histograms and
error counters, but the three query methods SetStatus, GetStatus and
GetTokenRequest had no instrumentation at all. In production these are
high-frequency calls on the audit path and without metrics operators
have no way to detect slow queries or elevated error rates.

Add duration histograms and error counters for all three methods using
the same pattern already established in the same file, and update the
internal metrics tests to reflect the new counter and histogram counts.

Signed-off-by: Rama542 <Rama542@users.noreply.github.com>
@adecaro adecaro force-pushed the feat/auditor-metrics-setstatus-getstatus branch from eb3ac14 to 3bffeac Compare May 10, 2026 06:26
@adecaro adecaro added this to the Q3/26 milestone Jun 2, 2026
@AkramBitar

Copy link
Copy Markdown
Contributor

@Rama542

I would like to thanks you a lot for working on that PR.
Did you have the chance to see why these tests fail?

Regards,
Akram

@AkramBitar AkramBitar requested review from AkramBitar and adecaro June 22, 2026 12:52
@AkramBitar AkramBitar added the enhancement New feature or request label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT]: Add observability metrics to SetStatus, GetStatus, and GetTokenRequest in auditor.Service

3 participants