Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics for block-level sync #1877

Merged
merged 26 commits into from
Dec 28, 2020
Merged

Metrics for block-level sync #1877

merged 26 commits into from
Dec 28, 2020

Conversation

kitallis
Copy link
Contributor

@kitallis kitallis commented Dec 11, 2020

Story card: ch2073

Because

Measure and track in different ways how block-sync is performing.

This addresses

  • Number of resyncs for block-sync
  • Users attempting block-level sync
  • Users enabled for block level sync via rake task
  • De-dupe patients against passport id
  • Alert if someone is in a resync loop - datadog ref
  • Improve time tracing around constituent parts of a sync request

Added a a block-level sync dashboard on datadog that will get populated from this data.

@prabhanshuguptagit prabhanshuguptagit marked this pull request as ready for review December 22, 2020 14:37
Facility
.with_discarded
.updated_on_server_since(other_facilities_processed_since, limit)
Statsd.instance.time("other_facility_records.Facility") do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These time calls are now timing the old sync code (post revert), but whenever we ship the new-new perf changes, the body can be swapped and the timer can stay.

@@ -35,6 +39,27 @@ def disable_audit_logs?
false
end

def log_block_level_sync_metrics(response_key)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Centralize all the block-sync logging in one place so that the loggers don't end up being called multiple times during the code-path and are easy to find in one place.

Copy link
Contributor

@harimohanraj89 harimohanraj89 left a comment

Choose a reason for hiding this comment

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

Couple of thoughts. Lookin' pretty solid.

@@ -11,10 +11,14 @@ def __sync_from_user__(params)
end

def __sync_to_user__(response_key)
AuditLog.create_logs_async(current_user, records_to_sync, "fetch", Time.current) unless disable_audit_logs?
records = records_to_sync
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we put proper ivar caching into the methods to prevent this kind of inefficiency in future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍🏼 #1921 is doing a bunch of nice memoization, I think we can do this there. I'll add a task for it in the PR.

def passport_assigning_facility
"COALESCE((metadata->'assigning_facility_id'), (metadata->'assigningFacilityUuid'))::text"
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the output of this report generally look like? Can we post some logs from a test run for good measure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me fetch some logs and post a counter...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logs –

Screenshot 2020-12-28 at 5 02 36 PM

Counter –

Screenshot 2020-12-28 at 5 04 19 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This happens to be the actual number as it stands on production...

@harimohanraj89
Copy link
Contributor

Noice.

@kitallis kitallis merged commit 68f2878 into master Dec 28, 2020
@kitallis kitallis deleted the block-sync-metrics branch December 28, 2020 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants