Skip to content

arc/add_instrumentation_to_appoint_a_rep#27585

Merged
patrick-brown-oddball merged 4 commits intomasterfrom
arc/add_instrumentation_to_appoint_a_rep
Apr 14, 2026
Merged

arc/add_instrumentation_to_appoint_a_rep#27585
patrick-brown-oddball merged 4 commits intomasterfrom
arc/add_instrumentation_to_appoint_a_rep

Conversation

@patrick-brown-oddball
Copy link
Copy Markdown
Contributor

Summary

  • Added metrics to Datadog for appoint a representative

Related issue(s)

Testing done

  • New code is covered by unit tests

What areas of the site does it impact?

get-help-from-accredited-representative/appoint-rep/

Acceptance criteria

  • I added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature has a monitor built into Datadog
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Datadog/StatsD instrumentation around creating Power of Attorney (appoint-a-representative) requests in the Accredited Representative Portal, along with unit tests verifying the new metrics are emitted.

Changes:

  • Increment a new overall request counter metric when a POA request is created.
  • Increment a new “pathway” counter metric distinguishing rep-first vs org-first flows.
  • Add service specs that stub AccreditedRepresentativePortal::Monitoring and assert the counters are tracked.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
modules/accredited_representative_portal/app/services/accredited_representative_portal/power_of_attorney_request_service/create.rb Emits new StatsD counters for POA request creation + pathway.
modules/accredited_representative_portal/spec/services/accredited_representative_portal/power_of_attorney_request_service/create_spec.rb Adds unit tests to validate the new track_count calls.

Comment on lines 67 to 73
request.save!

pathway = @registration_number.present? ? 'rep-first' : 'org-first'

Monitoring.new.track_count('ar.poa.request.count')
Monitoring.new.track_count("ar.poa.request.pathway.#{pathway}")
end
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

track_count is executed inside the DB transaction (after save! but before the transaction commits). If the transaction fails at commit time, these metrics will still be emitted even though the record wasn’t persisted. Consider moving the metric emission outside the ActiveRecord::Base.transaction block (or using an after_commit hook) so counts only reflect committed requests.

Copilot uses AI. Check for mistakes.

request.save!

pathway = @registration_number.present? ? 'rep-first' : 'org-first'
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The pathway metric name uses hyphenated segments (rep-first / org-first). This module’s existing StatsD/Datadog metric names appear to use only dots/underscores (e.g., ar.poa.request.decision.accept, ar.unique_session.count). To avoid introducing an inconsistent naming pattern (and potential metric-name restrictions), consider switching to underscore-separated names or emitting a single ar.poa.request.pathway metric with a pathway:rep_first|org_first tag.

Suggested change
pathway = @registration_number.present? ? 'rep-first' : 'org-first'
pathway = @registration_number.present? ? 'rep_first' : 'org_first'

Copilot uses AI. Check for mistakes.
@rmtolmach
Copy link
Copy Markdown
Contributor

Your branch is 100+ commits behind, so I've updated it with the latest. LGTM otherwise!

@patrick-brown-oddball patrick-brown-oddball merged commit 2912c02 into master Apr 14, 2026
44 checks passed
@patrick-brown-oddball patrick-brown-oddball deleted the arc/add_instrumentation_to_appoint_a_rep branch April 14, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants