Skip to content

Add Basic Redis HLL class

Alina Mihaila requested to merge 235697-add-basic-redis-hll-class into master

What does this MR do?

Add a base class for tracking purpose Gitlab::UsageData::BaseHLL

  • Here have the the expiry values 6 weeks

  • Add some other common parts

  • Add a base key format, with a weekly key(I'm not 100% sure about weekly keys, as this myght couse us to miss some data if the weeks are not full when we build the usage ping, unless we explicit get the count for last 4 full weeks)

  • Add HLLRedisCounter

  • Add custom KEY_EXPIRY_LENGTH

  • Allow Array of events

  • Implement feature per event, per actor, user https://docs.gitlab.com/ee/development/feature_flags/development.html#feature-actors Move this in a separate issue #235954 (closed)

  • Add more tests

Example of usage

Add a class for expand_vulnerabilities event

Keep in mind to add a feature flag per event with user actor for percentage rollout

class ExpandVulnerabilitiesCounts < UsageDataCounters::HLLRedisCounter
  # This can take multiple events
  KNOWN_EVENTS = %(expand_vulnerabilities).freeze

Later

# controller
ExpandVulnerabilitiesCounts.new.track_event("entity_id", "expand_vulnerabilities")

# usage_data
ExpandVulnerabilitiesCounts.new.unique_events("entity_id", weeks: 4)

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • 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

Closes #235697 (closed)

Edited by Alina Mihaila

Merge request reports