2

So I'm trying send OpenTelemetry trace back to Jaeger. I've tried sending the traces to console and it works. But I'm not getting anything when sending it to Jaeger.

builder.Services.AddOpenTelemetryTracing(b =>
{
    b.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("ServiceA"))
        .AddSource("TelemetryDemo")
        .AddHttpClientInstrumentation()
        .AddAspNetCoreInstrumentation()
        .AddOtlpExporter(o =>
        {
            o.Endpoint = new Uri("http://localhost:4317");
            o.ExportProcessorType = ExportProcessorType.Simple;
        })
        .AddConsoleExporter();
});

I'm running Jaeger's All-in-One from Docker hub: https://hub.docker.com/r/jaegertracing/all-in-one

This is the command that I'm running: docker run -d --name jaeger -p 16686:16686 -p 6831:6831/udp -p 4317:4317 -p 55680:55680 jaegertracing/all-in-one

The traces is showing on the console, but when I open Jaeger's dashboard, I got nothing. What is wrong here?

Edit: Figured it out. Jaeger has 2 Docker images: one that is Otel-compliant, and one that is not. In this question I was using the one that is not, so that is why the Otlp Exporter did not work.

I have since changed to use the OTel-compliant image in https://hub.docker.com/r/jaegertracing/opentelemetry-all-in-one/ (notice this one has "OTEL" name in it)

Farid
  • 872
  • 1
  • 13
  • 30

2 Answers2

1

I believe as of 2022, the AIO image does support OTLP. Try running the docker container using below

docker run -d --name jaeger \
  -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
  -e COLLECTOR_OTLP_ENABLED=true \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 4317:4317 \
  -p 4318:4318 \
  -p 14250:14250 \
  -p 14268:14268 \
  -p 14269:14269 \
  -p 9411:9411 \
  jaegertracing/all-in-one:<version>

Replace with whatever version of image you have. I tried with 1.37

Akhilesh
  • 111
  • 2
  • 9
0

Update 05/2023

For .net you need something like this:

.AddOtlpExporter(otlpOptions =>
{
    otlpOptions.Endpoint = new Uri("http://localhost:4317");
})

More details about that in here: https://opentelemetry.io/docs/instrumentation/net/exporters/#otlp-endpoint

With that set in your .NET app, you can either spin up a Jaeger All-in-one container, explained here: https://www.jaegertracing.io/docs/1.45/getting-started/#all-in-one

Or send the trace through the OTel Collector, with the following Collector config:

receivers:
  otlp:
    protocols:
      grpc:
      http:

exporters:
  otlp:
    endpoint: "jaeger:4317"
    tls:
      insecure: true
  logging:
    loglevel: debug

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: []
      exporters: [logging,otlp]

Old answer

You need to use the JaegerExporter or send the traces to a otel-collector and from the collector to Jaeger.
For .net you need something like this:

.AddJaegerExporter(o =>
    {
        o.AgentHost = "localhost";
        o.AgentPort = 14250;
    })

Make sure you expose the Jaeger port to your localhost.

That's the easiest way, and you can stop here if you want.

But if you think about changing the backend in the future, maybe it would be a good idea to invest some time in configuring the otel-collector now.

OTel-collector docs

You would need a conf.yml like this (logging is optional in this case):

receivers:
  otlp:
    protocols:
      grpc:
      http:

exporters:
  jaeger:
    endpoint: "jaeger:14250"
    tls:
      insecure: true
  logging:
    loglevel: debug

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: []
      exporters: [logging,jaeger]

And your collector Dockerfile would be something like this:

FROM otel/opentelemetry-collector-contrib:0.48.0
COPY conf.yml .
EXPOSE 1888
EXPOSE 8888
EXPOSE 8889
EXPOSE 13133
EXPOSE 4317
EXPOSE 55670
CMD [ "--config=conf.yml" ]

You can send the trace to the collector, the collector will receive OTLP and will send to Jaeger.
In this 2nd scenario, you can continue using "http://localhost:4317" if you configure your collector to expose its ports to localhost.

Juliano Costa
  • 2,175
  • 2
  • 18
  • 30
  • From here (https://www.jaegertracing.io/download/), it says the all-in-one Docker image already contains a collector. Why would I need another otel collector? – Farid Apr 06 '22 at 13:44
  • You don't need one. As I've mentioned, just if you plan to change from Jaeger to something else in the future. The OTel-Collector is vendor agnostic, so you can move from one exporter to other without having to change your apps configuration. – Juliano Costa Apr 07 '22 at 05:28
  • If you wanna send your Traces from your code, directly to Jaeger, just use the `AddJaegerExporter` as I've mentioned in the first part of the answer. – Juliano Costa Apr 07 '22 at 05:30
  • BTW, that is because the Collector shipped with Jaeger, just receives Traces sent via the Jaeger Exporter. – Juliano Costa Apr 07 '22 at 05:32
  • 1
    I finally figured it out. Jaeger has 2 Docker image - one that is OTel compliant, and the other is not (which is the one that I used). So if I wanted to use the Jaeger image that is not Otel-compliant, I would do `AddJaegerExporter` instead of `AddOtlpExporter`. Thanks for giving me the clue! – Farid Apr 18 '22 at 07:23
  • 1
    Don't forget that the AddJaegerExporter is about to be deprecated https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Exporter.Jaeger/README.md – Tore Nestenius May 09 '23 at 09:28