Commit c09d2dac authored by Sean McGivern's avatar Sean McGivern

Merge branch 'cat-fix-graphql-duration-unit' into 'master'

Update unit to seconds in GraphQL logs

See merge request gitlab-org/gitlab!35446
parents 4244baa2 ef8cfe08
......@@ -52,8 +52,7 @@ module Gitlab
end
def duration(time_started)
nanoseconds = Gitlab::Metrics::System.monotonic_time - time_started
nanoseconds * 1000000
Gitlab::Metrics::System.monotonic_time - time_started
end
def default_initial_values(query)
......
......@@ -17,9 +17,27 @@ RSpec.describe Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer do
end
context 'feature flag enabled by default' do
let(:monotonic_time_before) { 42 }
let(:monotonic_time_after) { 500 }
let(:monotonic_time_duration) { monotonic_time_after - monotonic_time_before }
it 'enables the analyzer' do
expect(subject.analyze?(anything)).to be_truthy
end
it 'returns a duration in seconds' do
allow(GraphQL::Analysis).to receive(:analyze_query).and_return([4, 2])
allow(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(monotonic_time_before, monotonic_time_after)
allow(Gitlab::GraphqlLogger).to receive(:info)
expected_duration = monotonic_time_duration
memo = subject.initial_value(spy('query'))
subject.final_value(memo)
expect(memo).to have_key(:duration_s)
expect(memo[:duration_s]).to eq(expected_duration)
end
end
end
end
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