]>
git.proxmox.com Git - ceph.git/blob - 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
;
6 #define CATCH_CONFIG_MAIN
7 #include <opentracing/catch2/catch.hpp>
10 auto tracer
= MakeNoopTracer();
12 auto span1
= tracer
->StartSpan("a");
15 SECTION("Spans provide references to the tracer that created them.") {
16 CHECK(&span1
->tracer() == tracer
.get());
19 SECTION("Ensure basic operations compile.") {
20 auto span2
= tracer
->StartSpan("b", {ChildOf(&span1
->context())});
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}});
31 SECTION("A reference to a null SpanContext is ignored.") {
32 StartSpanOptions options
;
33 ChildOf(nullptr).Apply(options
);
34 CHECK(options
.references
.size() == 0);
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());