diff options
author | Stan Hu <stanhu@gmail.com> | 2019-07-17 16:34:27 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-07-18 06:53:39 -0700 |
commit | 1136c0c8e98d4f0d3fb4f50219657cabe0d45c99 (patch) | |
tree | 7c555a4d2fa9796cdcba2ac4de2514a974179f31 /spec | |
parent | 037096ef6c2c2f804302efb429bcd1eb5123b5e9 (diff) | |
download | gitlab-ce-1136c0c8e98d4f0d3fb4f50219657cabe0d45c99.tar.gz |
Add Rugged calls and duration to API and Rails logs
This adds `rugged_duration_ms` and `rugged_calls` fields to
`api_json.log` and `production_json.log`. This will make it easier to
identify performance issues caused by excessive I/O.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/64676
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/rugged_instrumentation_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/rugged_instrumentation_spec.rb b/spec/lib/gitlab/rugged_instrumentation_spec.rb new file mode 100644 index 00000000000..4dcc8ae514a --- /dev/null +++ b/spec/lib/gitlab/rugged_instrumentation_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::RuggedInstrumentation, :request_store do + subject { described_class } + + describe '.query_time' do + it 'increments query times' do + subject.query_time += 0.451 + subject.query_time += 0.322 + + expect(subject.query_time).to be_within(0.001).of(0.773) + expect(subject.query_time_ms).to eq(773.0) + end + end + + context '.increment_query_count' do + it 'tracks query counts' do + expect(subject.query_count).to eq(0) + + 2.times { subject.increment_query_count } + + expect(subject.query_count).to eq(2) + end + end +end |