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
5dce47e8
Commit
5dce47e8
authored
Jul 28, 2021
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore contents of metrics with value schemas
parent
1f56f09a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
8 deletions
+20
-8
config/metrics/objects_schemas/topology_schema.json
config/metrics/objects_schemas/topology_schema.json
+2
-2
ee/spec/config/metrics/every_metric_definition_spec.rb
ee/spec/config/metrics/every_metric_definition_spec.rb
+14
-6
lib/gitlab/usage/metric_definition.rb
lib/gitlab/usage/metric_definition.rb
+4
-0
No files found.
config/metrics/objects_schemas/topology_schema.json
View file @
5dce47e8
{
"type"
:
"object"
,
"required"
:
[
"duration"
,
"failures"
],
"required"
:
[
"duration
_s
"
,
"failures"
],
"properties"
:
{
"duration"
:
{
"type"
:
"number"
,
"description"
:
"The time it took to collect topology data"
},
"duration
_s
"
:
{
"type"
:
"number"
,
"description"
:
"The time it took to collect topology data"
},
"failures"
:
{
"type"
:
"array"
,
"description"
:
"The information about failed queries"
},
"application_requests_per_hour"
:
{
"type"
:
"number"
,
"description"
:
"The number of requests to the web application per hour"
},
"nodes"
:
{
...
...
ee/spec/config/metrics/every_metric_definition_spec.rb
View file @
5dce47e8
...
...
@@ -11,7 +11,6 @@ RSpec.describe 'Every metric definition' do
geo_node_usage
license_add_ons
testing_total_unique_counts
topology
user_auth_by_provider
)
.
freeze
end
...
...
@@ -19,7 +18,7 @@ RSpec.describe 'Every metric definition' do
let
(
:usage_ping_key_paths
)
do
parse_usage_ping_keys
(
usage_ping
)
.
flatten
.
reject
{
|
v
|
v
=~
Regexp
.
union
(
ignored_usage_ping_key_patterns
)}
.
reject
{
|
v
|
v
=~
Regexp
.
union
(
ignored_usage_ping_key_patterns
)
}
.
sort
end
...
...
@@ -29,7 +28,6 @@ RSpec.describe 'Every metric definition' do
geo_node_usage
mock_ci
mock_monitoring
projects_with_enabled_alert_integrations_histogram
user_auth_by_provider
user_dast_scans
user_sast_scans
...
...
@@ -38,22 +36,28 @@ RSpec.describe 'Every metric definition' do
user_secret_detection_scans
user_coverage_fuzzing_scans
user_api_fuzzing_scans
topology
)
.
freeze
end
let
(
:metric_files_key_paths
)
do
Gitlab
::
Usage
::
MetricDefinition
.
definitions
.
reject
{
|
k
,
v
|
v
.
status
==
'removed'
||
v
.
key_path
=~
Regexp
.
union
(
ignored_metric_files_key_patterns
)}
.
reject
{
|
k
,
v
|
v
.
status
==
'removed'
||
v
.
key_path
=~
Regexp
.
union
(
ignored_metric_files_key_patterns
)
}
.
keys
.
sort
end
let
(
:metric_files_with_schema
)
do
Gitlab
::
Usage
::
MetricDefinition
.
definitions
.
select
{
|
k
,
v
|
v
.
respond_to?
(
:value_json_schema
)
}
.
keys
end
# Recursively traverse nested Hash of a generated Usage Ping to return an Array of key paths
# in the dotted format used in metric definition YAML files, e.g.: 'count.category.metric_name'
def
parse_usage_ping_keys
(
object
,
key_path
=
[])
if
object
.
is_a?
Hash
if
object
.
is_a?
(
Hash
)
&&
!
object_with_schema?
(
key_path
.
join
(
'.'
))
object
.
each_with_object
([])
do
|
(
key
,
value
),
result
|
result
.
append
parse_usage_ping_keys
(
value
,
key_path
+
[
key
])
end
...
...
@@ -62,6 +66,10 @@ RSpec.describe 'Every metric definition' do
end
end
def
object_with_schema?
(
key_path
)
metric_files_with_schema
.
include?
(
key_path
)
end
before
do
allow
(
Gitlab
::
UsageData
).
to
receive_messages
(
count:
-
1
,
distinct_count:
-
1
,
estimate_batch_distinct_count:
-
1
,
sum:
-
1
,
alt_usage_data:
-
1
)
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
).
and_return
(
true
)
...
...
lib/gitlab/usage/metric_definition.rb
View file @
5dce47e8
...
...
@@ -114,6 +114,10 @@ module Gitlab
attributes
[
method
]
||
super
end
def
respond_to_missing?
(
method
,
*
args
)
attributes
[
method
].
present?
||
super
end
def
skip_validation?
!!
attributes
[
:skip_validation
]
||
@skip_validation
||
SKIP_VALIDATION_STATUSES
.
include?
(
attributes
[
:status
])
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