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
Kazuhiko Shiozaki
gitlab-ce
Commits
a1251746
Commit
a1251746
authored
Dec 29, 2015
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'influxdb-current-settings' into 'master'
See merge request !2239
parents
1dbf7284
701e5de9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
25 deletions
+11
-25
lib/gitlab/metrics.rb
lib/gitlab/metrics.rb
+11
-25
No files found.
lib/gitlab/metrics.rb
View file @
a1251746
module
Gitlab
module
Metrics
extend
Gitlab
::
CurrentSettings
RAILS_ROOT
=
Rails
.
root
.
to_s
METRICS_ROOT
=
Rails
.
root
.
join
(
'lib'
,
'gitlab'
,
'metrics'
).
to_s
PATH_REGEX
=
/^
#{
RAILS_ROOT
}
\/?/
# Returns the current settings, ensuring we _always_ have a default set of
# metrics settings (even during tests, when the migrations are lacking,
# etc). This ensures the application is able to boot up even when the
# migrations have not been executed.
def
self
.
settings
if
ApplicationSetting
.
table_exists?
and
curr
=
ApplicationSetting
.
current
curr
else
{
metrics_pool_size:
16
,
metrics_timeout:
10
,
metrics_enabled:
false
,
metrics_method_call_threshold:
10
}
end
end
def
self
.
pool_size
settings
[
:metrics_pool_size
]
current_application_settings
[
:metrics_pool_size
]
||
16
end
def
self
.
timeout
settings
[
:metrics_timeout
]
current_application_settings
[
:metrics_timeout
]
||
10
end
def
self
.
enabled?
settings
[
:metrics_enabled
]
current_application_settings
[
:metrics_enabled
]
||
false
end
def
self
.
mri?
...
...
@@ -41,7 +26,8 @@ module Gitlab
# This is memoized since this method is called for every instrumented
# method. Loading data from an external cache on every method call slows
# things down too much.
@method_call_threshold
||=
settings
[
:metrics_method_call_threshold
]
@method_call_threshold
||=
(
current_application_settings
[
:metrics_method_call_threshold
]
||
10
)
end
def
self
.
pool
...
...
@@ -105,10 +91,10 @@ module Gitlab
# "@foo ||= bar" is _not_ thread-safe.
if
enabled?
@pool
=
ConnectionPool
.
new
(
size:
pool_size
,
timeout:
timeout
)
do
host
=
settings
[
:metrics_host
]
user
=
settings
[
:metrics_username
]
pw
=
settings
[
:metrics_password
]
port
=
settings
[
:metrics_port
]
host
=
current_application_
settings
[
:metrics_host
]
user
=
current_application_
settings
[
:metrics_username
]
pw
=
current_application_
settings
[
:metrics_password
]
port
=
current_application_
settings
[
:metrics_port
]
InfluxDB
::
Client
.
new
(
udp:
{
host:
host
,
port:
port
},
username:
user
,
password:
pw
)
...
...
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