]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/jaeger-client-cpp/examples/App.cpp
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / jaeger-client-cpp / examples / App.cpp
1 #include <iostream>
2
3 #include <yaml-cpp/yaml.h>
4
5 #include <jaegertracing/Tracer.h>
6
7 namespace {
8
9 void setUpTracer(const char* configFilePath)
10 {
11 auto configYAML = YAML::LoadFile(configFilePath);
12 auto config = jaegertracing::Config::parse(configYAML);
13 auto tracer = jaegertracing::Tracer::make(
14 "example-service", config, jaegertracing::logging::consoleLogger());
15 opentracing::Tracer::InitGlobal(
16 std::static_pointer_cast<opentracing::Tracer>(tracer));
17 }
18
19 void tracedSubroutine(const std::unique_ptr<opentracing::Span>& parentSpan)
20 {
21 auto span = opentracing::Tracer::Global()->StartSpan(
22 "tracedSubroutine", { opentracing::ChildOf(&parentSpan->context()) });
23 }
24
25 void tracedFunction()
26 {
27 auto span = opentracing::Tracer::Global()->StartSpan("tracedFunction");
28 tracedSubroutine(span);
29 }
30
31 } // anonymous namespace
32
33 int main(int argc, char* argv[])
34 {
35 if (argc < 2) {
36 std::cerr << "usage: " << argv[0] << " <config-yaml-path>\n";
37 return 1;
38 }
39 setUpTracer(argv[1]);
40 tracedFunction();
41 // Not stricly necessary to close tracer, but might flush any buffered
42 // spans. See more details in opentracing::Tracer::Close() documentation.
43 opentracing::Tracer::Global()->Close();
44 return 0;
45 }