Commit d592b3b0 authored by Alina Mihaila's avatar Alina Mihaila Committed by Peter Leitzen

Adjust rails custom metrics generator to prefix filename with timestamp

parent 15c87e7c
...@@ -67,6 +67,8 @@ tier: ['free', 'starter', 'premium', 'ultimate', 'bronze', 'silver', 'gold'] ...@@ -67,6 +67,8 @@ tier: ['free', 'starter', 'premium', 'ultimate', 'bronze', 'silver', 'gold']
The GitLab codebase provides a dedicated [generator](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/generators/gitlab/usage_metric_definition_generator.rb) to create new metric definitions. The GitLab codebase provides a dedicated [generator](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/generators/gitlab/usage_metric_definition_generator.rb) to create new metric definitions.
For uniqueness, the generated file includes a timestamp prefix, in ISO 8601 format.
The generator takes the key path argument and 2 options and creates the metric YAML definition in corresponding location: The generator takes the key path argument and 2 options and creates the metric YAML definition in corresponding location:
- `--ee`, `--no-ee` Indicates if metric is for EE. - `--ee`, `--no-ee` Indicates if metric is for EE.
......
...@@ -67,8 +67,11 @@ module Gitlab ...@@ -67,8 +67,11 @@ module Gitlab
options[:dir] options[:dir]
end end
# Example of file name
#
# 20210201124931_g_project_management_issue_title_changed_weekly.yml
def file_name def file_name
key_path.split('.').last "#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{key_path.split('.').last}"
end end
def directory def directory
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment