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
229b520f
Commit
229b520f
authored
Oct 18, 2021
by
Niko Belokolodov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate License metrics to one class
parent
0049f328
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
88 additions
and
9 deletions
+88
-9
ee/config/metrics/license/20210204124831_license_md5.yml
ee/config/metrics/license/20210204124831_license_md5.yml
+7
-4
ee/config/metrics/license/20210204124833_license_id.yml
ee/config/metrics/license/20210204124833_license_id.yml
+4
-0
ee/config/metrics/license/20210204124843_license_user_count.yml
...fig/metrics/license/20210204124843_license_user_count.yml
+4
-0
ee/config/metrics/license/20210204124845_license_starts_at.yml
...nfig/metrics/license/20210204124845_license_starts_at.yml
+4
-0
ee/config/metrics/license/20210204124847_license_expires_at.yml
...fig/metrics/license/20210204124847_license_expires_at.yml
+4
-0
ee/config/metrics/license/20210204124849_license_plan.yml
ee/config/metrics/license/20210204124849_license_plan.yml
+4
-0
ee/config/metrics/license/20210204124851_license_trial.yml
ee/config/metrics/license/20210204124851_license_trial.yml
+4
-0
ee/config/metrics/license/20210204124852_license_subscription_id.yml
...etrics/license/20210204124852_license_subscription_id.yml
+4
-1
ee/config/metrics/license/20210204124926_license_trial_ends_on.yml
.../metrics/license/20210204124926_license_trial_ends_on.yml
+4
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+1
-1
ee/lib/gitlab/usage/metrics/instrumentations/license_metric.rb
...b/gitlab/usage/metrics/instrumentations/license_metric.rb
+46
-0
lib/gitlab/utils/usage_data.rb
lib/gitlab/utils/usage_data.rb
+2
-3
No files found.
ee/config/metrics/license/20210204124831_license_md5.yml
View file @
229b520f
...
@@ -9,13 +9,16 @@ value_type: string
...
@@ -9,13 +9,16 @@ value_type: string
status
:
active
status
:
active
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
instrumentation_class
:
LicenseMdFiveMetric
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
md5
data_category
:
standard
data_category
:
standard
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
-
premium
-
premium
-
ultimate
-
ultimate
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/557
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/557
performance_indicator_type
:
[]
performance_indicator_type
:
[]
milestone
:
"
<13.9"
milestone
:
"
<13.9"
ee/config/metrics/license/20210204124833_license_id.yml
View file @
229b520f
...
@@ -10,6 +10,10 @@ status: active
...
@@ -10,6 +10,10 @@ status: active
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
data_category
:
subscription
data_category
:
subscription
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
id
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
...
...
ee/config/metrics/license/20210204124843_license_user_count.yml
View file @
229b520f
...
@@ -10,6 +10,10 @@ status: active
...
@@ -10,6 +10,10 @@ status: active
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
data_category
:
subscription
data_category
:
subscription
instrumentation_class
:
LicenseMetric
options
:
attribute
:
user_count
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
...
...
ee/config/metrics/license/20210204124845_license_starts_at.yml
View file @
229b520f
...
@@ -10,6 +10,10 @@ status: active
...
@@ -10,6 +10,10 @@ status: active
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
data_category
:
subscription
data_category
:
subscription
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
starts_at
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
...
...
ee/config/metrics/license/20210204124847_license_expires_at.yml
View file @
229b520f
...
@@ -10,6 +10,10 @@ status: active
...
@@ -10,6 +10,10 @@ status: active
data_category
:
subscription
data_category
:
subscription
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
expires_at
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
...
...
ee/config/metrics/license/20210204124849_license_plan.yml
View file @
229b520f
...
@@ -10,6 +10,10 @@ status: active
...
@@ -10,6 +10,10 @@ status: active
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
data_category
:
subscription
data_category
:
subscription
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
plan
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
...
...
ee/config/metrics/license/20210204124851_license_trial.yml
View file @
229b520f
...
@@ -10,6 +10,10 @@ status: active
...
@@ -10,6 +10,10 @@ status: active
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
data_category
:
subscription
data_category
:
subscription
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
trial
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
...
...
ee/config/metrics/license/20210204124852_license_subscription_id.yml
View file @
229b520f
...
@@ -9,7 +9,10 @@ value_type: string
...
@@ -9,7 +9,10 @@ value_type: string
status
:
active
status
:
active
time_frame
:
none
time_frame
:
none
data_source
:
license
data_source
:
license
instrumentation_class
:
ZuoraSubscriptionIdMetric
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
subsription_id
data_category
:
standard
data_category
:
standard
distribution
:
distribution
:
-
ee
-
ee
...
...
ee/config/metrics/license/20210204124926_license_trial_ends_on.yml
View file @
229b520f
...
@@ -10,6 +10,10 @@ status: active
...
@@ -10,6 +10,10 @@ status: active
time_frame
:
none
time_frame
:
none
data_source
:
database
data_source
:
database
data_category
:
subscription
data_category
:
subscription
instrumentation_class
:
LicenseMetric
options
:
attribute
:
-
trial_ends_on
distribution
:
distribution
:
-
ee
-
ee
tier
:
tier
:
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
229b520f
...
@@ -72,7 +72,7 @@ module EE
...
@@ -72,7 +72,7 @@ module EE
def
features_usage_data_ee
def
features_usage_data_ee
{
{
elasticsearch_enabled:
alt_usage_data
(
fallback:
nil
)
{
::
Gitlab
::
CurrentSettings
.
elasticsearch_search?
},
elasticsearch_enabled:
alt_usage_data
(
fallback:
nil
)
{
::
Gitlab
::
CurrentSettings
.
elasticsearch_search?
},
license_trial_ends_on:
alt_usage_data
(
fallback:
nil
)
{
License
.
trial_ends_on
},
license_trial_ends_on:
alt_usage_data
(
fallback:
nil
)
{
add_metric
(
"LicenseMetric"
,
options:
{
attribute: :trial_ends_on
})
},
geo_enabled:
alt_usage_data
(
fallback:
nil
)
{
::
Gitlab
::
Geo
.
enabled?
},
geo_enabled:
alt_usage_data
(
fallback:
nil
)
{
::
Gitlab
::
Geo
.
enabled?
},
user_cap_feature_enabled:
add_metric
(
'UserCapSettingEnabledMetric'
,
time_frame:
'none'
)
user_cap_feature_enabled:
add_metric
(
'UserCapSettingEnabledMetric'
,
time_frame:
'none'
)
}
}
...
...
ee/lib/gitlab/usage/metrics/instrumentations/license_metric.rb
0 → 100644
View file @
229b520f
# frozen_string_literal: true
module
Gitlab
module
Usage
module
Metrics
module
Instrumentations
class
LicenseMetric
<
GenericMetric
# Usage example
#
# In metric YAML defintion
# instrumentation_class: LicenseMetric
# options:
# attribute: md5
# end
ALLOWED_ATTRIBUTES
=
%i(md5
id
plan
trial
starts_at
expires_at
user_count
trial_ends_on
subscription_id)
.
freeze
def
initialize
(
time_frame
:,
options:
{})
super
raise
ArgumentError
,
"License options attribute are required"
unless
license_attribute
.
present?
raise
ArgumentError
,
"attribute should one allowed"
unless
license_attribute
.
in?
(
ALLOWED_ATTRIBUTES
)
end
def
license_attribute
options
[
:attribute
]
end
def
value
alt_usage_data
(
fallback:
-
1
)
do
::
Licese
.
current
.
send
(
license_attribute
)
end
end
end
end
end
end
end
lib/gitlab/utils/usage_data.rb
View file @
229b520f
...
@@ -45,14 +45,13 @@ module Gitlab
...
@@ -45,14 +45,13 @@ module Gitlab
MAX_BUCKET_SIZE
=
100
MAX_BUCKET_SIZE
=
100
INSTRUMENTATION_CLASS_FALLBACK
=
-
100
INSTRUMENTATION_CLASS_FALLBACK
=
-
100
def
add_metric
(
metric
,
time_frame:
'none'
)
def
add_metric
(
metric
,
time_frame:
'none'
,
options:
{}
)
# Results of this method should be overwritten by instrumentation class values
# Results of this method should be overwritten by instrumentation class values
# -100 indicates the metric was not properly merged.
# -100 indicates the metric was not properly merged.
return
INSTRUMENTATION_CLASS_FALLBACK
if
Feature
.
enabled?
(
:usage_data_instrumentation
)
return
INSTRUMENTATION_CLASS_FALLBACK
if
Feature
.
enabled?
(
:usage_data_instrumentation
)
metric_class
=
"Gitlab::Usage::Metrics::Instrumentations::
#{
metric
}
"
.
constantize
metric_class
=
"Gitlab::Usage::Metrics::Instrumentations::
#{
metric
}
"
.
constantize
metric_class
.
new
(
time_frame:
time_frame
).
value
metric_class
.
new
(
time_frame:
time_frame
,
options:
options
).
value
end
end
def
count
(
relation
,
column
=
nil
,
batch:
true
,
batch_size:
nil
,
start:
nil
,
finish:
nil
)
def
count
(
relation
,
column
=
nil
,
batch:
true
,
batch_size:
nil
,
start:
nil
,
finish:
nil
)
...
...
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