public void TestDispose() { IReporter reporter = Substitute.For <IReporter>(); ISampler sampler = Substitute.For <ISampler>(); var tracer = new Tracer.Builder("bonda") .WithReporter(reporter) .WithSampler(sampler) .Build(); tracer.Dispose(); reporter.Received(1).CloseAsync(Arg.Any <CancellationToken>()); sampler.Received(1).Close(); }
public void TestPublish() { var cf = new ConnectionFactory() { Uri = new Uri("amqp://*****:*****@localhost:5672") }; var serviceName = "initExampleService"; //var transport = new JaegerHttpTransport("192.168.99.100"); var transport = new JaegerUdpTransport("10.150.28.30", 6831); //var zt = new ZipkinJSONTransport(new Uri("http://192.168.99.100:9411"), 2); var reporter = new RemoteReporter.Builder(transport).Build(); //var zreporter = new RemoteReporter.Builder(zt).Build(); var sampler = new ConstSampler(true); var serviceProvider = new ServiceCollection() .AddLogging() //<-- You were missing this .BuildServiceProvider(); //get logger var loggerFactory = serviceProvider.GetService <ILoggerFactory>(); loggerFactory.AddConsole(LogLevel.Trace); loggerFactory.AddDebug(LogLevel.Trace); var log = loggerFactory.CreateLogger("test"); log.LogInformation("prova log {0}", "prova"); var logReporter = new LoggingReporter(loggerFactory); var tracer = new Tracer.Builder(serviceName) .WithLoggerFactory(loggerFactory) //.WithTransport(transport) //.WithReporter(logReporter) .WithReporter(reporter) .WithSampler(sampler) .Build(); using (var span = tracer.BuildSpan("fakeget").StartActive(true)) { var conn = cf.CreateConnection("testtracing"); var model = new TracingModel(conn.CreateModel(), tracer); // TODO: Add your test code here for (int i = 0; i < 25; i++) { model.BasicPublish("testexchange", "", false, null, Encoding.UTF8.GetBytes("testmessage")); /*var consumer = new EventingBasicConsumer(model); * consumer.Received += (ch, ea) => * { * var body = ea.Body; * // ... process the message * model.BasicAck(ea.DeliveryTag, false); * }; * * Task.Delay(200).Wait(); * * var res = model.BasicConsume("testqueueu", false, consumer);*/ Task.Delay(2500).Wait(); var res = model.BasicGet("testqueueu", true); } } tracer.Dispose(); Assert.True(true, "Your first passing test"); }