Commit e2ceb392 authored by Mario Sebastián Celi Calderón's avatar Mario Sebastián Celi Calderón Committed by Markus Koller

Remove graphql_logging feature flag code [RUN ALL RSPEC] [RUN AS-IF-FOSS]

parent 310c30ad
---
title: Remove graphql_logging feature flag
merge_request: 54984
author:
type: other
---
name: graphql_logging
introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/27885
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/35579
milestone: '12.0'
type: development
group: group::project management
default_enabled: true
...@@ -9,10 +9,6 @@ module Gitlab ...@@ -9,10 +9,6 @@ module Gitlab
FIELD_USAGE_ANALYZER = GraphQL::Analysis::FieldUsage.new { |query, used_fields, used_deprecated_fields| [used_fields, used_deprecated_fields] } FIELD_USAGE_ANALYZER = GraphQL::Analysis::FieldUsage.new { |query, used_fields, used_deprecated_fields| [used_fields, used_deprecated_fields] }
ALL_ANALYZERS = [COMPLEXITY_ANALYZER, DEPTH_ANALYZER, FIELD_USAGE_ANALYZER].freeze ALL_ANALYZERS = [COMPLEXITY_ANALYZER, DEPTH_ANALYZER, FIELD_USAGE_ANALYZER].freeze
def analyze?(query)
Feature.enabled?(:graphql_logging, default_enabled: true)
end
def initial_value(query) def initial_value(query)
variables = process_variables(query.provided_variables) variables = process_variables(query.provided_variables)
default_initial_values(query).merge({ default_initial_values(query).merge({
......
...@@ -5,42 +5,6 @@ require 'spec_helper' ...@@ -5,42 +5,6 @@ require 'spec_helper'
RSpec.describe Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer do RSpec.describe Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer do
subject { described_class.new } subject { described_class.new }
describe '#analyze?' do
context 'feature flag disabled' do
before do
stub_feature_flags(graphql_logging: false)
end
it 'disables the analyzer' do
expect(subject.analyze?(anything)).to be_falsey
end
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
describe '#initial_value' do describe '#initial_value' do
it 'filters out sensitive variables' do it 'filters out sensitive variables' do
doc = GraphQL.parse <<-GRAPHQL doc = GraphQL.parse <<-GRAPHQL
...@@ -58,4 +22,24 @@ RSpec.describe Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer do ...@@ -58,4 +22,24 @@ RSpec.describe Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer do
expect(subject.initial_value(query)[:variables]).to eq('{:body=>"[FILTERED]"}') expect(subject.initial_value(query)[:variables]).to eq('{:body=>"[FILTERED]"}')
end end
end end
describe '#final_value' do
let(:monotonic_time_before) { 42 }
let(:monotonic_time_after) { 500 }
let(:monotonic_time_duration) { monotonic_time_after - monotonic_time_before }
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