Commit a98fa3ff authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'use-duration-s-in-graphql-logs' into 'master'

Use duration_s in GraphQL logs

See merge request gitlab-org/gitlab!31759
parents 3f82d382 d77f8cc1
...@@ -618,7 +618,7 @@ installations from source. ...@@ -618,7 +618,7 @@ installations from source.
GraphQL queries are recorded in that file. For example: GraphQL queries are recorded in that file. For example:
```json ```json
{"query_string":"query IntrospectionQuery{__schema {queryType { name },mutationType { name }}}...(etc)","variables":{"a":1,"b":2},"complexity":181,"depth":1,"duration":7} {"query_string":"query IntrospectionQuery{__schema {queryType { name },mutationType { name }}}...(etc)","variables":{"a":1,"b":2},"complexity":181,"depth":1,"duration_s":7}
``` ```
## `migrations.log` ## `migrations.log`
......
...@@ -34,7 +34,7 @@ module Gitlab ...@@ -34,7 +34,7 @@ module Gitlab
memo[:depth] = depth memo[:depth] = depth
memo[:complexity] = complexity memo[:complexity] = complexity
memo[:duration] = duration(memo[:time_started]).round(1) memo[:duration_s] = duration(memo[:time_started]).round(1)
GraphqlLogger.info(memo.except!(:time_started, :query)) GraphqlLogger.info(memo.except!(:time_started, :query))
rescue => e rescue => e
...@@ -62,7 +62,7 @@ module Gitlab ...@@ -62,7 +62,7 @@ module Gitlab
query_string: nil, query_string: nil,
query: query, query: query,
variables: nil, variables: nil,
duration: nil duration_s: nil
} }
end end
end end
......
...@@ -23,7 +23,7 @@ describe Gitlab::GraphqlLogger do ...@@ -23,7 +23,7 @@ describe Gitlab::GraphqlLogger do
variables: {}, variables: {},
complexity: 181, complexity: 181,
depth: 0, depth: 0,
duration: 7 duration_s: 7
} }
output = subject.format_message('INFO', now, 'test', analyzer_memo) output = subject.format_message('INFO', now, 'test', analyzer_memo)
...@@ -34,7 +34,7 @@ describe Gitlab::GraphqlLogger do ...@@ -34,7 +34,7 @@ describe Gitlab::GraphqlLogger do
expect(data['complexity']).to eq(181) expect(data['complexity']).to eq(181)
expect(data['variables']).to eq({}) expect(data['variables']).to eq({})
expect(data['depth']).to eq(0) expect(data['depth']).to eq(0)
expect(data['duration']).to eq(7) expect(data['duration_s']).to eq(7)
end end
end end
end end
...@@ -190,7 +190,7 @@ describe 'GitlabSchema configurations' do ...@@ -190,7 +190,7 @@ describe 'GitlabSchema configurations' do
variables: {}.to_s, variables: {}.to_s,
complexity: 181, complexity: 181,
depth: 13, depth: 13,
duration: 7 duration_s: 7
} }
expect_any_instance_of(Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer).to receive(:duration).and_return(7) expect_any_instance_of(Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer).to receive(:duration).and_return(7)
......
...@@ -9,7 +9,7 @@ describe 'GraphQL' do ...@@ -9,7 +9,7 @@ describe 'GraphQL' do
context 'logging' do context 'logging' do
shared_examples 'logging a graphql query' do shared_examples 'logging a graphql query' do
let(:expected_params) do let(:expected_params) do
{ query_string: query, variables: variables.to_s, duration: anything, depth: 1, complexity: 1 } { query_string: query, variables: variables.to_s, duration_s: anything, depth: 1, complexity: 1 }
end end
it 'logs a query with the expected params' do it 'logs a query with the expected params' 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