From 2a36dd57864f612454b1bbd0f8c6e9b4fc728190 Mon Sep 17 00:00:00 2001 From: Craig Ringer Date: Fri, 9 Feb 2018 10:24:26 +0800 Subject: [PATCH] Demonstrate that we lose spans on short runs The RemoteReporter loses spans during short-lived executions (#52). This is a test case not a fix. Signed-off-by: Craig Ringer --- CMakeLists.txt | 8 ++++++ src/jaegertracing/shortlived.cpp | 46 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/jaegertracing/shortlived.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f103d986..74fe5a2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,3 +371,11 @@ install( NAMESPACE "${namespace}" DESTINATION "${config_install_dir}" ) + + +add_executable(shortlived "shortlived.cpp") +target_link_libraries(shortlived ${LIBS} jaegertracing) +# If building on top of the local dependencies support, in-tree, add +# target_include_directories(shortlived PRIVATE +# $ +# $) diff --git a/src/jaegertracing/shortlived.cpp b/src/jaegertracing/shortlived.cpp new file mode 100644 index 00000000..b34350bd --- /dev/null +++ b/src/jaegertracing/shortlived.cpp @@ -0,0 +1,46 @@ +#include + +#include +#include + +using std::string; + +const string cfgstr {R"endyaml( +disabled: false +sampler: + type: const + param: 1 +reporter: + queueSize: 100 + bufferFlushInterval: 10 + logSpans: false + localAgentHostPort: 127.0.0.1:6831 +headers: + jaegerDebugHeader: debug-id + jaegerBaggageHeader: baggage + TraceContextHeaderName: trace-id + traceBaggageHeaderPrefix: "testctx-" +baggage_restrictions: + denyBaggageOnInitializationFailure: false + hostPort: 127.0.0.1:5778 + refreshInterval: 60 +)endyaml"}; + +int main(int argc, char *argv[]) +{ + const auto config = jaegertracing::Config::parse(YAML::Load(cfgstr)); + auto tracer = jaegertracing::Tracer::make("shortlived", config); + + string opname("shortlived"); + if (argc > 1) + { + opname += "-"; + opname += argv[1]; + } + auto span = tracer->StartSpan(opname); + span->Finish(); + span.reset(); + /* This should ensure that all spans reach the server */ + //static_cast(tracer.get())->flush(); + tracer->Close(); +}