Add sums to internal events
What does this MR do and why?
Adds a rudimentary implementation of sum to Internal events. Motivated by this and this
All features, like all time and time time framed metrics and filtering works.
Sum metrics can be defined like this:
[snip]
events:
- name: my_event
operator: sum(value)
This MR does not include docs or CLI support as it is the first iteration we need to implement the first metrics.
In the monitor trigging three events could look like this:
(sums.sum_total_my_events_with_foo is filtering label: foo and sums.sums_total_my_event_monthly is summing all events)
References
Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
Create the following files:
ee/config/events/my_event.yml
---
description: Test sum metrics
internal_events: true
action: my_event
additional_properties:
label:
description: Something to filter by
value:
description: Number of something
product_group: analytics_instrumentation
milestone: '17.6'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170920
distributions:
- ee
tiers:
- ultimate
ee/config/metrics/counts_28d/count_total_my_event_monthly.yml
---
key_path: sums.sum_total_my_event_monthly
description: Monthly sum of value from my_events
product_group: analytics_instrumentation
performance_indicator_type: []
value_type: number
status: active
milestone: '17.6'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170920
time_frame: 28d
data_source: internal_events
data_category: optional
distribution:
- ee
tier:
- ultimate
tiers:
- ultimate
events:
- name: my_event
operator: 'sum(value)'
ee/config/metrics/counts_all/count_total_sum_total_my_events_with_foo.yml
---
key_path: sums.sum_total_my_events_with_foo
description: Sum count of my_events with foo
product_group: analytics_instrumentation
performance_indicator_type: []
value_type: number
status: active
milestone: '17.6'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170920
time_frame: all
data_source: internal_events
data_category: optional
distribution:
- ee
tier:
- ultimate
tiers:
- ultimate
events:
- name: my_event
operator: 'sum(value)'
filter:
label: foo
To verify:
- Run the monitor
bin/rails runner scripts/internal_events/monitor.rb my_event - Trigger some events:
Gitlab::InternalEvents.track_event('my_event', additional_properties: {label: 'bar', value: 1.1}) Gitlab::InternalEvents.track_event('my_event', additional_properties: {label: 'foo', value: 2.4}) Gitlab::InternalEvents.track_event('my_event', additional_properties: {label: 'foo', value: 0.6}) - Check the monitor