diff options
author | charlieablett <cablett@gitlab.com> | 2019-06-21 17:20:00 +0300 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-07-03 13:53:13 +0300 |
commit | f4890d90782ad42a802b89c2a17c83bf9fb9d123 (patch) | |
tree | 233421eff8ec110cc16b1dcb9b50bedccb044e76 /app/graphql | |
parent | c99c30fdd6f3adf4fb29aad4b10e265be69d2d67 (diff) |
Alert if `calls_gitaly` declaration missing
- Move `calls_gitaly_check` to public
- Add instrumentation for flagging missing CallsGitaly declarations
- Wrap resolver proc in before-and-after Gitaly counts to get the net
Gitaly call count for the resolver.
Diffstat (limited to 'app/graphql')
-rw-r--r-- | app/graphql/gitlab_schema.rb | 1 | ||||
-rw-r--r-- | app/graphql/types/base_field.rb | 22 |
2 files changed, 13 insertions, 10 deletions
diff --git a/app/graphql/gitlab_schema.rb b/app/graphql/gitlab_schema.rb index 5615909c4ec..152ebb930e2 100644 --- a/app/graphql/gitlab_schema.rb +++ b/app/graphql/gitlab_schema.rb @@ -13,6 +13,7 @@ class GitlabSchema < GraphQL::Schema use BatchLoader::GraphQL use Gitlab::Graphql::Authorize use Gitlab::Graphql::Present + use Gitlab::Graphql::CallsGitaly use Gitlab::Graphql::Connections use Gitlab::Graphql::GenericTracing diff --git a/app/graphql/types/base_field.rb b/app/graphql/types/base_field.rb index 95db116d6f9..64bc7e6474f 100644 --- a/app/graphql/types/base_field.rb +++ b/app/graphql/types/base_field.rb @@ -21,6 +21,18 @@ module Types complexity end + def calls_gitaly_check(calls) + return if @calls_gitaly + + # Will inform you if :calls_gitaly should be true or false based on the number of Gitaly calls + # involved with the request. + if calls > 0 + raise "Gitaly is called for field '#{name}' - please add `calls_gitaly: true` to the field declaration" + end + rescue => e + Gitlab::Sentry.track_exception(e) + end + private def field_complexity(resolver_class) @@ -54,15 +66,5 @@ module Types complexity.to_i end end - - def calls_gitaly_check - # Will inform you if :calls_gitaly should be true or false based on the number of Gitaly calls - # involved with the request. - if @calls_gitaly && Gitlab::GitalyClient.get_request_count == 0 - raise "Gitaly is called for field '#{name}' - please add `calls_gitaly: true` to the field declaration" - end - rescue => e - Gitlab::Sentry.track_exception(e) - end end end |