Skip to content

Commit

Permalink
Demonstrate that we lose spans on short runs
Browse files Browse the repository at this point in the history
The RemoteReporter loses spans during short-lived executions (jaegertracing#52).

This is a test case not a fix.

Signed-off-by: Craig Ringer <[email protected]>
  • Loading branch information
ringerc committed Feb 9, 2018
1 parent c36adcf commit 2a36dd5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# $<BUILD_INTERFACE:${jaegertracing_SOURCE_DIR}/src>
# $<BUILD_INTERFACE:${jaegertracing_BINARY_DIR}/src>)
46 changes: 46 additions & 0 deletions src/jaegertracing/shortlived.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <jaegertracing/Tracer.h>

#include <chrono>
#include <thread>

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<jaegertracing::Tracer*>(tracer.get())->flush();
tracer->Close();
}

0 comments on commit 2a36dd5

Please sign in to comment.