This repository was archived by the owner on Aug 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 10 files changed +68
-39
lines changed Expand file tree Collapse file tree 10 files changed +68
-39
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ find_package(nlohmann_json CONFIG REQUIRED)
63
63
list (APPEND LIBS nlohmann_json)
64
64
list (APPEND package_deps nlohmann_json)
65
65
66
+ option (JAEGERTRACING_BUILD_EXAMPLES "Build examples" ON )
67
+
66
68
option (JAEGERTRACING_COVERAGE "Build with coverage" $ENV{COVERAGE} )
67
69
option (JAEGERTRACING_BUILD_CROSSDOCK "Build crossdock" $ENV{CROSSDOCK} )
68
70
cmake_dependent_option(
@@ -240,6 +242,11 @@ configure_file(
240
242
src/jaegertracing/Constants.h
241
243
@ONLY)
242
244
245
+ if (JAEGERTRACING_BUILD_EXAMPLES)
246
+ add_executable (app examples/App.cpp)
247
+ target_link_libraries (app PUBLIC ${JAEGERTRACING_LIB} )
248
+ endif ()
249
+
243
250
if (BUILD_TESTING)
244
251
add_library (testutils
245
252
src/jaegertracing/testutils/TUDPTransport.cpp
Original file line number Diff line number Diff line change @@ -10,20 +10,15 @@ Please see [CONTRIBUTING.md](CONTRIBUTING.md).
10
10
## Generated files
11
11
12
12
This project uses Apache Thrift for wire-format protocol support code
13
- generation. It currently requires exactly Thrift 0.9.2 or 0.9.3. Patches have
14
- been applied to the generated code so it cannot be directly re-generated from
15
- the IDL in the ` idl ` submodule
16
-
17
- (see https://github.com/jaegertracing/jaeger-client-cpp/issues/45 )
13
+ generation. It currently requires Thrift 0.11.0.
18
14
19
15
The code can be re-generated with
20
16
21
- git submodule init
22
- git submodule update
23
- find idl/thrift/ -type f -name \*.thrift -exec thrift -gen cpp -out src/jaegertracing/thrift-gen {} \;
24
-
25
- but at time of writing (Thrift 0.11.0) the resulting code is invalid due to
26
- https://issues.apache.org/jira/browse/THRIFT-4484 .
17
+ ``` bash
18
+ $ git submodule update --init
19
+ $ find idl/thrift/ -type f -name \* .thrift -exec thrift -gen cpp -out src/jaegertracing/thrift-gen {} \;
20
+ $ git apply scripts/thrift-gen.patch
21
+ ```
27
22
28
23
## License
29
24
@@ -35,4 +30,3 @@ https://issues.apache.org/jira/browse/THRIFT-4484.
35
30
[ cov ] : https://codecov.io/gh/jaegertracing/jaeger-client-cpp
36
31
[ ot-img ] : https://img.shields.io/badge/OpenTracing--1.0-enabled-blue.svg
37
32
[ ot-url ] : http://opentracing.io
38
-
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 1
- service_name : test-service
2
1
disabled : false
3
- sampler :
4
- type : probabilistic
5
- param : 0.001
6
2
reporter :
7
- queueSize : 100
8
- bufferFlushInterval : 10
9
- logSpans : false
10
- localAgentHostPort : 127.0.0.1:6831
11
- headers :
12
- jaegerDebugHeader : debug-id
13
- jaegerBaggageHeader : baggage
14
- TraceContextHeaderName : trace-id
15
- traceBaggageHeaderPrefix : testctx-
16
- baggage_restrictions :
17
- denyBaggageOnInitializationFailure : false
18
- hostPort : 127.0.0.1:5778
19
- refreshInterval : 60
3
+ logSpans : true
4
+ sampler :
5
+ type : const
6
+ param : 1
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class Config {
32
32
33
33
static Config parse (const YAML::Node& configYAML)
34
34
{
35
- if (!configYAML.IsMap ()) {
35
+ if (!configYAML.IsDefined () || !configYAML. IsMap ()) {
36
36
return Config ();
37
37
}
38
38
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
- #include " jaegertracing/Constants.h"
18
17
#include " jaegertracing/TracerFactory.h"
18
+ #include " jaegertracing/Constants.h"
19
19
#include < gtest/gtest.h>
20
20
21
21
namespace jaegertracing {
@@ -26,10 +26,6 @@ TEST(TracerFactory, testInvalidConfig)
26
26
" abc: {" ,
27
27
R"( {
28
28
"service_name": {}
29
- })" ,
30
- R"( {
31
- "service_name": "t",
32
- "badField": 97
33
29
})" };
34
30
TracerFactory tracerFactory;
35
31
for (auto && invalidConfig : invalidConfigTestCases) {
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class RestrictionsConfig {
33
33
34
34
static RestrictionsConfig parse (const YAML::Node& configYAML)
35
35
{
36
- if (!configYAML.IsMap ()) {
36
+ if (!configYAML.IsDefined () || !configYAML. IsMap ()) {
37
37
return RestrictionsConfig ();
38
38
}
39
39
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class HeadersConfig {
30
30
31
31
static HeadersConfig parse (const YAML::Node& configYAML)
32
32
{
33
- if (!configYAML.IsMap ()) {
33
+ if (!configYAML.IsDefined () || !configYAML. IsMap ()) {
34
34
return HeadersConfig ();
35
35
}
36
36
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ class Config {
49
49
50
50
static Config parse (const YAML::Node& configYAML)
51
51
{
52
- if (!configYAML.IsMap ()) {
52
+ if (!configYAML.IsDefined () || !configYAML. IsMap ()) {
53
53
return Config ();
54
54
}
55
55
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ class Config {
54
54
55
55
static Config parse (const YAML::Node& configYAML)
56
56
{
57
- if (!configYAML.IsMap ()) {
57
+ if (!configYAML.IsDefined () || !configYAML. IsMap ()) {
58
58
return Config ();
59
59
}
60
60
You can’t perform that action at this time.
0 commit comments