Skip to content

Commit

Permalink
Fixed no_rt trace example
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhaowu committed Oct 3, 2023
1 parent ba6ae7b commit cce7512
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/tracing_example_no_rt/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void StartTracing(const char* app_name, const char* filename) {
auto file_sink = std::make_shared<FileSink>(filename);
trace_aggregator->RegisterSink(file_sink);

quill::start();
trace_aggregator->Start();
}

Expand All @@ -44,6 +45,9 @@ int main() {

StartTracing("tracing_example_no_cactus_rt", "build/no-rt.perfetto");

trace_aggregator->RegisterThreadTracer(main_thread_tracer);
trace_aggregator->RegisterThreadTracer(thread1_tracer);

std::thread t([thread1_tracer]() {
for (int i = 0; i < 10; i++) {
{
Expand Down
6 changes: 4 additions & 2 deletions src/cactus_rt/tracing/trace_aggregator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void TraceAggregator::RegisterSink(std::shared_ptr<Sink> sink) {

void TraceAggregator::RegisterThreadTracer(std::shared_ptr<ThreadTracer> tracer) {
if (tracer->tid_ == 0) {
LOG_WARNING(Logger(), "thread {} does not have a valid tid. this shouldn't have happened and is likely a bug", tracer->name_);
LOG_WARNING(Logger(), "thread {} does not have a valid tid", tracer->name_);
}

// RegisterThreadTracer is mutually exclusive with RegisterSink and writing of
Expand Down Expand Up @@ -125,7 +125,9 @@ void TraceAggregator::Run() {

if (tracers_with_events > 0) {
for (auto& sink : sinks_) {
sink->Write(trace);
if (!sink->Write(trace)) {
LOG_WARNING_LIMIT(std::chrono::milliseconds(5000), Logger(), "failed to write trace data to sink, data may be corrupted");
}
}
}
}
Expand Down

0 comments on commit cce7512

Please sign in to comment.