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
70a1e8bd
Commit
70a1e8bd
authored
Jun 18, 2021
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method for_data_warehouse
parent
0f05c6af
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
3650 additions
and
5 deletions
+3650
-5
lib/gitlab/usage/metrics/instrumentations/base_metric.rb
lib/gitlab/usage/metrics/instrumentations/base_metric.rb
+2
-2
lib/gitlab/usage/metrics/instrumentations/database_metric.rb
lib/gitlab/usage/metrics/instrumentations/database_metric.rb
+4
-0
lib/gitlab/usage/metrics/instrumentations/generic_metric.rb
lib/gitlab/usage/metrics/instrumentations/generic_metric.rb
+5
-0
lib/gitlab/usage_data_non_sql_metrics.rb
lib/gitlab/usage_data_non_sql_metrics.rb
+1
-1
lib/gitlab/usage_data_queries.rb
lib/gitlab/usage_data_queries.rb
+1
-1
queries.yml
queries.yml
+3628
-0
spec/lib/gitlab/usage_data_non_sql_metrics_spec.rb
spec/lib/gitlab/usage_data_non_sql_metrics_spec.rb
+8
-0
spec/lib/gitlab/usage_data_queries_spec.rb
spec/lib/gitlab/usage_data_queries_spec.rb
+1
-1
No files found.
lib/gitlab/usage/metrics/instrumentations/base_metric.rb
View file @
70a1e8bd
...
...
@@ -11,12 +11,12 @@ module Gitlab
attr_reader
:time_frame
attr_reader
:options
def
initialize
(
time_frame:
'none'
,
options:
{})
def
initialize
(
time_frame
:,
options:
{})
@time_frame
=
time_frame
@options
=
options
end
def
to_sql
def
for_data_warehouse
value
end
end
...
...
lib/gitlab/usage/metrics/instrumentations/database_metric.rb
View file @
70a1e8bd
...
...
@@ -59,6 +59,10 @@ module Gitlab
Gitlab
::
Usage
::
Metrics
::
Query
.
for
(
self
.
class
.
metric_operation
,
relation
,
self
.
class
.
column
)
end
def
for_data_warehouse
to_sql
end
def
suggested_name
Gitlab
::
Usage
::
Metrics
::
NameSuggestion
.
for
(
self
.
class
.
metric_operation
,
...
...
lib/gitlab/usage/metrics/instrumentations/generic_metric.rb
View file @
70a1e8bd
...
...
@@ -28,6 +28,11 @@ module Gitlab
end
end
def
initialize
(
time_frame:
'none'
,
options:
{})
@time_frame
=
time_frame
@options
=
options
end
def
value
alt_usage_data
(
fallback:
self
.
class
.
fallback
)
do
self
.
class
.
metric_value
.
call
...
...
lib/gitlab/usage_data_non_sql_metrics.rb
View file @
70a1e8bd
...
...
@@ -6,7 +6,7 @@ module Gitlab
class
<<
self
def
add_metric
(
metric
)
metric
.
value
unless
metric
.
is_a?
(
Gitlab
::
Usage
::
Metrics
::
Instrumentations
::
DatabaseMetric
)
metric
.
for_data_warehouse
end
def
count
(
relation
,
column
=
nil
,
batch:
true
,
batch_size:
nil
,
start:
nil
,
finish:
nil
)
...
...
lib/gitlab/usage_data_queries.rb
View file @
70a1e8bd
...
...
@@ -6,7 +6,7 @@ module Gitlab
class
UsageDataQueries
<
UsageData
class
<<
self
def
add_metric
(
metric
)
metric
.
to_sql
metric
.
for_data_warehouse
end
def
count
(
relation
,
column
=
nil
,
*
args
,
**
kwargs
)
...
...
queries.yml
0 → 100644
View file @
70a1e8bd
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/lib/gitlab/usage_data_non_sql_metrics_spec.rb
View file @
70a1e8bd
...
...
@@ -5,6 +5,14 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
UsageDataNonSqlMetrics
do
let
(
:default_count
)
{
Gitlab
::
UsageDataNonSqlMetrics
::
SQL_METRIC_DEFAULT
}
describe
'#add_metric'
do
let
(
:metric
)
{
double
(
:metric
,
for_data_warehouse:
1
)
}
it
'computes the metric value for given metric'
do
expect
(
described_class
.
add_metric
(
metric
)).
to
eq
(
1
)
end
end
describe
'.count'
do
it
'returns default value for count'
do
expect
(
described_class
.
count
(
User
)).
to
eq
(
default_count
)
...
...
spec/lib/gitlab/usage_data_queries_spec.rb
View file @
70a1e8bd
...
...
@@ -8,7 +8,7 @@ RSpec.describe Gitlab::UsageDataQueries do
end
describe
'#add_metric'
do
let
(
:metric
)
{
double
(
:metric
,
to_sql
:
'SELECT COUNT("users"."id") FROM "users"'
)
}
let
(
:metric
)
{
double
(
:metric
,
for_data_warehouse
:
'SELECT COUNT("users"."id") FROM "users"'
)
}
it
'computes the metric value for given metric'
do
expect
(
described_class
.
add_metric
(
metric
)).
to
eq
(
'SELECT COUNT("users"."id") FROM "users"'
)
...
...
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