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,26 +5,29 @@ require 'spec_helper' ...@@ -5,26 +5,29 @@ 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 describe '#initial_value' do
context 'feature flag disabled' do it 'filters out sensitive variables' do
before do doc = GraphQL.parse <<-GRAPHQL
stub_feature_flags(graphql_logging: false) mutation createNote($body: String!) {
end createNote(input: {noteableId: "1", body: $body}) {
note {
id
}
}
}
GRAPHQL
query = GraphQL::Query.new(GitlabSchema, document: doc, context: {}, variables: { body: "some note" })
it 'disables the analyzer' do expect(subject.initial_value(query)[:variables]).to eq('{:body=>"[FILTERED]"}')
expect(subject.analyze?(anything)).to be_falsey
end end
end end
context 'feature flag enabled by default' do describe '#final_value' do
let(:monotonic_time_before) { 42 } let(:monotonic_time_before) { 42 }
let(:monotonic_time_after) { 500 } let(:monotonic_time_after) { 500 }
let(:monotonic_time_duration) { monotonic_time_after - monotonic_time_before } 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 it 'returns a duration in seconds' do
allow(GraphQL::Analysis).to receive(:analyze_query).and_return([4, 2, [[], []]]) 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::Metrics::System).to receive(:monotonic_time).and_return(monotonic_time_before, monotonic_time_after)
...@@ -39,23 +42,4 @@ RSpec.describe Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer do ...@@ -39,23 +42,4 @@ RSpec.describe Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer do
expect(memo[:duration_s]).to eq(expected_duration) expect(memo[:duration_s]).to eq(expected_duration)
end end
end end
end
describe '#initial_value' do
it 'filters out sensitive variables' do
doc = GraphQL.parse <<-GRAPHQL
mutation createNote($body: String!) {
createNote(input: {noteableId: "1", body: $body}) {
note {
id
}
}
}
GRAPHQL
query = GraphQL::Query.new(GitlabSchema, document: doc, context: {}, variables: { body: "some note" })
expect(subject.initial_value(query)[:variables]).to eq('{:body=>"[FILTERED]"}')
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