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
2c10a884
Commit
2c10a884
authored
Oct 06, 2020
by
Mehmet Emin INAC
Committed by
Igor Drozdov
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge graphql logs with application(controller) logs
parent
53488ad0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
app/controllers/graphql_controller.rb
app/controllers/graphql_controller.rb
+7
-1
lib/gitlab/graphql/query_analyzers/logger_analyzer.rb
lib/gitlab/graphql/query_analyzers/logger_analyzer.rb
+3
-1
spec/controllers/graphql_controller_spec.rb
spec/controllers/graphql_controller_spec.rb
+3
-1
No files found.
app/controllers/graphql_controller.rb
View file @
2c10a884
...
...
@@ -113,6 +113,12 @@ class GraphqlController < ApplicationController
# Merging to :metadata will ensure these are logged as top level keys
payload
[
:metadata
]
||=
{}
payload
[
:metadata
].
merge!
(
graphql:
{
operation_name:
params
[
:operationName
]
})
payload
[
:metadata
].
merge!
(
graphql:
logs
)
end
def
logs
RequestStore
.
store
[
:graphql_logs
].
to_h
.
except
(
:duration_s
,
:query_string
)
.
merge
(
operation_name:
params
[
:operationName
])
end
end
lib/gitlab/graphql/query_analyzers/logger_analyzer.rb
View file @
2c10a884
...
...
@@ -25,7 +25,7 @@ module Gitlab
end
def
call
(
memo
,
visit_type
,
irep_node
)
memo
RequestStore
.
store
[
:graphql_logs
]
=
memo
end
def
final_value
(
memo
)
...
...
@@ -35,6 +35,8 @@ module Gitlab
memo
[
:depth
]
=
depth
memo
[
:complexity
]
=
complexity
# This duration is not the execution time of the
# query but the execution time of the analyzer.
memo
[
:duration_s
]
=
duration
(
memo
[
:time_started
]).
round
(
1
)
memo
[
:used_fields
]
=
field_usages
.
first
memo
[
:used_deprecated_fields
]
=
field_usages
.
second
...
...
spec/controllers/graphql_controller_spec.rb
View file @
2c10a884
...
...
@@ -150,9 +150,11 @@ RSpec.describe GraphqlController do
describe
'#append_info_to_payload'
do
let
(
:graphql_query
)
{
graphql_query_for
(
'project'
,
{
'fullPath'
=>
'foo'
},
%w(id name)
)
}
let
(
:mock_store
)
{
{
graphql_logs:
{
foo: :bar
}
}
}
let
(
:log_payload
)
{
{}
}
before
do
allow
(
RequestStore
).
to
receive
(
:store
).
and_return
(
mock_store
)
allow
(
controller
).
to
receive
(
:append_info_to_payload
).
and_wrap_original
do
|
method
,
*|
method
.
call
(
log_payload
)
end
...
...
@@ -162,7 +164,7 @@ RSpec.describe GraphqlController do
post
:execute
,
params:
{
query:
graphql_query
,
operationName:
'Foo'
}
expect
(
controller
).
to
have_received
(
:append_info_to_payload
)
expect
(
log_payload
.
dig
(
:metadata
,
:graphql
,
:operation_name
)).
to
eq
(
'Foo'
)
expect
(
log_payload
.
dig
(
:metadata
,
:graphql
)).
to
eq
({
operation_name:
'Foo'
,
foo: :bar
}
)
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