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
df0081ee
Commit
df0081ee
authored
Feb 18, 2020
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Being collecting blob truncation metrics
parent
238462be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
lib/gitlab/git/blob.rb
lib/gitlab/git/blob.rb
+11
-2
spec/lib/gitlab/git/blob_spec.rb
spec/lib/gitlab/git/blob_spec.rb
+17
-1
No files found.
lib/gitlab/git/blob.rb
View file @
df0081ee
...
...
@@ -124,11 +124,12 @@ module Gitlab
self
.
__send__
(
"
#{
key
}
="
,
options
[
key
.
to_sym
])
# rubocop:disable GitlabSecurity/PublicSend
end
record_metric_blob_size
# Retain the actual size before it is encoded
@loaded_size
=
@data
.
bytesize
if
@data
@loaded_all_data
=
@loaded_size
==
size
record_metric_blob_size
record_metric_truncated
(
truncated?
)
end
def
binary_in_repo?
...
...
@@ -210,6 +211,14 @@ module Gitlab
self
.
class
.
gitlab_blob_size
.
observe
({},
size
)
end
def
record_metric_truncated
(
bool
)
if
bool
self
.
class
.
gitlab_blob_truncated_true
.
increment
else
self
.
class
.
gitlab_blob_truncated_false
.
increment
end
end
def
has_lfs_version_key?
!
empty?
&&
text_in_repo?
&&
data
.
start_with?
(
"version https://git-lfs.github.com/spec"
)
end
...
...
spec/lib/gitlab/git/blob_spec.rb
View file @
df0081ee
...
...
@@ -22,7 +22,23 @@ describe Gitlab::Git::Blob, :seed_helper do
it
'records blob size'
do
expect
(
described_class
).
to
receive
(
:gitlab_blob_size
).
and_call_original
Gitlab
::
Git
::
Blob
.
new
(
name:
'test'
,
size:
1234
)
Gitlab
::
Git
::
Blob
.
new
(
name:
'test'
,
size:
4
,
data:
'abcd'
)
end
context
'when untruncated'
do
it
'attempts to record gitlab_blob_truncated_false'
do
expect
(
described_class
).
to
receive
(
:gitlab_blob_truncated_false
).
and_call_original
Gitlab
::
Git
::
Blob
.
new
(
name:
'test'
,
size:
4
,
data:
'abcd'
)
end
end
context
'when truncated'
do
it
'attempts to record gitlab_blob_truncated_true'
do
expect
(
described_class
).
to
receive
(
:gitlab_blob_truncated_true
).
and_call_original
Gitlab
::
Git
::
Blob
.
new
(
name:
'test'
,
size:
40
,
data:
'abcd'
)
end
end
end
...
...
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