Search code examples
c#jaegeropentracing

Jaeger error No suitable sender found. Using NoopSender


I am using below example of OpenTracing, Jaeger https://github.com/yurishkuro/opentracing-tutorial/tree/master/csharp/src/lesson01

I have my Jaeger UI running for which I used the below command.

docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p 5775:5775/udp -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778-p 16686:16686 -p 14268:14268 -p 9411:9411 jaegertracing/all-in-one:latest

Below is my code which I tried from above github link

using Microsoft.Extensions.Logging;
using System;
using Jaeger.Metrics;
using Jaeger.Reporters;
using Jaeger.Samplers;
using Jaeger.Senders.Thrift;
using Jaeger;
using OpenTracing;
using OpenTracing.Util;

namespace Jaeger_Class_Library
{
    public class Hello
    {
        private readonly ITracer _tracer;
        private readonly ILogger<Hello> _logger;

        public Hello()
        {

        }

        public Hello(OpenTracing.ITracer tracer, ILoggerFactory loggerFactory)
        {
            _tracer = tracer;
            _logger = loggerFactory.CreateLogger<Hello>();
        }

        public void SayHello(string helloTo)
        {
            var span = _tracer.BuildSpan("say-hello").Start();
            var helloString = $"Hello, {helloTo}!";
            _logger.LogInformation(helloString);
            span.Finish();
        }

        private static Tracer InitTracer(string serviceName, ILoggerFactory loggerFactory)
        {
            var samplerConfiguration = new Configuration.SamplerConfiguration(loggerFactory)
                .WithType(ConstSampler.Type);
                //.WithParam(1);

            var reporterConfiguration = new Configuration.ReporterConfiguration(loggerFactory)
                .WithLogSpans(true);

            return (Tracer)new Configuration(serviceName, loggerFactory)
                .WithSampler(samplerConfiguration)
                .WithReporter(reporterConfiguration)
                .GetTracer();
        }

        public void TriggerTrace()
        {
            using (var loggerFactory = new LoggerFactory().AddConsole())
            {
                var helloTo = "Test message to Trace";
                using (var tracer = InitTracer("hello-world", loggerFactory))
                {
                    new Hello(tracer, loggerFactory).SayHello(helloTo);
                }
            }
        }

    }

}

Above is the Class Library project. Below is my console app where I am calling the TriggerTrace Method. When that function is executed I would expect some traces in the Jaeger UI,

static void Main(string[] args)
        {

            Hello hello = new Hello();
            hello.TriggerTrace();
            Console.WriteLine("Tracing...");

        }

Below is the error I see, I do not see any traces in the UI, Am I missing any configuration ?

warn: Jaeger.Senders.SenderResolver[0]
      **No suitable sender found. Using NoopSender, meaning that data will not be sent anywhere!**
info: Jaeger.Configuration[0]
      Initialized Tracer(ServiceName=hello-world, Version=CSharp-0.4.2.0, Reporter=CompositeReporter(Reporters=RemoteReporter(Sender=NoopSender()), LoggingReporter(Logger=Microsoft.Extensions.Logging.Logger`1[Jaeger.Reporters.LoggingReporter])), Sampler=ConstSampler(True), IPv4=172425085, Tags=[jaeger.version, CSharp-0.4.2.0], [hostname, RRUPAKULA-LAP], [ip, 10.70.255.125], ZipkinSharedRpcSpan=False, ExpandExceptionLogs=False, UseTraceId128Bit=False)
info: Jaeger_Class_Library.Hello[0]
      Hello, Test message to Trace!
info: Jaeger.Reporters.LoggingReporter[0]
      Span reported: cc9fa176171a0dab:cc9fa176171a0dab:0000000000000000:1 - say-hello
Tracing...

Solution

  • I had the same problem. Found this page that explains how to configure Thrift sender: https://github.com/jaegertracing/jaeger-client-csharp/blob/master/src/Senders/Jaeger.Senders.Thrift/README.md

    The C# tutorial does not mention it though ...

    And here is my InitTracer(). Works fine with Jaeger launched from binary:

        private static Tracer InitTracer(string serviceName, ILoggerFactory loggerFactory)
        {
            Configuration.SenderConfiguration.DefaultSenderResolver = new SenderResolver(loggerFactory)
                .RegisterSenderFactory<ThriftSenderFactory>();
    
            var samplerConfiguration = new Configuration.SamplerConfiguration(loggerFactory)
                .WithType(ConstSampler.Type)
                .WithParam(1);
    
            var sender = new SenderConfiguration(loggerFactory);
    
            var reporterConfiguration = new Configuration.ReporterConfiguration(loggerFactory)
                .WithLogSpans(true)
                .WithSender(sender);
    
            return (Tracer)new Configuration(serviceName, loggerFactory)
                .WithSampler(samplerConfiguration)
                .WithReporter(reporterConfiguration)
                .GetTracer();
        }