Can't get opentracing to work on sample project

Requesting help with this, if someone has some spare time and is interested.

OpenTracing: http://opentracing.io/

Having failed to get it working for a personal project, I cloned the java starter example on github, made a branch for it and added it there, but it also didn’t work.

The code can be found here: https://github.com/KoenDG/play-java-starter-example/tree/jaegertracing

In particular, I added the dependency, I added A provider for the Tracer class, bound it in the Module and added it to the CountController.

Then added some tracing in the count method.

The method still works and does the counting, but the logs aren’t showing up in the console and the Jaeger UI reports no services detected.

I’m not sure what I’m forgetting, if it’s a Play, Jaeger or network thing.

EDIT: Removing these links with where I found the examples since I’m a new user and there’s a max limit of 2 links per post for new users. I linked them in the commit message.

Note: if anyone is going to try this, you have to have a Jaeger instance running, suggested way is by using docker, as stated in the first link.

This is usually handled through Cinnamon (aka Lightbend Telemetry):

Thanks for the link, but I have no experience with Akka HTTP or Actors. Also, it’s in Scala, which I have no experience in.

I’m more interested in keeping track of how long individual methods within a call take, in a manner that isn’t dependant on anything other than the tracing library itself.

I’ve been using OpenTracing directly with an Akka based service. I see no reason why Play would inhibit OpenTracing from working. I’ve found Jaeger tracing to be particularly reliable.

Meanwhile, I’ve also asked for help on Jaeger’s google group and they got it working. I’ll test it when I get home from work but it’s probably a configuration error on my part.

1 Like

@KoenDG please let us know about how you solve the problem. ;-)

@marcospereira It did indeed turn out to be a configuration error on my part.

The problem was effectively in the TracerProvider not being constructed properly. Changing it to the following code got it working:

@Override
public Tracer get() {
    return new Configuration("play-java-starter-example")
    .withReporter(
        Configuration.ReporterConfiguration.fromEnv()
            .withLogSpans(true)
            .withFlushInterval(1000)
            .withMaxQueueSize(10000)
            .withSender(
                Configuration.SenderConfiguration.fromEnv()
                    .withAgentHost("localhost")
                    .withAgentPort(null)
            )
    )
    .withSampler(
        Configuration.SamplerConfiguration.fromEnv()
            .withType(ConstSampler.TYPE)
            .withParam(1)
    )
    .getTracerBuilder()
    .build();
}

And that worked. Going to the route made traces and the log show up in Jaeger

Also ran a non-daemon docker container, in case the log output showed something interesting:

docker run -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

The conversation I had on the Jaeger google group can be found here btw: https://groups.google.com/forum/#!topic/jaeger-tracing/x5C9pjZsFMk

EDIT: I pushed the working code to my branch.

2 Likes