Skip to content

feat(saf): add Micrometer metrics instrumentation - #382

Merged
ar merged 3 commits into
mainfrom
prompt-request/saf-micrometer-metrics
Jun 14, 2026
Merged

feat(saf): add Micrometer metrics instrumentation#382
ar merged 3 commits into
mainfrom
prompt-request/saf-micrometer-metrics

Conversation

@ar-agt

@ar-agt ar-agt commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

This PR implements Chhil's Prompt Request to add Micrometer instrumentation to the jPOS-EE SAF module, following a red-green-refactor flow and mirroring the existing QRestMetrics pattern.

Because this is our first Prompt Request, a quick note on the idea is here:
https://jpos.org/blog/2026/02/prompt-requests

What's included:

  • Added package-private SAFMetrics with null-safe no-op behavior when no MeterRegistry is configured
  • Added SAF meters:
    • jpos.saf.queue.size
    • jpos.saf.send.duration
    • jpos.saf.send.success
    • jpos.saf.send.retried
    • jpos.saf.send.expired
    • jpos.saf.send.discarded
  • Wired metrics into SAF.initService() and SAF.send(Entry)
  • Added micrometer.core to modules/saf module-info
  • Added SAF test dependencies and a new SAF test suite

Behavior covered by tests:

  • no-op behavior when metrics are not configured
  • queue depth gauge registration
  • send duration recording
  • success / retry / expired / discarded counters
  • SAF send-path instrumentation for success, retry, timeout, ISOException, expiration, and max retransmissions

Verification:

  • ./gradlew :modules:saf:test
  • git diff --check

@ar-agt

ar-agt commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, @chhil.

I implemented your Prompt Request and opened this PR. I followed a TDD flow and kept the SAF metrics pattern aligned with QRestMetrics, including null-safe no-op behavior when no registry is configured.

Since this is the first Prompt Request we're receiving, here's the short write-up on the idea as well:
https://jpos.org/blog/2026/02/prompt-requests

@chhil

chhil commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

The prompt missed adding update the module_saf.adoc with metrics changes.

private Entry send(Entry entry) {
String mti = getMTI(entry);
if (shouldIgnore(entry)) {
metrics.sendExpired(mti, isMaxRetransmission(entry) ? "max-retransmissions" : "expired");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should 2 events get logged if its max retransmission and expired?
i.e. preserves both when both conditions apply

@ar
ar merged commit 1f3cae7 into main Jun 14, 2026
1 check passed
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.

3 participants