Commit c9003a71 authored by Nick Thomas's avatar Nick Thomas

Merge branch '204891-enable-gathering-metrics-of-blob-size' into 'master'

Being collecting blob size metrics

See merge request gitlab-org/gitlab!25462
parents ffbbcfb7 5541fde9
......@@ -124,6 +124,8 @@ 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
......@@ -202,6 +204,12 @@ module Gitlab
private
def record_metric_blob_size
return unless size
self.class.gitlab_blob_size.observe({}, size)
end
def has_lfs_version_key?
!empty? && text_in_repo? && data.start_with?("version https://git-lfs.github.com/spec")
end
......
......@@ -12,10 +12,18 @@ describe Gitlab::Git::Blob, :seed_helper do
let(:blob) { Gitlab::Git::Blob.new(name: 'test') }
it 'handles nil data' do
expect(described_class).not_to receive(:gitlab_blob_size)
expect(blob.name).to eq('test')
expect(blob.size).to eq(nil)
expect(blob.loaded_size).to eq(nil)
end
it 'records blob size' do
expect(described_class).to receive(:gitlab_blob_size).and_call_original
Gitlab::Git::Blob.new(name: 'test', size: 1234)
end
end
shared_examples '.find' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment