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
5118ca34
Commit
5118ca34
authored
Aug 13, 2021
by
Heinrich Lee Yu
Committed by
Alex Kalderimis
Aug 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Zeitwerk autoloader
Switches from Rails classic autoloader to Zeitwerk
parent
ad862f26
Changes
28
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
107 additions
and
79 deletions
+107
-79
.rubocop_manual_todo.yml
.rubocop_manual_todo.yml
+0
-1
config/application.rb
config/application.rb
+5
-1
config/initializers/2_gitlab.rb
config/initializers/2_gitlab.rb
+0
-3
config/initializers_before_autoloader/004_zeitwerk.rb
config/initializers_before_autoloader/004_zeitwerk.rb
+2
-6
config/routes/project.rb
config/routes/project.rb
+1
-1
config/settings.rb
config/settings.rb
+0
-6
ee/lib/ee/gitlab/metrics/samplers/database_sampler.rb
ee/lib/ee/gitlab/metrics/samplers/database_sampler.rb
+2
-2
ee/lib/generators/geo_migration/geo_migration_generator.rb
ee/lib/generators/geo_migration/geo_migration_generator.rb
+17
-0
generator_templates/post_deployment_migration/post_deployment_migration/migration.rb
...ployment_migration/post_deployment_migration/migration.rb
+0
-0
lib/gem_extensions/active_record/delegate_cache.rb
lib/gem_extensions/active_record/delegate_cache.rb
+1
-1
lib/generators/gitlab/usage_metric_generator.rb
lib/generators/gitlab/usage_metric_generator.rb
+1
-1
lib/generators/post_deployment_migration/post_deployment_migration_generator.rb
...ployment_migration/post_deployment_migration_generator.rb
+1
-1
lib/gitlab/database/load_balancing/host.rb
lib/gitlab/database/load_balancing/host.rb
+7
-7
lib/gitlab/database/load_balancing/rack_middleware.rb
lib/gitlab/database/load_balancing/rack_middleware.rb
+6
-6
lib/gitlab/import_export/project/object_builder.rb
lib/gitlab/import_export/project/object_builder.rb
+1
-1
lib/gitlab/metrics/requests_rack_middleware.rb
lib/gitlab/metrics/requests_rack_middleware.rb
+7
-7
lib/gitlab/metrics/samplers/base_sampler.rb
lib/gitlab/metrics/samplers/base_sampler.rb
+1
-1
lib/gitlab/metrics/subscribers/action_view.rb
lib/gitlab/metrics/subscribers/action_view.rb
+1
-1
lib/gitlab/metrics/subscribers/rails_cache.rb
lib/gitlab/metrics/subscribers/rails_cache.rb
+1
-1
lib/gitlab/query_limiting/active_support_subscriber.rb
lib/gitlab/query_limiting/active_support_subscriber.rb
+3
-3
lib/gitlab/query_limiting/middleware.rb
lib/gitlab/query_limiting/middleware.rb
+1
-1
lib/gitlab/usage/metrics/aggregates.rb
lib/gitlab/usage/metrics/aggregates.rb
+26
-0
lib/gitlab/usage/metrics/aggregates/aggregate.rb
lib/gitlab/usage/metrics/aggregates/aggregate.rb
+0
-17
lib/gitlab/usage/metrics/aggregates/sources.rb
lib/gitlab/usage/metrics/aggregates/sources.rb
+13
-0
lib/gitlab/usage/metrics/aggregates/sources/redis_hll.rb
lib/gitlab/usage/metrics/aggregates/sources/redis_hll.rb
+0
-2
spec/fast_spec_helper.rb
spec/fast_spec_helper.rb
+5
-3
spec/lib/gitlab/database/load_balancing/rack_middleware_spec.rb
...ib/gitlab/database/load_balancing/rack_middleware_spec.rb
+4
-5
spec/services/service_response_spec.rb
spec/services/service_response_spec.rb
+1
-1
No files found.
.rubocop_manual_todo.yml
View file @
5118ca34
...
...
@@ -2305,7 +2305,6 @@ Gitlab/NamespacedClass:
-
'
ee/app/workers/sync_security_reports_to_report_approval_rules_worker.rb'
-
'
ee/app/workers/update_all_mirrors_worker.rb'
-
'
ee/app/workers/update_max_seats_used_for_gitlab_com_subscriptions_worker.rb'
-
'
ee/lib/generators/rails/geo_migration_generator.rb'
-
'
ee/lib/gitlab/path_locks_finder.rb'
-
'
ee/spec/support/elastic_query_name_inspector.rb'
-
'
ee/spec/support/ssh_keygen.rb'
...
...
config/application.rb
View file @
5118ca34
...
...
@@ -32,7 +32,7 @@ module Gitlab
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/rack_multipart_tempfile_factory'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/runtime'
)
config
.
autoloader
=
:
classic
config
.
autoloader
=
:
zeitwerk
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
...
...
@@ -86,7 +86,11 @@ module Gitlab
# Rake tasks ignore the eager loading settings, so we need to set the
# autoload paths explicitly
config
.
autoload_paths
=
config
.
eager_load_paths
.
dup
# These are only used in Rake tasks so we don't need to add these to eager_load_paths
config
.
autoload_paths
.
push
(
"
#{
config
.
root
}
/lib/generators"
)
Gitlab
.
ee
{
config
.
autoload_paths
.
push
(
"
#{
config
.
root
}
/ee/lib/generators"
)
}
Gitlab
.
jh
{
config
.
autoload_paths
.
push
(
"
#{
config
.
root
}
/jh/lib/generators"
)
}
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
...
...
config/initializers/2_gitlab.rb
deleted
100644 → 0
View file @
ad862f26
# frozen_string_literal: true
require_dependency
'gitlab'
config/initializers_before_autoloader/004_zeitwerk.rb
View file @
5118ca34
...
...
@@ -5,15 +5,11 @@ Rails.autoloaders.each do |autoloader|
# that do not define Ruby classes / modules
autoloader
.
ignore
(
Rails
.
root
.
join
(
'lib/support'
))
# Ignore generators since these are loaded manually by Rails
# https://github.com/rails/rails/blob/v6.1.3.2/railties/lib/rails/command/behavior.rb#L56-L65
autoloader
.
ignore
(
Rails
.
root
.
join
(
'lib/generators'
))
autoloader
.
ignore
(
Rails
.
root
.
join
(
'ee/lib/generators'
))
if
Gitlab
.
ee?
# Mailer previews are also loaded manually by Rails
# Mailer previews are loaded manually by Rails
# https://github.com/rails/rails/blob/v6.1.3.2/actionmailer/lib/action_mailer/preview.rb#L121-L125
autoloader
.
ignore
(
Rails
.
root
.
join
(
'app/mailers/previews'
))
autoloader
.
ignore
(
Rails
.
root
.
join
(
'ee/app/mailers/previews'
))
if
Gitlab
.
ee?
autoloader
.
ignore
(
Rails
.
root
.
join
(
'jh/app/mailers/previews'
))
if
Gitlab
.
jh?
autoloader
.
inflector
.
inflect
(
'api'
=>
'API'
,
...
...
config/routes/project.rb
View file @
5118ca34
...
...
@@ -389,7 +389,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
namespace
:design_management
do
namespace
:designs
,
path:
'designs/:design_id(/:sha)'
,
constraints:
->
(
params
)
{
params
[
:sha
].
nil?
||
Gitlab
::
Git
.
commit_id?
(
params
[
:sha
])
}
do
resource
:raw_image
,
only: :show
resources
:resized_image
,
only: :show
,
constraints:
->
(
params
)
{
DesignManagement
::
DESIGN_IMAGE_SIZES
.
include?
(
params
[
:id
])
}
resources
:resized_image
,
only: :show
,
constraints:
->
(
params
)
{
::
DesignManagement
::
DESIGN_IMAGE_SIZES
.
include?
(
params
[
:id
])
}
end
end
...
...
config/settings.rb
View file @
5118ca34
...
...
@@ -3,12 +3,6 @@
require
'settingslogic'
require
'digest/md5'
# We can not use `Rails.root` here, as this file might be loaded without the
# full Rails environment being loaded. We can not use `require_relative` either,
# as Rails uses `load` for `require_dependency` (used when loading the Rails
# environment). This could then lead to this file being loaded twice.
require_dependency
File
.
expand_path
(
'../lib/gitlab'
,
__dir__
)
class
Settings
<
Settingslogic
source
ENV
.
fetch
(
'GITLAB_CONFIG'
)
{
Pathname
.
new
(
File
.
expand_path
(
'..'
,
__dir__
)).
join
(
'config/gitlab.yml'
)
}
namespace
ENV
.
fetch
(
'GITLAB_ENV'
)
{
Rails
.
env
}
...
...
ee/lib/ee/gitlab/metrics/samplers/database_sampler.rb
View file @
5118ca34
...
...
@@ -15,9 +15,9 @@ module EE
end
def
geo_connection_stats
return
[]
unless
Geo
::
TrackingBase
.
connected?
return
[]
unless
::
Geo
::
TrackingBase
.
connected?
[{
labels:
labels_for_class
(
Geo
::
TrackingBase
),
stats:
Geo
::
TrackingBase
.
connection_pool
.
stat
}]
[{
labels:
labels_for_class
(
::
Geo
::
TrackingBase
),
stats:
::
Geo
::
TrackingBase
.
connection_pool
.
stat
}]
end
end
end
...
...
ee/lib/generators/
rails
/geo_migration_generator.rb
→
ee/lib/generators/
geo_migration
/geo_migration_generator.rb
View file @
5118ca34
...
...
@@ -4,7 +4,8 @@ require 'rails/generators'
require
'rails/generators/active_record'
require
'rails/generators/active_record/migration/migration_generator'
class
GeoMigrationGenerator
<
ActiveRecord
::
Generators
::
MigrationGenerator
module
GeoMigration
class
GeoMigrationGenerator
<
ActiveRecord
::
Generators
::
MigrationGenerator
source_root
File
.
join
(
Rails
.
root
,
'generator_templates/active_record/migration'
)
def
create_migration_file
...
...
@@ -12,4 +13,5 @@ class GeoMigrationGenerator < ActiveRecord::Generators::MigrationGenerator
validate_file_name!
migration_template
@migration_template
,
"ee/db/geo/migrate/
#{
file_name
}
.rb"
end
end
end
generator_templates/
rails
/post_deployment_migration/migration.rb
→
generator_templates/
post_deployment_migration
/post_deployment_migration/migration.rb
View file @
5118ca34
File moved
lib/gem_extensions/active_record/delegate_cache.rb
View file @
5118ca34
...
...
@@ -11,7 +11,7 @@ module GemExtensions
@relation_delegate_cache2
=
{}
# rubocop:disable Gitlab/ModuleWithInstanceVariables
[
DisableJoins
::
Relation
::
GemExtensions
::
ActiveRecord
::
DisableJoins
::
Relation
].
each
do
|
klass
|
delegate
=
Class
.
new
(
klass
)
do
include
::
ActiveRecord
::
Delegation
::
ClassSpecificRelation
...
...
lib/generators/gitlab/usage_metric
/usage_metric
_generator.rb
→
lib/generators/gitlab/usage_metric_generator.rb
View file @
5118ca34
...
...
@@ -17,7 +17,7 @@ module Gitlab
ALLOWED_OPERATIONS
=
%w(count distinct_count)
.
freeze
source_root
File
.
expand_path
(
'templates'
,
__dir__
)
source_root
File
.
expand_path
(
'
usage_metric/
templates'
,
__dir__
)
class_option
:ee
,
type: :boolean
,
optional:
true
,
default:
false
,
desc:
'Indicates if instrumentation is for EE'
class_option
:type
,
type: :string
,
desc:
"Metric type, must be one of:
#{
ALLOWED_SUPERCLASSES
.
keys
.
join
(
', '
)
}
"
...
...
lib/generators/
rails/
post_deployment_migration/post_deployment_migration_generator.rb
→
lib/generators/post_deployment_migration/post_deployment_migration_generator.rb
View file @
5118ca34
...
...
@@ -2,7 +2,7 @@
require
'rails/generators'
module
Rails
module
PostDeploymentMigration
class
PostDeploymentMigrationGenerator
<
Rails
::
Generators
::
NamedBase
def
create_migration_file
timestamp
=
Time
.
now
.
utc
.
strftime
(
'%Y%m%d%H%M%S'
)
...
...
lib/gitlab/database/load_balancing/host.rb
View file @
5118ca34
...
...
@@ -29,11 +29,11 @@ module Gitlab
@host
=
host
@port
=
port
@load_balancer
=
load_balancer
@pool
=
load_balancer
.
create_replica_connection_pool
(
LoadBalancing
.
pool_size
,
host
,
port
)
@pool
=
load_balancer
.
create_replica_connection_pool
(
::
Gitlab
::
Database
::
LoadBalancing
.
pool_size
,
host
,
port
)
@online
=
true
@last_checked_at
=
Time
.
zone
.
now
interval
=
LoadBalancing
.
replica_check_interval
interval
=
::
Gitlab
::
Database
::
LoadBalancing
.
replica_check_interval
@intervals
=
(
interval
..
(
interval
*
2
)).
step
(
0.5
).
to_a
end
...
...
@@ -54,7 +54,7 @@ module Gitlab
end
def
offline!
LoadBalancing
::
Logger
.
warn
(
::
Gitlab
::
Database
::
LoadBalancing
::
Logger
.
warn
(
event: :host_offline
,
message:
'Marking host as offline'
,
db_host:
@host
,
...
...
@@ -72,14 +72,14 @@ module Gitlab
refresh_status
if
@online
LoadBalancing
::
Logger
.
info
(
::
Gitlab
::
Database
::
LoadBalancing
::
Logger
.
info
(
event: :host_online
,
message:
'Host is online after replica status check'
,
db_host:
@host
,
db_port:
@port
)
else
LoadBalancing
::
Logger
.
warn
(
::
Gitlab
::
Database
::
LoadBalancing
::
Logger
.
warn
(
event: :host_offline
,
message:
'Host is offline after replica status check'
,
db_host:
@host
,
...
...
@@ -108,7 +108,7 @@ module Gitlab
def
replication_lag_below_threshold?
if
(
lag_time
=
replication_lag_time
)
lag_time
<=
LoadBalancing
.
max_replication_lag_time
lag_time
<=
::
Gitlab
::
Database
::
LoadBalancing
.
max_replication_lag_time
else
false
end
...
...
@@ -125,7 +125,7 @@ module Gitlab
# only do this if we haven't replicated in a while so we only need
# to connect to the primary when truly necessary.
if
(
lag_size
=
replication_lag_size
)
lag_size
<=
LoadBalancing
.
max_replication_difference
lag_size
<=
::
Gitlab
::
Database
::
LoadBalancing
.
max_replication_difference
else
false
end
...
...
lib/gitlab/database/load_balancing/rack_middleware.rb
View file @
5118ca34
...
...
@@ -18,9 +18,9 @@ module Gitlab
# namespace - The namespace to use for sticking.
# id - The identifier to use for sticking.
def
self
.
stick_or_unstick
(
env
,
namespace
,
id
)
return
unless
LoadBalancing
.
enable?
return
unless
::
Gitlab
::
Database
::
LoadBalancing
.
enable?
Sticking
.
unstick_or_continue_sticking
(
namespace
,
id
)
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
unstick_or_continue_sticking
(
namespace
,
id
)
env
[
STICK_OBJECT
]
||=
Set
.
new
env
[
STICK_OBJECT
]
<<
[
namespace
,
id
]
...
...
@@ -56,7 +56,7 @@ module Gitlab
namespaces_and_ids
=
sticking_namespaces_and_ids
(
env
)
namespaces_and_ids
.
each
do
|
namespace
,
id
|
Sticking
.
unstick_or_continue_sticking
(
namespace
,
id
)
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
unstick_or_continue_sticking
(
namespace
,
id
)
end
end
...
...
@@ -65,17 +65,17 @@ module Gitlab
namespaces_and_ids
=
sticking_namespaces_and_ids
(
env
)
namespaces_and_ids
.
each
do
|
namespace
,
id
|
Sticking
.
stick_if_necessary
(
namespace
,
id
)
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
stick_if_necessary
(
namespace
,
id
)
end
end
def
clear
load_balancer
.
release_host
Session
.
clear_session
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
clear_session
end
def
load_balancer
LoadBalancing
.
proxy
.
load_balancer
::
Gitlab
::
Database
::
LoadBalancing
.
proxy
.
load_balancer
end
# Determines the sticking namespace and identifier based on the Rack
...
...
lib/gitlab/import_export/project/object_builder.rb
View file @
5118ca34
...
...
@@ -106,7 +106,7 @@ module Gitlab
end
def
design?
klass
==
DesignManagement
::
Design
klass
==
::
DesignManagement
::
Design
end
def
diff_commit_user?
...
...
lib/gitlab/metrics/requests_rack_middleware.rb
View file @
5118ca34
...
...
@@ -66,28 +66,28 @@ module Gitlab
def
call
(
env
)
method
=
env
[
'REQUEST_METHOD'
].
downcase
method
=
'INVALID'
unless
HTTP_METHODS
.
key?
(
method
)
started
=
Gitlab
::
Metrics
::
System
.
monotonic_time
started
=
::
Gitlab
::
Metrics
::
System
.
monotonic_time
health_endpoint
=
health_endpoint?
(
env
[
'PATH_INFO'
])
status
=
'undefined'
begin
status
,
headers
,
body
=
@app
.
call
(
env
)
elapsed
=
Gitlab
::
Metrics
::
System
.
monotonic_time
-
started
elapsed
=
::
Gitlab
::
Metrics
::
System
.
monotonic_time
-
started
if
!
health_endpoint
&&
Gitlab
::
Metrics
.
record_duration_for_status?
(
status
)
RequestsRackMiddleware
.
http_request_duration_seconds
.
observe
({
method:
method
},
elapsed
)
if
!
health_endpoint
&&
::
Gitlab
::
Metrics
.
record_duration_for_status?
(
status
)
self
.
class
.
http_request_duration_seconds
.
observe
({
method:
method
},
elapsed
)
end
[
status
,
headers
,
body
]
rescue
StandardError
RequestsRackMiddleware
.
rack_uncaught_errors_count
.
increment
self
.
class
.
rack_uncaught_errors_count
.
increment
raise
ensure
if
health_endpoint
RequestsRackMiddleware
.
http_health_requests_total
.
increment
(
status:
status
.
to_s
,
method:
method
)
self
.
class
.
http_health_requests_total
.
increment
(
status:
status
.
to_s
,
method:
method
)
else
RequestsRackMiddleware
.
http_requests_total
.
increment
(
self
.
class
.
http_requests_total
.
increment
(
status:
status
.
to_s
,
method:
method
,
feature_category:
feature_category
.
presence
||
FEATURE_CATEGORY_DEFAULT
...
...
lib/gitlab/metrics/samplers/base_sampler.rb
View file @
5118ca34
...
...
@@ -23,7 +23,7 @@ module Gitlab
def
safe_sample
sample
rescue
StandardError
=>
e
Gitlab
::
AppLogger
.
warn
(
"
#{
self
.
class
}
:
#{
e
}
, stopping"
)
::
Gitlab
::
AppLogger
.
warn
(
"
#{
self
.
class
}
:
#{
e
}
, stopping"
)
stop
end
...
...
lib/gitlab/metrics/subscribers/action_view.rb
View file @
5118ca34
...
...
@@ -40,7 +40,7 @@ module Gitlab
end
def
current_transaction
Transaction
.
current
::
Gitlab
::
Metrics
::
Transaction
.
current
end
end
end
...
...
lib/gitlab/metrics/subscribers/rails_cache.rb
View file @
5118ca34
...
...
@@ -65,7 +65,7 @@ module Gitlab
private
def
current_transaction
Transaction
.
current
::
Gitlab
::
Metrics
::
Transaction
.
current
end
def
metric_cache_operation_duration_seconds
...
...
lib/gitlab/query_limiting/active_support_subscriber.rb
View file @
5118ca34
...
...
@@ -6,10 +6,10 @@ module Gitlab
attach_to
:active_record
def
sql
(
event
)
return
if
!
Transaction
.
current
||
event
.
payload
.
fetch
(
:cached
,
event
.
payload
[
:name
]
==
'CACHE'
)
return
if
!
::
Gitlab
::
QueryLimiting
::
Transaction
.
current
||
event
.
payload
.
fetch
(
:cached
,
event
.
payload
[
:name
]
==
'CACHE'
)
Transaction
.
current
.
increment
Transaction
.
current
.
executed_sql
(
event
.
payload
[
:sql
])
::
Gitlab
::
QueryLimiting
::
Transaction
.
current
.
increment
::
Gitlab
::
QueryLimiting
::
Transaction
.
current
.
executed_sql
(
event
.
payload
[
:sql
])
end
end
end
...
...
lib/gitlab/query_limiting/middleware.rb
View file @
5118ca34
...
...
@@ -13,7 +13,7 @@ module Gitlab
end
def
call
(
env
)
transaction
,
retval
=
Transaction
.
run
do
transaction
,
retval
=
::
Gitlab
::
QueryLimiting
::
Transaction
.
run
do
@app
.
call
(
env
)
end
...
...
lib/gitlab/usage/metrics/aggregates.rb
0 → 100644
View file @
5118ca34
# frozen_string_literal: true
module
Gitlab
module
Usage
module
Metrics
module
Aggregates
UNION_OF_AGGREGATED_METRICS
=
'OR'
INTERSECTION_OF_AGGREGATED_METRICS
=
'AND'
ALLOWED_METRICS_AGGREGATIONS
=
[
UNION_OF_AGGREGATED_METRICS
,
INTERSECTION_OF_AGGREGATED_METRICS
].
freeze
AGGREGATED_METRICS_PATH
=
Rails
.
root
.
join
(
'config/metrics/aggregates/*.yml'
)
AggregatedMetricError
=
Class
.
new
(
StandardError
)
UnknownAggregationOperator
=
Class
.
new
(
AggregatedMetricError
)
UnknownAggregationSource
=
Class
.
new
(
AggregatedMetricError
)
DisallowedAggregationTimeFrame
=
Class
.
new
(
AggregatedMetricError
)
DATABASE_SOURCE
=
'database'
REDIS_SOURCE
=
'redis'
SOURCES
=
{
DATABASE_SOURCE
=>
Sources
::
PostgresHll
,
REDIS_SOURCE
=>
Sources
::
RedisHll
}.
freeze
end
end
end
end
lib/gitlab/usage/metrics/aggregates/aggregate.rb
View file @
5118ca34
...
...
@@ -4,23 +4,6 @@ module Gitlab
module
Usage
module
Metrics
module
Aggregates
UNION_OF_AGGREGATED_METRICS
=
'OR'
INTERSECTION_OF_AGGREGATED_METRICS
=
'AND'
ALLOWED_METRICS_AGGREGATIONS
=
[
UNION_OF_AGGREGATED_METRICS
,
INTERSECTION_OF_AGGREGATED_METRICS
].
freeze
AGGREGATED_METRICS_PATH
=
Rails
.
root
.
join
(
'config/metrics/aggregates/*.yml'
)
AggregatedMetricError
=
Class
.
new
(
StandardError
)
UnknownAggregationOperator
=
Class
.
new
(
AggregatedMetricError
)
UnknownAggregationSource
=
Class
.
new
(
AggregatedMetricError
)
DisallowedAggregationTimeFrame
=
Class
.
new
(
AggregatedMetricError
)
DATABASE_SOURCE
=
'database'
REDIS_SOURCE
=
'redis'
SOURCES
=
{
DATABASE_SOURCE
=>
Sources
::
PostgresHll
,
REDIS_SOURCE
=>
Sources
::
RedisHll
}.
freeze
class
Aggregate
include
Gitlab
::
Usage
::
TimeFrame
...
...
lib/gitlab/usage/metrics/aggregates/sources.rb
0 → 100644
View file @
5118ca34
# frozen_string_literal: true
module
Gitlab
module
Usage
module
Metrics
module
Aggregates
module
Sources
UnionNotAvailable
=
Class
.
new
(
AggregatedMetricError
)
end
end
end
end
end
lib/gitlab/usage/metrics/aggregates/sources/redis_hll.rb
View file @
5118ca34
...
...
@@ -5,8 +5,6 @@ module Gitlab
module
Metrics
module
Aggregates
module
Sources
UnionNotAvailable
=
Class
.
new
(
AggregatedMetricError
)
class
RedisHll
extend
Calculations
::
Intersection
def
self
.
calculate_metrics_union
(
metric_names
:,
start_date
:,
end_date
:,
recorded_at:
nil
)
...
...
spec/fast_spec_helper.rb
View file @
5118ca34
...
...
@@ -18,9 +18,11 @@ require_relative '../config/settings'
require_relative
'support/rspec'
require
'active_support/all'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'ee/lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'jh/lib'
unless
ActiveSupport
::
Dependencies
.
autoload_paths
.
frozen?
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'ee/lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'jh/lib'
end
ActiveSupport
::
XmlMini
.
backend
=
'Nokogiri'
...
...
spec/lib/gitlab/database/load_balancing/rack_middleware_spec.rb
View file @
5118ca34
...
...
@@ -183,18 +183,17 @@ RSpec.describe Gitlab::Database::LoadBalancing::RackMiddleware, :redis do
describe
'#clear'
do
it
'clears the currently used host and session'
do
lb
=
double
(
:lb
)
session
=
double
(
:session
)
session
=
spy
(
:session
)
allow
(
middleware
).
to
receive
(
:load_balancer
).
and_return
(
lb
)
expect
(
lb
).
to
receive
(
:release_host
)
stub_const
(
'Gitlab::Database::LoadBalancing::RackMiddleware::Session'
,
session
)
expect
(
session
).
to
receive
(
:clear_session
)
stub_const
(
'Gitlab::Database::LoadBalancing::Session'
,
session
)
middleware
.
clear
expect
(
session
).
to
have_received
(
:clear_session
)
end
end
...
...
spec/services/service_response_spec.rb
View file @
5118ca34
...
...
@@ -2,7 +2,7 @@
require
'fast_spec_helper'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'app/services
'
require_relative
'../../app/services/service_response
'
RSpec
.
describe
ServiceResponse
do
describe
'.success'
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