Collect Service Ping metrics information about duration
What does this MR do and why?
ServicePing metrics can take a significant time and resources to be collected. This MR attempts to build up tooling that provides insights into collection time of metrics on self-managed instances. It adds decorator class to wraps resulting metrics values. Such approach was selected because upon collection it is not known which metric would get value. Using decorator enables enumeration over resulting ServicePing payload and retrieval of collection time information without to widespread changes to legacy codebase
On VersionsApp side there is https://gitlab.com/gitlab-services/version-gitlab-com/-/merge_requests/669
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
-
Checkout https://gitlab.com/gitlab-services/version-gitlab-com/-/merge_requests/669 and spin up local VersionApp server. If you do not have VersionApp set up locally follow this instruction
-
Change
ServicePing:SubmitService
to point to your local development VersionApp instance
diff --git a/app/services/service_ping/submit_service.rb b/app/services/service_ping/submit_service.rb
index 64793f5072c..e8236f9142d 100644
--- a/app/services/service_ping/submit_service.rb
+++ b/app/services/service_ping/submit_service.rb
@@ -102,6 +102,7 @@ def save_raw_usage_data(usage_data)
# See https://gitlab.com/gitlab-org/gitlab/-/issues/233615 for details
def base_url
Rails.env.production? ? PRODUCTION_BASE_URL : STAGING_BASE_URL
+ 'http://localhost:3000'
end
end
end
- In rails console
$ bin/rails c
trigger ServicePing report
[1] pry(main)> ServicePing::SubmitService.new.execute
- Look for incoming request to
/usage_ping_metadata
output in VersionApp
Started POST "/usage_ping_metadata" for ::1 at 2022-04-07 13:30:44 +0200
Processing by UsagePingMetadataController#create as HTML
Parameters: {"metadata"=>{"metrics"=>[{"name"=>"version", "time_elapsed"=>3.00002284348011e-06}, {"name"=>"installation_type", "time_elapsed"=>8.999952115118504e-06}, {"name"=>"settings.ldap_encrypted_secrets_enabled", "time_elapsed"=>0.0013879999751225114}, {"name"=>"settings.smtp_encrypted_secrets_enabled", "time_elapsed"=>0.0005740000633522868}, {"name"=>"settings.operating_system", "time_elapsed"=>0.6089230000507087}, {"name"=>"settings.gitaly_apdex", "time_elapsed"=>0.012181999976746738}, {"name"=>"counts.assignee_lists", "time_elapsed"=>0.027057999977841973}, {"name"=>"counts.ci_builds", "time_elapsed"=>0.03883099998347461}, {"name"=>"counts.ci_internal_pipelines", "time_elapsed"=>0.029631000012159348},
....
{"name"=>"counts.assignee_lists", "time_elapsed"=>0.027057999977841973}, {"name"=>"counts.ci_builds", "time_elapsed"=>0.03883099998347461}, {"name"=>"counts.ci_internal_pipelines", "time_elapsed"=>0.029631000012159348}, {"name"=>"counts.ci_external_pipelines", "time_elapsed"=>0.014370999997481704}]
Completed 201 Created in 21ms (ActiveRecord: 0.0ms | Allocations: 37391)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #295289 (closed)