Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
948f87cf
Commit
948f87cf
authored
Apr 26, 2021
by
Luis Mejia
Committed by
Mark Chao
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve RedisHllGenerator to accept --ee option
parent
f4337bc9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
changelogs/unreleased/327870-improve-metric-yaml-defintion-generator-to-fill-correct-tier-and-d.yml
...c-yaml-defintion-generator-to-fill-correct-tier-and-d.yml
+5
-0
lib/generators/gitlab/usage_metric_definition/redis_hll_generator.rb
...ors/gitlab/usage_metric_definition/redis_hll_generator.rb
+12
-2
spec/lib/generators/gitlab/usage_metric_definition/redis_hll_generator_spec.rb
...itlab/usage_metric_definition/redis_hll_generator_spec.rb
+27
-0
No files found.
changelogs/unreleased/327870-improve-metric-yaml-defintion-generator-to-fill-correct-tier-and-d.yml
0 → 100644
View file @
948f87cf
---
title
:
Add --ee option to Usage Metric Definition generator to fill correct tier and distribution
merge_request
:
59942
author
:
type
:
other
lib/generators/gitlab/usage_metric_definition/redis_hll_generator.rb
View file @
948f87cf
...
...
@@ -10,14 +10,24 @@ module Gitlab
argument
:category
,
type: :string
,
desc:
"Category name"
argument
:event
,
type: :string
,
desc:
"Event name"
class_option
:ee
,
type: :boolean
,
optional:
true
,
default:
false
,
desc:
'Indicates if metric is for ee'
def
create_metrics
Gitlab
::
UsageMetricDefinitionGenerator
.
start
([
"
#{
key_path
}
_weekly"
,
'--dir'
,
'7d'
])
Gitlab
::
UsageMetricDefinitionGenerator
.
start
([
"
#{
key_path
}
_monthly"
,
'--dir'
,
'28d'
])
weekly_params
=
[
"
#{
key_path
}
_weekly"
,
'--dir'
,
'7d'
]
weekly_params
<<
'--ee'
if
ee?
Gitlab
::
UsageMetricDefinitionGenerator
.
start
(
weekly_params
)
monthly_params
=
[
"
#{
key_path
}
_monthly"
,
'--dir'
,
'28d'
]
monthly_params
<<
'--ee'
if
ee?
Gitlab
::
UsageMetricDefinitionGenerator
.
start
(
monthly_params
)
end
private
def
ee?
options
[
:ee
]
end
def
key_path
"redis_hll_counters.
#{
category
}
.
#{
event
}
"
end
...
...
spec/lib/generators/gitlab/usage_metric_definition/redis_hll_generator_spec.rb
View file @
948f87cf
...
...
@@ -18,6 +18,10 @@ RSpec.describe Gitlab::UsageMetricDefinition::RedisHllGenerator do
stub_prometheus_queries
end
after
do
FileUtils
.
rm_rf
(
temp_dir
)
end
it
'creates metric definition files'
do
described_class
.
new
(
args
).
invoke_all
...
...
@@ -27,4 +31,27 @@ RSpec.describe Gitlab::UsageMetricDefinition::RedisHllGenerator do
expect
(
YAML
.
safe_load
(
File
.
read
(
weekly_metric_definition_path
))).
to
include
(
"key_path"
=>
"redis_hll_counters.test_category.i_test_event_weekly"
)
expect
(
YAML
.
safe_load
(
File
.
read
(
monthly_metric_definition_path
))).
to
include
(
"key_path"
=>
"redis_hll_counters.test_category.i_test_event_monthly"
)
end
context
'with ee option'
do
let
(
:weekly_metric_definition_path
)
{
Dir
.
glob
(
File
.
join
(
temp_dir
,
'ee/config/metrics/counts_7d/*i_test_event_weekly.yml'
)).
first
}
let
(
:monthly_metric_definition_path
)
{
Dir
.
glob
(
File
.
join
(
temp_dir
,
'ee/config/metrics/counts_28d/*i_test_event_monthly.yml'
)).
first
}
let
(
:weekly_metric_definition
)
{
YAML
.
safe_load
(
File
.
read
(
weekly_metric_definition_path
))
}
let
(
:monthly_metric_definition
)
{
YAML
.
safe_load
(
File
.
read
(
monthly_metric_definition_path
))
}
before
do
stub_const
(
"
#{
Gitlab
::
UsageMetricDefinitionGenerator
}
::TOP_LEVEL_DIR"
,
'config'
)
stub_const
(
"
#{
Gitlab
::
UsageMetricDefinitionGenerator
}
::TOP_LEVEL_DIR_EE"
,
File
.
join
(
temp_dir
,
'ee'
))
end
it
'creates metric definition files'
do
described_class
.
new
(
args
,
{
'ee'
:
true
}).
invoke_all
expect
(
weekly_metric_definition
).
to
include
(
"key_path"
=>
"redis_hll_counters.test_category.i_test_event_weekly"
)
expect
(
weekly_metric_definition
[
"distribution"
]).
to
include
(
'ee'
)
expect
(
monthly_metric_definition
).
to
include
(
"key_path"
=>
"redis_hll_counters.test_category.i_test_event_monthly"
)
expect
(
monthly_metric_definition
[
"distribution"
]).
to
include
(
'ee'
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment