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!