Commit 5c7dabbf authored by Mikolaj Wawrzyniak's avatar Mikolaj Wawrzyniak

Wrap metric name suggestion in doubble quotes

To avoid problems with YAML special characters, lets wrap entire name
suggestion in doubble quotes
parent 160cd80d
......@@ -67,7 +67,7 @@ module Gitlab
def metric_name_suggestion
return unless Feature.enabled?(:product_intelligence_metrics_names_suggestions, default_enabled: :yaml)
"\nname: #{Usage::Metrics::NamesSuggestions::Generator.generate(key_path)}"
"\nname: \"#{Usage::Metrics::NamesSuggestions::Generator.generate(key_path)}\""
end
def file_path
......
......@@ -85,7 +85,7 @@ module Gitlab
parts << actual_source
parts += process_joined_relations(actual_source, arel, relation, constraints)
parts.compact.join('_')
parts.compact.join('_').delete('"')
end
def append_constraints_prompt(target, constraints, parts)
......
......@@ -64,7 +64,7 @@ RSpec.describe Gitlab::Usage::Metrics::NamesSuggestions::Generator do
it_behaves_like 'name suggestion' do
# corresponding metric is collected with distinct_count(::Clusters::Cluster.aws_installed.enabled.where(time_period), :user_id)
let(:key_path) { 'usage_activity_by_stage_monthly.configure.clusters_platforms_eks' }
let(:constraints) { /<adjective describing\: '\(clusters.provider_type = \d+ AND \("cluster_providers_aws"\."status" IN \(\d+\)\) AND clusters\.enabled = TRUE\)'>/ }
let(:constraints) { /<adjective describing\: '\(clusters.provider_type = \d+ AND \(cluster_providers_aws\.status IN \(\d+\)\) AND clusters\.enabled = TRUE\)'>/ }
let(:name_suggestion) { /count_distinct_user_id_from_#{constraints}_clusters_<with>_#{constraints}_cluster_providers_aws/ }
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