Skip to content

Add unique_on to Internal Events Tracking

Problem

We want to continue progressing toward our event system vision outlined in the prototypical documentation and our objective to deprecate the old system. We need to take the next steps on top of Internal Events Tracking - iteration 0 (#407858 - closed)

Desired Outcome

Exact outcome TBD, this is still a placeholder that needs to be filled depenending on Users should be able to define a property from the standard context in a RedisHLL metric definition like this:

options:
  events:
  - i_code_review_user_create_mr
    unique_on: user_id

Notice that "unique_on" might need some wordsmithing.

Limitations

  1. In this version the only valid properties to use for unique_on are those defined in the Standard Context. (namespace_id, project_id and user_id)
  2. Since each Redis event is stored under one Redis key for now, we cannot allow multiple different unique_on on the same event.

Implementation

  1. Load the metric definitions and find the matching definitions based on event name
  2. Validate that a maximum of one unique_on property is defined. E.g. one metric cannot define unique_on: user_id and another one unique_on: namespace_id for the same event.
  3. InternalEventsTracking.track_event should pass the value of the property specified by unique_on to UsageDataCounters::HLLRedisCounter.track_event
Edited by Sebastian Rehm