Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2019-02-04 15:44:51 +0300
committerAndrew Newdigate <andrew@gitlab.com>2019-02-08 15:08:31 +0300
commit48bcd5248f6c1e8471393fe07ed043c4fefcb7e2 (patch)
tree99d907f6dc6f322d59af528301a889f6bb66b443 /spec/lib
parentc48f29c15989d260ccb72d3e4bf5973a5e0f2d25 (diff)
Provide a performance bar link to the Jaeger UI
Jaeger is a distributed tracing tool. This change adds a "Tracing" link to the performance bar to directly link to a current request in Jaeger. This is useful for two reasons: 1 - it provides affordance to developers that the distributed tracing tool is available, so that it can quickly be discovered. 2 - it allows developers to quickly find a specific trace without having to manually navigate to a second user-interface.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/tracing_spec.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/lib/gitlab/tracing_spec.rb b/spec/lib/gitlab/tracing_spec.rb
new file mode 100644
index 00000000000..2cddc895026
--- /dev/null
+++ b/spec/lib/gitlab/tracing_spec.rb
@@ -0,0 +1,66 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require 'rspec-parameterized'
+
+describe Gitlab::Tracing do
+ using RSpec::Parameterized::TableSyntax
+
+ describe '.enabled?' do
+ where(:connection_string, :enabled_state) do
+ nil | false
+ "" | false
+ "opentracing://jaeger" | true
+ end
+
+ with_them do
+ it 'should return the correct state for .enabled?' do
+ expect(described_class).to receive(:connection_string).and_return(connection_string)
+
+ expect(described_class.enabled?).to eq(enabled_state)
+ end
+ end
+ end
+
+ describe '.tracing_url_enabled?' do
+ where(:enabled?, :tracing_url_template, :tracing_url_enabled_state) do
+ false | nil | false
+ false | "" | false
+ false | "http://localhost" | false
+ true | nil | false
+ true | "" | false
+ true | "http://localhost" | true
+ end
+
+ with_them do
+ it 'should return the correct state for .tracing_url_enabled?' do
+ expect(described_class).to receive(:enabled?).and_return(enabled?)
+ allow(described_class).to receive(:tracing_url_template).and_return(tracing_url_template)
+
+ expect(described_class.tracing_url_enabled?).to eq(tracing_url_enabled_state)
+ end
+ end
+ end
+
+ 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="
+ end
+
+ with_them do
+ it 'should return the correct state for .tracing_url' do
+ expect(described_class).to receive(:tracing_url_enabled?).and_return(tracing_url_enabled?)
+ allow(described_class).to receive(:tracing_url_template).and_return(tracing_url_template)
+ allow(Gitlab::CorrelationId).to receive(:current_id).and_return(correlation_id)
+ allow(Gitlab).to receive(:process_name).and_return(process_name)
+
+ expect(described_class.tracing_url).to eq(tracing_url)
+ end
+ end
+ end
+end