Draft: Use instrumented classes in Usage Ping [RUN ALL RSPEC] [RUN AS-IF-FOSS]
requested to merge 330842-merge-instrumentation-classes-to-usage-data-in-usage-ping-service into master
What does this MR do?
- Add feature flag
usage_ping_with_instrumentation_classes
- Add
Gitlab::Usage::UsageDataInstrumentation
class where we merge hash generated withusage_data.rb
with hash generated with instrumentation classes if feature enabled in SubmitUsagePingService - Use
Gitlab::Usage::UsageDataInstrumentation
inapp/services/submit_usage_ping_service.rb
- Use
Gitlab::Usage::UsageDataInstrumentation
inlib/tasks/gitlab/usage_data.rake
rake taskthat generates usage ping payload - Use
Gitlab::Usage::UsageDataInstrumentation
inapp/controllers/admin/application_settings_controller.rb
this is in admin side where we can preview usage ping - Use
Gitlab::Usage::UsageDataInstrumentation
inapp/controllers/admin/instance_review_controller.rb
this is.../admin/instance_review
- Use
Gitlab::Usage::UsageDataInstrumentation
inee/spec/config/metrics/every_metric_definition_spec.rb
If feature usage_ping_with_instrumentation_classes
is enabled then we merged data generated with instrumentation classes and we do not add the metrics instrumented in usage_data.rb
If the feature is disabled we compute all metrics in usage_data.rb including the ones that have instrumentation classes
Metrics that have instrumentation classes are:
usage_activity_by_stage_monthly.plan.issues
redis_hll_counters.quickactions.i_quickactions_approve_monthly
counts.boards
usage_activity_by_stage.plan.issues
counts.issues
redis_hll_counters.quickactions.i_quickactions_approve_weekly
instance_auto_devops_enabled
Note:
This should be merged in %14.1
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
I have included a changelog entry, or it's not needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
Test usage ping service in rails console with featured enabled and disabled we should get the same payload.
Feature.disable(:usage_data_instrumentation)
SubmitUsagePingService.new.execute
old = RawUsageData.last.payload
puts Gitlab::Json.pretty_generate(old)
Feature.enable(:usage_data_instrumentation)
SubmitUsagePingService.new.execute
new = RawUsageData.last.payload
puts Gitlab::Json.pretty_generate(new)
# Check the values for instrumented classes old should be equal with new
[18] pry(main)> old['counts']['issues']
=> 14
[19] pry(main)> old['counts']['boards']
=> 2
[20] pry(main)> old["usage_activity_by_stage_monthly"]["plan"]["issues"]
=> 1
[21] pry(main)> old["redis_hll_counters"]["quickactions"]["i_quickactions_approve_monthly"]
=> 0
[22] pry(main)> old["redis_hll_counters"]["quickactions"]["i_quickactions_approve_weekly"]
=> 0
[23] pry(main)> old["usage_activity_by_stage"]["plan"]["issues"]
=> 2
[24] pry(main)> old["instance_auto_devops_enabled"]
=> true
[25] pry(main)> new['counts']['issues']
[27] pry(main)> new['counts']['issues']
=> 14
[28] pry(main)> new['counts']['boards']
=> 2
[29] pry(main)> new["usage_activity_by_stage_monthly"]["plan"]["issues"]
=> 1
[32] pry(main)> new["redis_hll_counters"]["quickactions"]["i_quickactions_approve_monthly"]
=> 0
[33] pry(main)> new["redis_hll_counters"]["quickactions"]["i_quickactions_approve_weekly"]
=> 0
[34] pry(main)> new["usage_activity_by_stage"]["plan"]["issues"]
=> 2
[35] pry(main)> new["instance_auto_devops_enabled"]
=> true
Use diff
diff old.json new.json
➜ diff new.json old.json
567c567
< "duration_s": 0.17775100003927946
---
> "duration_s": 0.18792900000698864
570c570
< "recorded_at": "2021-06-15T06:36:34.157Z",
---
> "recorded_at": "2021-06-15T06:33:14.062Z",
1943,1944c1943,1944
< "recording_ce_finished_at": "2021-06-15T06:36:47.544Z",
< "recording_ee_finished_at": "2021-06-15T06:36:47.544Z",
---
> "recording_ce_finished_at": "2021-06-15T06:33:28.977Z",
> "recording_ee_finished_at": "2021-06-15T06:33:28.977Z",
This is ok to be different, as these are timestamps
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #330842 (closed)
Edited by Alina Mihaila