Skip to content

feat(jans-fido2): add dropOffRate and completionRate to metrics error…#13360

Open
imran-ishaq wants to merge 6 commits intomainfrom
jans-fido2-add-drop-off-field
Open

feat(jans-fido2): add dropOffRate and completionRate to metrics error…#13360
imran-ishaq wants to merge 6 commits intomainfrom
jans-fido2-add-drop-off-field

Conversation

@imran-ishaq
Copy link
Contributor

@imran-ishaq imran-ishaq commented Feb 26, 2026

Description

Adds dropOffRate and completionRate to the GET /metrics/analytics/errors response. Rates are based on started operations (ATTEMPT count): completionRate = successRate + failureRate, dropOffRate = 1 - completionRate. Includes a fallback when no ATTEMPT entries exist (e.g. legacy data)

Target issue

Adds explicit drop-off and completion metrics to the FIDO2 metrics errors analytics endpoint so administrators can track abandonment and completion rates (fixes #[issue-number] if you have one).

closes #13351

Implementation Details


Test and Document the changes

  • Static code analysis has been run locally and issues have been fixed
  • Relevant unit and integration tests have been added/updated
  • Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)

Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with docs: to indicate documentation changes or if the below checklist is not selected.

  • I confirm that there is no impact on the docs due to the code changes in this PR.

Summary by CodeRabbit

  • New Features

    • Added completionRate and dropOffRate to report flow completion and abandonment.
    • successRate and failureRate now use initiated/ATTEMPT counts as the denominator.
    • Added normalization for mixed legacy/new data and fallback behavior when no ATTEMPT entries exist.
  • Documentation

    • Updated metrics docs and API descriptions, examples, and notes to reflect new fields and revised rate semantics.

…s analytics endpoint

Signed-off-by: imran <imranishaq7071@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff7b908 and dcfb753.

📒 Files selected for processing (1)
  • jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java

📝 Walkthrough

Walkthrough

Adds two new error-analytics metrics (completionRate, dropOffRate), changes successRate/failureRate denominators to ATTEMPT (started) counts, updates service logic to compute and normalize rates with legacy fallback, and updates documentation/OpenAPI schema and metric constants.

Changes

Cohort / File(s) Summary
Documentation
jans-fido2/docs/METRICS_WIKI.md, jans-fido2/docs/jansFido2Swagger.yaml
Revised metric definitions and examples: successRate/failureRate now use ATTEMPT (started) as denominator; added completionRate (successRate + failureRate) and dropOffRate (1 - completionRate); updated notes and schema descriptions.
Metrics Service
jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java
Reworked analytics tally to count ATTEMPT/SUCCESS/FAILURE, compute successRate/failureRate relative to totalStarted, introduce completionRate and dropOffRate, normalize when completionRate>1 due to legacy mixes, and fall back to completed-only denominators when no ATTEMPT entries exist.
Constants/Model
jans-fido2/model/src/main/java/io/jans/fido2/model/metric/Fido2MetricsConstants.java
Added public constants COMPLETION_RATE and DROP_OFF_RATE for the new metric keys.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #13257: Updates METRICS_WIKI.md and OpenAPI schema to add completionRate/dropOffRate and adjust rate semantics — directly overlaps docs/schema changes.
  • PR #12405: Modifies Fido2MetricsService aggregation/analytics logic and helpers — related to service-side rate computations and normalization.
  • PR #12800: Changes FIDO2 metrics subsystem and constants — overlaps with metric name/constant additions.

Suggested reviewers

  • yurem
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: adding dropOffRate and completionRate to metrics error analytics response for jans-fido2.
Description check ✅ Passed The description includes target issue reference, implementation details explaining the rate calculation logic, and addresses the documentation checklist requirements.
Linked Issues check ✅ Passed All coding requirements from issue #13351 are met: new fields (dropOffRate, completionRate) added to API response, rates computed using ATTEMPT count as denominator, completionRate equals successRate + failureRate, dropOffRate equals 1 - completionRate, and fallback logic for legacy data.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing dropOffRate and completionRate metrics. Documentation updates, constant additions, service implementation, and API schema changes are all in scope with issue #13351.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jans-fido2-add-drop-off-field

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mo-auto
Copy link
Member

mo-auto commented Feb 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mo-auto mo-auto added area-documentation Documentation needs to change as part of issue or PR comp-docs Touching folder /docs comp-jans-fido2 Component affected by issue or PR kind-feature Issue or PR is a new feature request labels Feb 26, 2026
@sonarqubecloud
Copy link

