]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentracing-cpp/test/tracer_test.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / opentracing-cpp / test / tracer_test.cpp
1 #include <opentracing/ext/tags.h>
2 #include <opentracing/noop.h>
3 #include <opentracing/tracer.h>
4 using namespace opentracing;
5
6 #define CATCH_CONFIG_MAIN
7 #include <opentracing/catch2/catch.hpp>
8
9 TEST_CASE("tracer") {
10 auto tracer = MakeNoopTracer();
11
12 auto span1 = tracer->StartSpan("a");
13 CHECK(span1);
14
15 SECTION("Spans provide references to the tracer that created them.") {
16 CHECK(&span1->tracer() == tracer.get());
17 }
18
19 SECTION("Ensure basic operations compile.") {
20 auto span2 = tracer->StartSpan("b", {ChildOf(&span1->context())});
21 CHECK(span2);
22 span2->SetOperationName("b1");
23 span2->SetTag("x", true);
24 span2->SetTag(opentracing::ext::span_kind,
25 opentracing::ext::span_kind_rpc_client);
26 CHECK(span2->BaggageItem("y").empty());
27 span2->Log({{"event", "xyz"}, {"abc", 123}});
28 span2->Finish();
29 }
30
31 SECTION("A reference to a null SpanContext is ignored.") {
32 StartSpanOptions options;
33 ChildOf(nullptr).Apply(options);
34 CHECK(options.references.size() == 0);
35 }
36 }
37
38 TEST_CASE("A tracer can be globally registered") {
39 CHECK(!Tracer::IsGlobalTracerRegistered());
40 auto tracer = MakeNoopTracer();
41 CHECK(Tracer::InitGlobal(tracer) != nullptr);
42 CHECK(Tracer::IsGlobalTracerRegistered());
43 }