Commit 5ac5264e authored by Stan Hu's avatar Stan Hu

Merge branch 'bvl-rename-fallback-graphql-endpoint-ids' into 'master'

Use better fallback operation names in GraphQL

See merge request gitlab-org/gitlab!83281
parents edf916c8 2b4d3932
......@@ -14,7 +14,6 @@ module Gitlab
end
end
ANONYMOUS = Operation.new("anonymous").freeze
UNKNOWN = Operation.new("unknown").freeze
def self.default
......@@ -24,7 +23,7 @@ module Gitlab
def initialize(operation_names)
@operation_hash = operation_names
.map { |name| Operation.new(name).freeze }
.concat([ANONYMOUS, UNKNOWN])
.concat([UNKNOWN])
.index_by(&:name)
end
......@@ -32,7 +31,7 @@ module Gitlab
def from_query(query)
operation_name = query.selected_operation_name
return ANONYMOUS unless operation_name
return UNKNOWN unless operation_name
@operation_hash[operation_name] || UNKNOWN
end
......
......@@ -19,7 +19,7 @@ RSpec.describe Gitlab::Graphql::KnownOperations do
describe "#from_query" do
where(:query_string, :expected) do
"query { helloWorld }" | described_class::ANONYMOUS
"query { helloWorld }" | described_class::UNKNOWN
"query fuzzyyy { helloWorld }" | described_class::UNKNOWN
"query foo { helloWorld }" | described_class::Operation.new("foo")
end
......@@ -35,13 +35,13 @@ RSpec.describe Gitlab::Graphql::KnownOperations do
describe "#operations" do
it "returns array of known operations" do
expect(subject.operations.map(&:name)).to match_array(%w(anonymous unknown foo bar))
expect(subject.operations.map(&:name)).to match_array(%w(unknown foo bar))
end
end
describe "Operation#to_caller_id" do
where(:query_string, :expected) do
"query { helloWorld }" | "graphql:#{described_class::ANONYMOUS.name}"
"query { helloWorld }" | "graphql:#{described_class::UNKNOWN.name}"
"query foo { helloWorld }" | "graphql:foo"
end
......
......@@ -28,7 +28,7 @@ RSpec.describe Gitlab::Metrics::RailsSlis do
}
]
possible_graphql_labels = ['graphql:foo', 'graphql:bar', 'graphql:unknown', 'graphql:anonymous'].map do |endpoint_id|
possible_graphql_labels = ['graphql:foo', 'graphql:bar', 'graphql:unknown'].map do |endpoint_id|
{
endpoint_id: endpoint_id,
feature_category: nil,
......
......@@ -15,7 +15,7 @@ RSpec.describe 'GraphQL' do
let(:expected_execute_query_log) do
{
"correlation_id" => kind_of(String),
"meta.caller_id" => "graphql:anonymous",
"meta.caller_id" => "graphql:unknown",
"meta.client_id" => kind_of(String),
"meta.feature_category" => "not_owned",
"meta.remote_ip" => kind_of(String),
......
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