@imran-ishaq imran-ishaq marked this pull request as ready for review February 26, 2026 14:15
@imran-ishaq imran-ishaq requested a review from yurem as a code owner February 26, 2026 14:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java`:
- Around line 512-515: The analysis map is using hardcoded keys "completionRate"
and "dropOffRate" in Fido2MetricsService.put calls; add new constants (e.g.,
COMPLETION_RATE and DROP_OFF_RATE) to Fido2MetricsConstants and replace the
hardcoded strings in Fido2MetricsService (where analysis.put("completionRate",
...) and analysis.put("dropOffRate", ...)) to use
Fido2MetricsConstants.COMPLETION_RATE and Fido2MetricsConstants.DROP_OFF_RATE so
all metric keys are centralized and consistent.
- Around line 505-511: In Fido2MetricsService (around the block computing
successRate/failureRate), guard completionRate/dropOffRate against out-of-range
values caused by mixing legacy completion-only records: after computing
successRate and failureRate (using successfulOperations, failedOperations,
totalStarted), compute completionRate = successRate + failureRate and then clamp
it to [0.0, 1.0] (e.g., completionRate = Math.max(0.0, Math.min(1.0,
completionRate))); recompute dropOffRate = 1.0 - completionRate and similarly
ensure dropOffRate stays within [0.0, 1.0]. Ensure these clamped values are used
for subsequent metric reporting.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d70103 and 95d075d.

📒 Files selected for processing (3)
  • jans-fido2/docs/METRICS_WIKI.md
  • jans-fido2/docs/jansFido2Swagger.yaml
  • jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java

…s analytics endpoint 1

Signed-off-by: imran <imranishaq7071@gmail.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java`:
- Around line 507-516: The computation in Fido2MetricsService currently clamps
completionRate independently, causing completionRate != successRate +
failureRate; fix by computing rawSum = successRate + failureRate, then clamp
completionRate = Math.min(1.0, rawSum) and if rawSum > 0 and rawSum !=
completionRate scale successRate and failureRate proportionally (successRate *=
completionRate / rawSum; failureRate *= completionRate / rawSum) so their sum
equals completionRate before putting them into analysis (use the existing
successfulOperations, failedOperations, totalStarted, and Fido2MetricsConstants
names to locate the code).

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95d075d and 866aed5.

📒 Files selected for processing (2)
  • jans-fido2/model/src/main/java/io/jans/fido2/model/metric/Fido2MetricsConstants.java
  • jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java

…s analytics endpoint 2

Signed-off-by: imran <imranishaq7071@gmail.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java`:
- Around line 523-533: The fallback branch in Fido2MetricsService currently
skips adding SUCCESS_RATE, FAILURE_RATE, COMPLETION_RATE, and DROP_OFF_RATE to
the analysis map when totalCompleted == 0, causing missing keys for empty
datasets; modify the else branch that computes totalCompleted from
successfulOperations and failedOperations so it always puts those four keys into
the analysis map even when totalCompleted == 0 — compute successRate and
failureRate as 0.0 when totalCompleted == 0, set completionRate to 0.0 and
dropOffRate to 0.0 in that case, and continue to use the existing constants
Fido2MetricsConstants.SUCCESS_RATE, FAILURE_RATE, COMPLETION_RATE, DROP_OFF_RATE
and the analysis map to ensure stable response shape.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 866aed5 and 93bdf2e.

📒 Files selected for processing (1)
  • jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java

…s analytics endpoint 3

Signed-off-by: imran <imranishaq7071@gmail.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java`:
- Around line 494-503: The three separate streams counting
ATTEMPT/SUCCESS/FAILURE in Fido2MetricsService (producing totalStarted,
successfulOperations, failedOperations) should be collapsed into a single pass
to avoid traversing entries multiple times: iterate once (or use
entries.stream().collect(Collectors.groupingBy(e -> e.getStatus(),
Collectors.counting()))) to produce counts keyed by Fido2MetricsConstants values
and then assign totalStarted/successfulOperations/failedOperations from that
single tally; update any downstream code to use these consolidated counts.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93bdf2e and ff7b908.

📒 Files selected for processing (1)
  • jans-fido2/server/src/main/java/io/jans/fido2/service/metric/Fido2MetricsService.java

…s analytics endpoint 4

Signed-off-by: imran <imranishaq7071@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-documentation Documentation needs to change as part of issue or PR comp-docs Touching folder /docs comp-jans-fido2 Component affected by issue or PR kind-feature Issue or PR is a new feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(jans-fido2): add dropOffRate and completionRate to metrics errors analytics

2 participants