From f78cd68ddf4513716b4f006428693756e04a6729 Mon Sep 17 00:00:00 2001 From: Andrew Newdigate Date: Fri, 22 Feb 2019 14:47:37 +0200 Subject: Switch back to using regexps in `tracing_url_template` This approach is able to cope with `%` characters in the URL template, which is important since `%` is a valid URL character. Additionally this approach is less likely to fail on an invalid string. This is important since the distributed tracing infrastructure is designed to degrade gracefully when not properly configured, and a small mistake in the configuration of the URL template could have led to a production outage. --- spec/lib/gitlab/tracing_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'spec/lib/gitlab/tracing_spec.rb') diff --git a/spec/lib/gitlab/tracing_spec.rb b/spec/lib/gitlab/tracing_spec.rb index 8902d5f44ec..566b5050e47 100644 --- a/spec/lib/gitlab/tracing_spec.rb +++ b/spec/lib/gitlab/tracing_spec.rb @@ -44,13 +44,15 @@ describe Gitlab::Tracing do describe '.tracing_url' do where(:tracing_url_enabled?, :tracing_url_template, :correlation_id, :process_name, :tracing_url) do - false | "https://localhost" | "123" | "web" | nil - true | "https://localhost" | "123" | "web" | "https://localhost" - true | "https://localhost?service=%{service}" | "123" | "web" | "https://localhost?service=web" - true | "https://localhost?c=%{correlation_id}" | "123" | "web" | "https://localhost?c=123" - true | "https://localhost?c=%{correlation_id}&s=%{service}" | "123" | "web" | "https://localhost?c=123&s=web" - true | "https://localhost?c=%{correlation_id}" | nil | "web" | "https://localhost?c=" - true | "https://localhost?c=%{correlation_id}&s=%22%{service}%22" | "123" | "web" | "https://localhost?c=123&s=%22web%22" + false | "https://localhost" | "123" | "web" | nil + true | "https://localhost" | "123" | "web" | "https://localhost" + true | "https://localhost?service={{ service }}" | "123" | "web" | "https://localhost?service=web" + true | "https://localhost?c={{ correlation_id }}" | "123" | "web" | "https://localhost?c=123" + true | "https://localhost?c={{ correlation_id }}&s={{ service }}" | "123" | "web" | "https://localhost?c=123&s=web" + true | "https://localhost?c={{ correlation_id }}" | nil | "web" | "https://localhost?c=" + true | "https://localhost?c={{ correlation_id }}&s=%22{{ service }}%22" | "123" | "web" | "https://localhost?c=123&s=%22web%22" + true | "https://localhost?c={{correlation_id}}&s={{service}}" | "123" | "web" | "https://localhost?c=123&s=web" + true | "https://localhost?c={{correlation_id }}&s={{ service}}" | "123" | "web" | "https://localhost?c=123&s=web" end with_them do -- cgit v1.2.1