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
2d69ea6c
Commit
2d69ea6c
authored
Apr 23, 2021
by
Andreas Brandl
Committed by
Matthias Käppler
Apr 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding metrics for batched migrations
parent
243ab4d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
15 deletions
+30
-15
lib/gitlab/database/background_migration/batched_migration_wrapper.rb
...atabase/background_migration/batched_migration_wrapper.rb
+16
-11
spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb
...se/background_migration/batched_migration_wrapper_spec.rb
+14
-4
No files found.
lib/gitlab/database/background_migration/batched_migration_wrapper.rb
View file @
2d69ea6c
...
...
@@ -62,11 +62,10 @@ module Gitlab
metric_for
(
:gauge_batch_size
).
set
(
base_labels
,
tracking_record
.
batch_size
)
metric_for
(
:gauge_sub_batch_size
).
set
(
base_labels
,
tracking_record
.
sub_batch_size
)
metric_for
(
:gauge_interval
).
set
(
base_labels
,
tracking_record
.
batched_migration
.
interval
)
metric_for
(
:gauge_job_duration
).
set
(
base_labels
,
(
tracking_record
.
finished_at
-
tracking_record
.
started_at
).
to_i
)
metric_for
(
:counter_updated_tuples
).
increment
(
base_labels
,
tracking_record
.
batch_size
)
# Time efficiency: Ratio of duration to interval (ideal: less than, but close to 1)
efficiency
=
(
tracking_record
.
finished_at
-
tracking_record
.
started_at
).
to_i
/
migration
.
interval
.
to_f
metric_for
(
:histogram_time_efficiency
).
observe
(
base_labels
,
efficiency
)
metric_for
(
:gauge_total_tuple_count
).
set
(
base_labels
,
tracking_record
.
batched_migration
.
total_tuple_count
)
if
metrics
=
tracking_record
.
metrics
metrics
[
'timings'
]
&
.
each
do
|
key
,
timings
|
...
...
@@ -95,21 +94,27 @@ module Gitlab
:batched_migration_job_sub_batch_size
,
'Sub-batch size for a batched migration job'
),
gauge_interval:
Gitlab
::
Metrics
.
gauge
(
:batched_migration_job_interval_seconds
,
'Interval for a batched migration job'
),
gauge_job_duration:
Gitlab
::
Metrics
.
gauge
(
:batched_migration_job_duration_seconds
,
'Duration for a batched migration job'
),
counter_updated_tuples:
Gitlab
::
Metrics
.
counter
(
:batched_migration_job_updated_tuples_total
,
'Number of tuples updated by batched migration job'
),
histogram_timings:
Gitlab
::
Metrics
.
histogram
(
:batched_migration_job_duration_seconds
,
'
T
imings for a batched migration job'
,
:batched_migration_job_
query_
duration_seconds
,
'
Query t
imings for a batched migration job'
,
{},
[
0.1
,
0.25
,
0.5
,
1
,
5
].
freeze
),
histogram_time_efficiency:
Gitlab
::
Metrics
.
histogram
(
:batched_migration_job_time_efficiency
,
'Ratio of job duration to interval'
,
{},
[
0.5
,
0.9
,
1
,
1.5
,
2
].
freeze
gauge_total_tuple_count:
Gitlab
::
Metrics
.
gauge
(
:batched_migration_total_tuple_count
,
'Total tuple count the migration needs to touch'
)
}
end
...
...
spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb
View file @
2d69ea6c
...
...
@@ -68,6 +68,12 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigrationWrapper, '
subject
end
it
'reports interval'
do
expect
(
described_class
.
metrics
[
:gauge_interval
]).
to
receive
(
:set
).
with
(
labels
,
job_record
.
batched_migration
.
interval
)
subject
end
it
'reports updated tuples (currently based on batch_size)'
do
expect
(
described_class
.
metrics
[
:counter_updated_tuples
]).
to
receive
(
:increment
).
with
(
labels
,
job_record
.
batch_size
)
...
...
@@ -89,18 +95,22 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigrationWrapper, '
subject
end
it
'reports
time efficiency
'
do
it
'reports
job duration
'
do
freeze_time
do
expect
(
Time
).
to
receive
(
:current
).
and_return
(
Time
.
zone
.
now
-
5
.
seconds
).
ordered
expect
(
Time
).
to
receive
(
:current
).
and_return
(
Time
.
zone
.
now
).
ordered
ratio
=
5
/
job_record
.
batched_migration
.
interval
.
to_f
expect
(
described_class
.
metrics
[
:histogram_time_efficiency
]).
to
receive
(
:observe
).
with
(
labels
,
ratio
)
expect
(
described_class
.
metrics
[
:gauge_job_duration
]).
to
receive
(
:set
).
with
(
labels
,
5
.
seconds
)
subject
end
end
it
'reports the total tuple count for the migration'
do
expect
(
described_class
.
metrics
[
:gauge_total_tuple_count
]).
to
receive
(
:set
).
with
(
labels
,
job_record
.
batched_migration
.
total_tuple_count
)
subject
end
end
context
'when the migration job does not raise an error'
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