private void ThenTheTracerIsCalled(FakeTracer fakeTracer) { var commandOnAllStateMachines = Wait.WaitFor(10000).Until(() => fakeTracer.BuildSpanCalled >= 2); _output.WriteLine($"fakeTracer.BuildSpanCalled is {fakeTracer.BuildSpanCalled}"); commandOnAllStateMachines.ShouldBeTrue(); }
public void should_return_tracing_header() { int port = RandomPortFinder.GetRandomPort(); var configuration = new FileConfiguration { Routes = new List <FileRoute> { new FileRoute { DownstreamPathTemplate = "/api/values", DownstreamScheme = "http", DownstreamHostAndPorts = new List <FileHostAndPort> { new FileHostAndPort { Host = "localhost", Port = port, } }, UpstreamPathTemplate = "/api001/values", UpstreamHttpMethod = new List <string> { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { UseTracing = true }, DownstreamHeaderTransform = new Dictionary <string, string>() { { "Trace-Id", "{TraceId}" }, { "Tom", "Laura" } } } } }; var butterflyPort = RandomPortFinder.GetRandomPort(); var butterflyUrl = $"http://localhost:{butterflyPort}"; var fakeTracer = new FakeTracer(); this.Given(x => GivenFakeOpenTracing(butterflyUrl)) .And(x => GivenServiceOneIsRunning($"http://localhost:{port}", "/api/values", 200, "Hello from Laura", butterflyUrl)) .And(x => _steps.GivenThereIsAConfiguration(configuration)) .And(x => _steps.GivenOcelotIsRunningUsingOpenTracing(fakeTracer)) .When(x => _steps.WhenIGetUrlOnTheApiGateway("/api001/values")) .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura")) .And(x => _steps.ThenTheTraceHeaderIsSet("Trace-Id")) .And(x => _steps.ThenTheResponseHeaderIs("Tom", "Laura")) .BDDfy(); }
public void should_forward_tracing_information_from_ocelot_and_downstream_services() { int port1 = RandomPortFinder.GetRandomPort(); int port2 = RandomPortFinder.GetRandomPort(); var configuration = new FileConfiguration() { ReRoutes = new List <FileReRoute>() { new FileReRoute() { DownstreamPathTemplate = "/api/values", DownstreamScheme = "http", DownstreamHostAndPorts = new List <FileHostAndPort> { new FileHostAndPort { Host = "localhost", Port = port1, } }, UpstreamPathTemplate = "/api001/values", UpstreamHttpMethod = new List <string> { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { UseTracing = true } }, new FileReRoute() { DownstreamPathTemplate = "/api/values", DownstreamScheme = "http", DownstreamHostAndPorts = new List <FileHostAndPort> { new FileHostAndPort() { Host = "localhost", Port = port2, } }, UpstreamPathTemplate = "/api002/values", UpstreamHttpMethod = new List <string> { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { UseTracing = true } } } }; var tracingPort = RandomPortFinder.GetRandomPort(); var tracingUrl = $"http://localhost:{tracingPort}"; var fakeTracer = new FakeTracer(); this.Given(_ => GivenFakeOpenTracing(tracingUrl)) .And(_ => GivenServiceOneIsRunning($"http://localhost:{port1}", "/api/values", 200, "Hello from Laura", tracingUrl)) .And(_ => GivenServiceTwoIsRunning($"http://localhost:{port2}", "/api/values", 200, "Hello from Tom", tracingUrl)) .And(_ => _steps.GivenThereIsAConfiguration(configuration)) .And(_ => _steps.GivenOcelotIsRunningUsingOpenTracing(fakeTracer)) .When(_ => _steps.WhenIGetUrlOnTheApiGateway("/api001/values")) .Then(_ => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) .And(_ => _steps.ThenTheResponseBodyShouldBe("Hello from Laura")) .When(_ => _steps.WhenIGetUrlOnTheApiGateway("/api002/values")) .Then(_ => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) .And(_ => _steps.ThenTheResponseBodyShouldBe("Hello from Tom")) .BDDfy(); var commandOnAllStateMachines = Wait.WaitFor(10000).Until(() => fakeTracer.BuildSpanCalled >= 2); _output.WriteLine($"fakeTracer.BuildSpanCalled is {fakeTracer.BuildSpanCalled}"); commandOnAllStateMachines.ShouldBeTrue(); }