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
43021bb2
Commit
43021bb2
authored
Dec 30, 2021
by
Dmitry Gruzd
Committed by
Kerri Miller
Dec 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track version of Elasticsearch server used by self hosted clients
parent
ccf33f48
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
0 deletions
+104
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+11
-0
ee/lib/gitlab/elastic/helper.rb
ee/lib/gitlab/elastic/helper.rb
+13
-0
ee/lib/gitlab/usage/metrics/instrumentations/advanced_search_metric.rb
.../usage/metrics/instrumentations/advanced_search_metric.rb
+17
-0
ee/spec/lib/ee/gitlab/elastic/helper_spec.rb
ee/spec/lib/ee/gitlab/elastic/helper_spec.rb
+53
-0
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+10
-0
No files found.
ee/lib/ee/gitlab/usage_data.rb
View file @
43021bb2
...
...
@@ -115,6 +115,17 @@ module EE
usage_data
end
override
:components_usage_data
def
components_usage_data
usage_data
=
super
if
::
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
usage_data
[
:advanced_search
]
=
add_metric
(
"AdvancedSearchMetric"
)
end
usage_data
end
def
requirements_counts
return
{}
unless
::
License
.
feature_available?
(
:requirements
)
...
...
ee/lib/gitlab/elastic/helper.rb
View file @
43021bb2
...
...
@@ -285,6 +285,19 @@ module Gitlab
false
end
def
server_info
info
=
client
.
info
.
fetch
(
'version'
,
{})
{
distribution:
info
.
fetch
(
'distribution'
,
'elasticsearch'
),
version:
info
[
'number'
],
build_type:
info
[
'build_type'
],
lucene_version:
info
[
'lucene_version'
]
}
rescue
StandardError
{}
end
private
def
create_index
(
index_name
,
alias_name
,
with_alias
,
settings
,
mappings
,
options
)
...
...
ee/lib/gitlab/usage/metrics/instrumentations/advanced_search_metric.rb
0 → 100644
View file @
43021bb2
# frozen_string_literal: true
module
Gitlab
module
Usage
module
Metrics
module
Instrumentations
class
AdvancedSearchMetric
<
GenericMetric
fallback
({})
value
do
::
Gitlab
::
Elastic
::
Helper
.
default
.
server_info
end
end
end
end
end
end
ee/spec/lib/ee/gitlab/elastic/helper_spec.rb
View file @
43021bb2
...
...
@@ -394,4 +394,57 @@ RSpec.describe Gitlab::Elastic::Helper, :request_store do
is_expected
.
to
include
(
'created_by'
=>
Gitlab
::
VERSION
)
end
end
describe
'#server_info'
do
subject
{
helper
.
server_info
}
context
'server is accessible'
do
before
do
allow
(
Gitlab
::
Elastic
::
Helper
.
default
.
client
).
to
receive
(
:info
).
and_return
(
info
)
end
context
'using elasticsearch'
do
let
(
:info
)
do
{
'version'
=>
{
'number'
=>
'7.9.3'
,
'build_type'
=>
'docker'
,
'lucene_version'
=>
'8.6.2'
}
}
end
it
'returns server info'
do
is_expected
.
to
include
(
distribution:
'elasticsearch'
,
version:
'7.9.3'
,
build_type:
'docker'
,
lucene_version:
'8.6.2'
)
end
end
context
'using opensearch'
do
let
(
:info
)
do
{
'version'
=>
{
'distribution'
=>
'opensearch'
,
'number'
=>
'1.0.0'
,
'build_type'
=>
'tar'
,
'lucene_version'
=>
'8.10.1'
}
}
end
it
'returns server info'
do
is_expected
.
to
include
(
distribution:
'opensearch'
,
version:
'1.0.0'
,
build_type:
'tar'
,
lucene_version:
'8.10.1'
)
end
end
end
context
'server is inaccessible'
do
before
do
allow
(
Gitlab
::
Elastic
::
Helper
.
default
.
client
).
to
receive
(
:info
).
and_raise
(
StandardError
)
end
it
'returns empty hash'
do
is_expected
.
to
eq
({})
end
end
end
end
ee/spec/lib/ee/gitlab/usage_data_spec.rb
View file @
43021bb2
...
...
@@ -182,6 +182,16 @@ RSpec.describe Gitlab::UsageData do
end
end
describe
'.components_usage_data'
do
subject
{
described_class
.
components_usage_data
}
it
'gathers components usage data'
do
stub_ee_application_setting
(
elasticsearch_indexing:
true
)
expect
(
subject
[
:advanced_search
]).
to
eq
(
Gitlab
::
Elastic
::
Helper
.
default
.
server_info
)
end
end
describe
'.requirements_counts'
do
subject
{
described_class
.
requirements_counts
}
...
...
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