0

I'm trying out OpenTracing Jaeger and have the following file test.cpp:

#include <opentracing/tracer.h>
#include <jaegertracing/Tracer.h>
#include <yaml-cpp/yaml.h>
#include <iostream>

void setUpTracer(const char* configFilePath)
{
    auto configYAML = YAML::LoadFile(configFilePath);
    auto config = jaegertracing::Config::parse(configYAML);
    auto tracer = jaegertracing::Tracer::make(
        "example-service", config, jaegertracing::logging::consoleLogger());
    opentracing::Tracer::InitGlobal(
        std::static_pointer_cast<opentracing::Tracer>(tracer));
}

int main(int argc, char* argv[]){
  setUpTracer(argv[1]);
  std::cout<<"Hello\n";
  return 0;
}

And consider config.yml to be:

disabled: false
reporter:
    logSpans: true
sampler:
  type: const
  param: 1

Now if I compile test.cpp with g++ test.cpp -lopentracing -ljaegertracing -lyaml-cpp and run ./a.out config.yml, I get a

ERROR: cannot connect to socket: Cannot connect socket to remote address { scheme="http", host="127.0.0.1", port=5778, path="/sampling", query="" }

While if I compile with g++ test.cpp -L /usr/local/lib -lopentracing -ljaegertracing -lyaml-cpp, I get a good

INFO: Initializing logging reporter
Hello

The contents of my /usr/local/lib are:

cmake                               libopentracing.so.1.6.0    libthriftqt.so
libjaegertracing.a                  libthrift-0.11.0.so        libthrift.so
libjaegertracing.so                 libthrift.a                libthriftz-0.11.0.so
libjaegertracing.so.0               libthrift_c_glib.a         libthriftz.a
libjaegertracing.so.0.6.0           libthrift_c_glib.la        libthriftz.la
libopentracing.a                    libthrift_c_glib.so        libthriftz.so
libopentracing_mocktracer.a         libthrift_c_glib.so.0      libyaml-cpp.a
libopentracing_mocktracer.so        libthrift_c_glib.so.0.0.0  pkgconfig
libopentracing_mocktracer.so.1      libthrift.la               python2.7
libopentracing_mocktracer.so.1.6.0  libthriftqt-0.11.0.so      python3.6
libopentracing.so                   libthriftqt.a
libopentracing.so.1                 libthriftqt.la

I'm using Jaeger in conjunction with a larger project involving ROS and get the same error even if I add_compile_options(-L /usr/local/lib) for CMakeLists.txt of the appropriate package; so, I wanted to better understand what the exact cause of the above error is, so hopefully that helps me to fix the one involved in ROS.

Thanks!

digikar
  • 576
  • 5
  • 13

1 Answers1

0

You are missing the configuration of Jaeger address. Since you did not provided it, it is trying to connect to the default one, which is TCP protocol, 127.0.0.1 and port 5778. Check for details the configuration section here.

Sergio Santiago
  • 1,316
  • 1
  • 11
  • 19
  • Well, yes, but what is it that causes that error to disappear in the presence of `-L /usr/local/lib` compilation option? – digikar Aug 02 '20 at 16:46
  • Also, the config file takes effect only if the "-L /usr/local/lib" compiler option is specified; otherwise, there seems to be no effect. – digikar Aug 03 '20 at 10:50