yurishkuro / opentracing-tutorial

A collection of tutorials for the OpenTracing API
Apache License 2.0
1.57k stars 407 forks source link

Defect in lession03 Publisher.java and Formatter.java in “solution” folder #53

Closed liurui-1 closed 5 years ago

liurui-1 commented 5 years ago

There is a defect in lession03 Publisher.java and Formatter.java in “solution” folder. The following code makes tracer object to be closed soon in the beginning. And the server-side tracing does not work.

try (JaegerTracer tracer = Tracing.init("publisher")) {
  new Publisher(tracer).run(args); //This is asynchronous!
}
yurishkuro commented 5 years ago

You're right. Original version wasn't using try-with-resouce. Would you like to create a PR to fix this?

liurui-1 commented 5 years ago

@yurishkuro In my app, I just do not need to close the tracer object because the dropwizard server is always running. If we want to close tracer object gracefully, we have to add a lot of lifecycle code for dropwizard server and add trace close code in the hook of server close which has nothing to do with this tutorial. I do not know this if this is the right way.

yurishkuro commented 5 years ago

In this tutorial the servers are also long-running, so there's no strong need to close the tracer. Also, I think Jaeger tracer already registers itself with JVM shutdown hooks, so on app exit it should flush automatically anyway.

liurui-1 commented 5 years ago

Thanks @yurishkuro . I just submited a PR as following: https://github.com/yurishkuro/opentracing-tutorial/pull/54