Enable multiple unique metrics for a single event
Problem
The following discussion from !121544 (merged) should be addressed:
-
@mikolaj_wawrzyniak started a discussion: (+2 comments) thought(non-blocking): I understand that this validation is dictated by current implementation of
HllRedisCounter
which holds only one counter per event, which prevents multiple metrics to be defined based on single event with differentunique
attribute. However I believe once current MR is delivered it will become sort of low hanging fruit to add more flexibility and enableunique
based on every countable attribute of the event
As long as this is not addressed we cannot create more than one metric using unique
on the same event.
Desired Outcome
It's possible to create multiple metrics with different properties as unique
property for the same event.
A unique-by-project metric for the user_visited_dashboard
event is created.
Potential Solution
This suggestion doesn't address a migration of existing Redis keys.
Mapping of legacy properties
Map from all event names to legacy properties. The map could be in a YAML file named event_tracking_legacy_unique_properties.yml
.
Change how we generate RedisHLL keys
Redis keys should have the format:
hll_counters_merge_request_action-<property name>-<date>
For legacy properties the Redis key format will be unchanged:
hll_counters_merge_request_action-<date>
Changes to Internal Events Tracking
Currently we update one RedisHLL counter for each call to track_event
, instead we should update any Redis key:
- legacy properties (the key without the property name)
- key for properties referred to as "unique" in a metric definition
Deploy plan:
Deploy plan:
-
Add value_name handling for RedisHLL -
Use the new value_name
RedisHLL option in InternalEvents & add a new metric making use of it -
Make RedisHLLMetric
andAggregatedMetric
also use the new value_name keys for reading its values [this has to work for any mix of legacy/non-legacy event-value pairs] -
Add validation for migrated events [explained here] -
Enable
the feature flag + update legacy event names & overrides files. Flag rollout issue -
Add changes to our Generator to make it possible to track the same event for multiple unique value namesthe Generator is already doing that.
How to verify
unique-by-project version of user_visited_dashboard
metric reports accurate numbers