broke out butterfly into seperate project (#521)

* broke out butterfly into seperate project

* nearly did it...

* updated docs as I have broken the butterfly code off into a seperate dll
This commit is contained in:
Tom Pallister
2018-08-03 08:11:47 +01:00
committed by GitHub
parent 24f8a18579
commit 37fb32b7f5
14 changed files with 66 additions and 485 deletions

View File

@ -1,6 +1,4 @@
using System;
using Butterfly.Client.Tracing;
using Butterfly.OpenTracing;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
@ -12,6 +10,12 @@ using Xunit;
namespace Ocelot.UnitTests.Configuration
{
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Ocelot.Logging;
public class HttpHandlerOptionsCreatorTests
{
private IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;
@ -155,23 +159,21 @@ namespace Ocelot.UnitTests.Configuration
private void GivenARealTracer()
{
var tracer = new RealTracer();
_serviceCollection.AddSingleton<IServiceTracer, RealTracer>();
var tracer = new FakeTracer();
_serviceCollection.AddSingleton<ITracer, FakeTracer>();
_serviceProvider = _serviceCollection.BuildServiceProvider();
_httpHandlerOptionsCreator = new HttpHandlerOptionsCreator(_serviceProvider);
}
class RealTracer : IServiceTracer
class FakeTracer : ITracer
{
public ITracer Tracer => throw new NotImplementedException();
public void Event(HttpContext httpContext, string @event)
{
throw new NotImplementedException();
}
public string ServiceName => throw new NotImplementedException();
public string Environment => throw new NotImplementedException();
public string Identity => throw new NotImplementedException();
public ISpan Start(ISpanBuilder spanBuilder)
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken, Action<string> addTraceIdToRepo,
Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> baseSendAsync)
{
throw new NotImplementedException();
}

View File

@ -23,6 +23,8 @@ using Ocelot.Middleware.Multiplexer;
namespace Ocelot.UnitTests.DependencyInjection
{
using Butterfly;
public class OcelotBuilderTests
{
private readonly IServiceCollection _services;
@ -140,15 +142,6 @@ namespace Ocelot.UnitTests.DependencyInjection
.BDDfy();
}
[Fact]
public void should_set_up_tracing()
{
this.Given(x => WhenISetUpOcelotServices())
.When(x => WhenISetUpOpentracing())
.When(x => WhenIAccessOcelotHttpTracingHandler())
.BDDfy();
}
[Fact]
public void should_set_up_without_passing_in_config()
{
@ -387,24 +380,6 @@ namespace Ocelot.UnitTests.DependencyInjection
}
}
private void WhenISetUpOpentracing()
{
try
{
_ocelotBuilder.AddOpenTracing(
option =>
{
option.CollectorUrl = "http://localhost:9618";
option.Service = "Ocelot.ManualTest";
}
);
}
catch (Exception e)
{
_ex = e;
}
}
private void WhenIAccessLoggerFactory()
{
try

View File

@ -1,27 +1,27 @@
using System;
using Butterfly.Client.Tracing;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Requester;
using Shouldly;
using Xunit;
namespace Ocelot.UnitTests.Requester
{
using System;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Requester;
using Shouldly;
using Xunit;
using Ocelot.Logging;
public class TracingHandlerFactoryTests
{
private TracingHandlerFactory _factory;
private Mock<IServiceTracer> _tracer;
private readonly TracingHandlerFactory _factory;
private Mock<ITracer> _tracer;
private IServiceCollection _serviceCollection;
private IServiceProvider _serviceProvider;
private Mock<IRequestScopedDataRepository> _repo;
public TracingHandlerFactoryTests()
{
_tracer = new Mock<IServiceTracer>();
_tracer = new Mock<ITracer>();
_serviceCollection = new ServiceCollection();
_serviceCollection.AddSingleton<IServiceTracer>(_tracer.Object);
_serviceCollection.AddSingleton<ITracer>(_tracer.Object);
_serviceProvider = _serviceCollection.BuildServiceProvider();
_repo = new Mock<IRequestScopedDataRepository>();
_factory = new TracingHandlerFactory(_serviceProvider, _repo.Object);