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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
46cd2d93
Commit
46cd2d93
authored
Nov 23, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use feature flag instead of application settigns to control if method calls should be instrumented
parent
0ae2d9e6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
7 additions
and
38 deletions
+7
-38
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+0
-1
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+0
-8
db/migrate/20171122211913_add_prometheus_instrumentation_to_application_settings.rb
...add_prometheus_instrumentation_to_application_settings.rb
+0
-15
db/schema.rb
db/schema.rb
+1
-2
lib/api/settings.rb
lib/api/settings.rb
+0
-3
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+3
-3
spec/lib/gitlab/metrics/method_call_spec.rb
spec/lib/gitlab/metrics/method_call_spec.rb
+3
-6
No files found.
app/helpers/application_settings_helper.rb
View file @
46cd2d93
...
@@ -211,7 +211,6 @@ module ApplicationSettingsHelper
...
@@ -211,7 +211,6 @@ module ApplicationSettingsHelper
:polling_interval_multiplier
,
:polling_interval_multiplier
,
:project_export_enabled
,
:project_export_enabled
,
:prometheus_metrics_enabled
,
:prometheus_metrics_enabled
,
:prometheus_metrics_method_instrumentation_enabled
,
:recaptcha_enabled
,
:recaptcha_enabled
,
:recaptcha_private_key
,
:recaptcha_private_key
,
:recaptcha_site_key
,
:recaptcha_site_key
,
...
...
app/views/admin/application_settings/_form.html.haml
View file @
46cd2d93
...
@@ -361,14 +361,6 @@
...
@@ -361,14 +361,6 @@
%code
prometheus_multiproc_dir
%code
prometheus_multiproc_dir
does not exist or is not pointing to a valid directory.
does not exist or is not pointing to a valid directory.
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'administration/monitoring/prometheus/gitlab_metrics'
,
anchor:
'metrics-shared-directory'
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'administration/monitoring/prometheus/gitlab_metrics'
,
anchor:
'metrics-shared-directory'
)
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
=
f
.
label
:prometheus_metrics_method_instrumentation_enabled
do
=
f
.
check_box
:prometheus_metrics_method_instrumentation_enabled
Track method execution time.
.help-block
Provides method execution metrics. Can adversely impact GitLab's responsiveness.
%fieldset
%fieldset
%legend
Profiling - Performance Bar
%legend
Profiling - Performance Bar
...
...
db/migrate/20171122211913_add_prometheus_instrumentation_to_application_settings.rb
deleted
100644 → 0
View file @
0ae2d9e6
class
AddPrometheusInstrumentationToApplicationSettings
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
(
:application_settings
,
:prometheus_metrics_method_instrumentation_enabled
,
:boolean
,
default:
false
,
allow_null:
false
)
end
def
down
remove_column
(
:application_settings
,
:prometheus_metrics_method_instrumentation_enabled
)
end
end
db/schema.rb
View file @
46cd2d93
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2017112
2211913
)
do
ActiveRecord
::
Schema
.
define
(
version:
2017112
1144800
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -149,7 +149,6 @@ ActiveRecord::Schema.define(version: 20171122211913) do
...
@@ -149,7 +149,6 @@ ActiveRecord::Schema.define(version: 20171122211913) do
t
.
boolean
"throttle_authenticated_web_enabled"
,
default:
false
,
null:
false
t
.
boolean
"throttle_authenticated_web_enabled"
,
default:
false
,
null:
false
t
.
integer
"throttle_authenticated_web_requests_per_period"
,
default:
7200
,
null:
false
t
.
integer
"throttle_authenticated_web_requests_per_period"
,
default:
7200
,
null:
false
t
.
integer
"throttle_authenticated_web_period_in_seconds"
,
default:
3600
,
null:
false
t
.
integer
"throttle_authenticated_web_period_in_seconds"
,
default:
3600
,
null:
false
t
.
boolean
"prometheus_metrics_method_instrumentation_enabled"
,
default:
false
,
null:
false
end
end
create_table
"audit_events"
,
force: :cascade
do
|
t
|
create_table
"audit_events"
,
force: :cascade
do
|
t
|
...
...
lib/api/settings.rb
View file @
46cd2d93
...
@@ -66,9 +66,6 @@ module API
...
@@ -66,9 +66,6 @@ module API
optional
:max_pages_size
,
type:
Integer
,
desc:
'Maximum size of pages in MB'
optional
:max_pages_size
,
type:
Integer
,
desc:
'Maximum size of pages in MB'
optional
:container_registry_token_expire_delay
,
type:
Integer
,
desc:
'Authorization token duration (minutes)'
optional
:container_registry_token_expire_delay
,
type:
Integer
,
desc:
'Authorization token duration (minutes)'
optional
:prometheus_metrics_enabled
,
type:
Boolean
,
desc:
'Enable Prometheus metrics'
optional
:prometheus_metrics_enabled
,
type:
Boolean
,
desc:
'Enable Prometheus metrics'
given
prometheus_metrics_enabled:
->
(
val
)
{
val
}
do
requires
:prometheus_metrics_method_instrumentation_enabled
,
type:
Boolean
,
desc:
'Enable method call instrumentation'
end
optional
:metrics_enabled
,
type:
Boolean
,
desc:
'Enable the InfluxDB metrics'
optional
:metrics_enabled
,
type:
Boolean
,
desc:
'Enable the InfluxDB metrics'
given
metrics_enabled:
->
(
val
)
{
val
}
do
given
metrics_enabled:
->
(
val
)
{
val
}
do
requires
:metrics_host
,
type:
String
,
desc:
'The InfluxDB host'
requires
:metrics_host
,
type:
String
,
desc:
'The InfluxDB host'
...
...
lib/gitlab/metrics/method_call.rb
View file @
46cd2d93
...
@@ -45,7 +45,7 @@ module Gitlab
...
@@ -45,7 +45,7 @@ module Gitlab
@cpu_time
+=
cpu_time
@cpu_time
+=
cpu_time
@call_count
+=
1
@call_count
+=
1
if
prometheus
_enabled?
&&
above_threshold?
if
call_measurement
_enabled?
&&
above_threshold?
self
.
class
.
call_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
labels
),
real_time
/
1000.0
)
self
.
class
.
call_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
labels
),
real_time
/
1000.0
)
end
end
...
@@ -71,8 +71,8 @@ module Gitlab
...
@@ -71,8 +71,8 @@ module Gitlab
real_time
>=
Metrics
.
method_call_threshold
real_time
>=
Metrics
.
method_call_threshold
end
end
def
prometheus
_enabled?
def
call_measurement
_enabled?
@prometheus_enabled
||=
Gitlab
::
CurrentSettings
.
current_application_settings
[
:prometheus_metrics_method_instrumentation_enabled
]
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enabled?
end
end
end
end
end
end
...
...
spec/lib/gitlab/metrics/method_call_spec.rb
View file @
46cd2d93
...
@@ -20,8 +20,7 @@ describe Gitlab::Metrics::MethodCall do
...
@@ -20,8 +20,7 @@ describe Gitlab::Metrics::MethodCall do
context
'prometheus instrumentation is enabled'
do
context
'prometheus instrumentation is enabled'
do
before
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:current_application_settings
)
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enable
.
and_return
(
prometheus_metrics_method_instrumentation_enabled:
true
)
end
end
it
'observes the performance of the supplied block'
do
it
'observes the performance of the supplied block'
do
...
@@ -35,8 +34,7 @@ describe Gitlab::Metrics::MethodCall do
...
@@ -35,8 +34,7 @@ describe Gitlab::Metrics::MethodCall do
context
'prometheus instrumentation is disabled'
do
context
'prometheus instrumentation is disabled'
do
before
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:current_application_settings
)
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
disable
.
and_return
(
prometheus_metrics_method_instrumentation_enabled:
false
)
end
end
it
'does not observe the performance'
do
it
'does not observe the performance'
do
...
@@ -52,8 +50,7 @@ describe Gitlab::Metrics::MethodCall do
...
@@ -52,8 +50,7 @@ describe Gitlab::Metrics::MethodCall do
before
do
before
do
allow
(
method_call
).
to
receive
(
:above_threshold?
).
and_return
(
false
)
allow
(
method_call
).
to
receive
(
:above_threshold?
).
and_return
(
false
)
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:current_application_settings
)
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enable
.
and_return
(
prometheus_metrics_method_instrumentation_enabled:
true
)
end
end
it
'does not observe the performance'
do
it
'does not observe the performance'
do
...
...
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