Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b2b6019
first implementation of Trace Spans in pubsub
IlaHadiAssar Feb 18, 2026
ebd6446
added buffering to collect spans
IlaHadiAssar Feb 18, 2026
86d2290
first draft, using json for exports
IlaHadiAssar Feb 23, 2026
2fb2f1b
spans are now exported to 1 file per process
IlaHadiAssar Feb 23, 2026
ebbb280
added tracing of metadata
IlaHadiAssar Feb 24, 2026
06f2620
added exit and crash handling
IlaHadiAssar Feb 25, 2026
2cc3cb4
Merge branch 'eclipse-ecal:master' into feature/tracing_poc
IlaHadiAssar Feb 26, 2026
7b0eb26
added span around SHM handshake
IlaHadiAssar Feb 26, 2026
50e57f5
Merge branch 'feature/tracing_poc' of github.com:hadiassarila-debug/e…
IlaHadiAssar Feb 26, 2026
5825802
minor code cleanup and switch to jsonl format
IlaHadiAssar Feb 26, 2026
3068f94
moved SendSpan creation to publisher implementation
IlaHadiAssar Feb 27, 2026
ff08fd6
added bitmask flags for layertype
IlaHadiAssar Mar 2, 2026
6460aee
added tracinglayertype enum to receive spans and shm handshake
IlaHadiAssar Mar 2, 2026
419a342
added version number
IlaHadiAssar Mar 2, 2026
e3b16a0
rule of 5
IlaHadiAssar Mar 2, 2026
923bc40
justified Span structs
IlaHadiAssar Mar 2, 2026
9f6a4aa
added constant for batch size
IlaHadiAssar Mar 2, 2026
34bfe51
cleanup
IlaHadiAssar Mar 2, 2026
677ecf2
moved file writing responsability to seperate class
IlaHadiAssar Mar 2, 2026
d73b155
moved traceprovider and span to seperate files
IlaHadiAssar Mar 2, 2026
b0b5f31
cleanup
IlaHadiAssar Mar 2, 2026
4641c13
write payload size at receive
IlaHadiAssar Mar 2, 2026
b0feb16
fixed missing includes
IlaHadiAssar Mar 2, 2026
6bc4db2
removed excessive default values
IlaHadiAssar Mar 2, 2026
f593df6
removed shm handshake span
IlaHadiAssar Mar 4, 2026
c6e4dc7
removed unused operation type
IlaHadiAssar Mar 4, 2026
417a35e
cleanup
IlaHadiAssar Mar 5, 2026
9441b93
fixed race conditions
IlaHadiAssar Mar 5, 2026
1cb8081
added tracing testsuite
IlaHadiAssar Mar 5, 2026
ebdfcac
changed buffer default size
IlaHadiAssar Mar 9, 2026
0b0fefc
removed duplicate filepaths
IlaHadiAssar Mar 9, 2026
123e2ab
Merge branch 'eclipse-ecal:master' into feature/tracing_poc
IlaHadiAssar Mar 9, 2026
f0163d2
no data dir now aborts program
IlaHadiAssar Mar 9, 2026
02b0569
Merge branch 'feature/tracing_poc' of github.com:hadiassarila-debug/e…
IlaHadiAssar Mar 9, 2026
cb9ccdd
Merge branch 'eclipse-ecal:master' into feature/tracing_poc
IlaHadiAssar Mar 10, 2026
0f80ff7
switched to ecal internal method to get pid
IlaHadiAssar Mar 10, 2026
cc2d03d
Merge branch 'feature/tracing_poc' of github.com:hadiassarila-debug/e…
IlaHadiAssar Mar 10, 2026
4d904a7
include nlohmann_json via fetchcontent
IlaHadiAssar Mar 10, 2026
0583d09
Merge branch 'eclipse-ecal:master' into feature/tracing_poc
IlaHadiAssar Mar 11, 2026
7b5f067
added find_package for nlohmann_json
IlaHadiAssar Mar 11, 2026
b7b03aa
Merge branch 'feature/tracing_poc' of github.com:hadiassarila-debug/e…
IlaHadiAssar Mar 11, 2026
0b3e08d
removed platform specific signal handling for buffer flush
IlaHadiAssar Mar 11, 2026
cbb21d7
set tracing env variable in workflows
IlaHadiAssar Mar 11, 2026
b7733c3
fixed workflows
IlaHadiAssar Mar 11, 2026
c817c47
removed platform specific get pid function
IlaHadiAssar Mar 11, 2026
70675cd
added windows compatibillity to tracing_tests
IlaHadiAssar Mar 11, 2026
45844e0
fixed windows linking issue
IlaHadiAssar Mar 11, 2026
f3ef015
added support for windows tmp directory
IlaHadiAssar Mar 11, 2026
8aa97ff
merge upstream master into feature/tracing_poc
IlaHadiAssar Mar 12, 2026
f057597
Merge branch 'eclipse-ecal:master' into feature/tracing_poc
IlaHadiAssar Mar 24, 2026
07e290f
threaded file writinh
IlaHadiAssar Apr 1, 2026
acd62f6
adjusted singele instance usage
IlaHadiAssar Apr 1, 2026
e657c72
implemented tracing_writer interface
IlaHadiAssar Apr 1, 2026
ee29aad
made file writer interchangeable
IlaHadiAssar Apr 14, 2026
c9f1dfe
Merge branch 'eclipse-ecal:master' into feature/tracing_poc
IlaHadiAssar Apr 14, 2026
b298c6b
restructured tests
IlaHadiAssar Apr 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def build_requirements(self):
def requirements(self):
self.requires("hdf5/1.10.6")
self.requires("protobuf/3.17.1")
self.requires("nlohmann_json/3.11.2")
self.requires("libcurl/7.78.0")
self.requires("qt/5.15.2")
self.requires("spdlog/1.9.2")
Expand Down Expand Up @@ -51,6 +52,6 @@ def generate(self):
else:
tc.variables["Protobuf_PROTOC_EXECUTABLE"] = os.path.join(self.deps_cpp_info["protobuf"].rootpath, "bin", "protoc")
tc.generate()



11 changes: 11 additions & 0 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ find_package(asio REQUIRED)
find_package(Threads REQUIRED)
find_package(ecaludp REQUIRED)
find_package(protozero REQUIRED)
find_package(nlohmann_json REQUIRED)

if (ECAL_CORE_CONFIGURATION)
find_package(yaml-cpp REQUIRED)
Expand Down Expand Up @@ -459,6 +460,14 @@ if(ECAL_CORE_TIMEPLUGIN)
)
endif()

######################################
# tracing
######################################
set(ecal_tracing_src
src/tracing/tracing.cpp
src/tracing/tracing.h
)

######################################
# util
######################################
Expand Down Expand Up @@ -635,6 +644,7 @@ set(ecal_sources
${ecal_serialization_src}
${ecal_service_src}
${ecal_time_src}
${ecal_tracing_src}
${ecal_util_src}
${ecal_cmn_src}
${ecal_builder_src}
Expand Down Expand Up @@ -717,6 +727,7 @@ target_link_libraries(ecal_core_private
$<$<BOOL:${ECAL_CORE_TRANSPORT_TCP}>:tcp_pubsub::tcp_pubsub>
$<$<BOOL:${ECAL_CORE_TIMEPLUGIN}>:ecaltime>
ecaludp::ecaludp
nlohmann_json::nlohmann_json
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${QNXNTO}>>>:dl>
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>,$<NOT:$<BOOL:${QNXNTO}>>>:rt>
$<$<STREQUAL:${CMAKE_SYSTEM_NAME},FreeBSD>:util>
Expand Down
17 changes: 17 additions & 0 deletions ecal/core/src/io/shm/ecal_memfile_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ecal_memfile_header.h"
#include "ecal_memfile_naming.h"
#include "ecal_memfile_sync.h"
#include "tracing/tracing.h"

#include <chrono>
#include <mutex>
Expand Down Expand Up @@ -161,6 +162,9 @@ namespace eCAL
m_attr.timeout_ack_ms = data_.acknowledge_timeout_ms;
if (m_attr.timeout_ack_ms < 0) m_attr.timeout_ack_ms = 0;

// store clock for tracing (does not modify SHM protocol)
m_current_clock_for_tracing = data_.clock;

// write header and payload into the memory file
#ifndef NDEBUG
Logging::Log(Logging::log_level_debug4, m_base_name + "::CSyncMemoryFile::Write");
Expand Down Expand Up @@ -250,6 +254,12 @@ namespace eCAL
return m_attr.min_size;
}

void CSyncMemoryFile::SetTracingInfo(uint64_t entity_id_, int32_t process_id_)
{
m_entity_id_for_tracing = entity_id_;
m_process_id_for_tracing = process_id_;
}

bool CSyncMemoryFile::Create(const std::string& base_name_, size_t size_)
{
if (m_created) return false;
Expand Down Expand Up @@ -346,6 +356,13 @@ namespace eCAL
{
if (!m_created) return;

// Trace the SHM handshake operation (does not modify SHM protocol)
eCAL::tracing::CShmHandshakeSpan handshake_span(
m_entity_id_for_tracing,
m_process_id_for_tracing,
m_current_clock_for_tracing
);

// fire the publisher events
// connected subscribers will read the content from the memory file

Expand Down
7 changes: 7 additions & 0 deletions ecal/core/src/io/shm/ecal_memfile_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace eCAL
bool CheckSize(size_t size_);
bool Write(CPayloadWriter& payload_, const SWriterAttr& data_, bool force_full_write_ = false);

void SetTracingInfo(uint64_t entity_id_, int32_t process_id_);

std::string GetName() const;
size_t GetSize() const;
bool IsCreated() const { return m_created; };
Expand All @@ -76,6 +78,11 @@ namespace eCAL
CMemoryFile m_memfile;
bool m_created;

// Tracing context (not part of core SHM protocol)
uint64_t m_entity_id_for_tracing{0};
int32_t m_process_id_for_tracing{0};
long long m_current_clock_for_tracing{0};

struct SEventHandlePair
{
EventHandleT event_snd;
Expand Down
15 changes: 14 additions & 1 deletion ecal/core/src/pubsub/ecal_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "config/builder/writer_attribute_builder.h"
#include "ecal_config_internal.h"
#include "tracing/tracing.h"

#include <iostream>
#include <memory>
Expand Down Expand Up @@ -99,9 +100,21 @@ namespace eCAL
}

bool CPublisher::Send(CPayloadWriter& payload_, long long time_)
{
{
auto publisher_impl = m_publisher_impl.lock();
if (!publisher_impl) return false;

Registration::Sample sample;
publisher_impl->GetRegistration(sample);
Comment thread
IlaHadiAssar marked this conversation as resolved.
Outdated

eCAL::tracing::CSendSpan send_span(
publisher_impl->GetTopicId(),
sample.topic.data_clock,
eCAL::eTLayerType::tl_all,
payload_.GetSize(),
eCAL::tracing::operation_type::send
);

// in an optimization case the
// publisher can send an empty package
// or we do not have any subscription at all
Expand Down
17 changes: 17 additions & 0 deletions ecal/core/src/pubsub/ecal_publisher_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

#include "registration/ecal_registration_provider.h"
#include "logging/ecal_log_provider.h"
#include "tracing/tracing.h"

#include <algorithm>
#include <chrono>
Expand Down Expand Up @@ -124,6 +125,19 @@ namespace eCAL
m_topic_id.topic_id.host_name = m_attributes.host_name;
m_topic_id.topic_id.process_id = m_attributes.process_id;

// record topic metadata for tracing
{
eCAL::tracing::STopicMetadata meta;
meta.entity_id = m_publisher_id;
meta.process_id = m_attributes.process_id;
meta.host_name = m_attributes.host_name;
meta.topic_name = m_attributes.topic_name;
meta.encoding = m_topic_info.encoding;
meta.type_name = m_topic_info.name;
meta.direction = eCAL::tracing::topic_direction::publisher;
eCAL::tracing::CTraceProvider::getInstance().addTopicMetadata(meta);
}

// mark as created
m_created = true;
}
Expand Down Expand Up @@ -758,6 +772,9 @@ namespace eCAL
// create writer
m_writer_shm = std::make_unique<CDataWriterSHM>(eCAL::eCALWriter::BuildSHMAttributes(m_attributes), g_memfile_map());

// set tracing info for handshake tracing (does not modify SHM protocol)
m_writer_shm->SetTracingInfo(m_publisher_id, m_attributes.process_id);

// register activated layer
Register();

Expand Down
1 change: 1 addition & 0 deletions ecal/core/src/pubsub/ecal_publisher_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ namespace eCAL

void GetRegistrationSample(Registration::Sample& sample);
void GetUnregistrationSample(Registration::Sample& sample);
long long GetClock() const { return m_clock; }

bool StartUdpLayer();
bool StartShmLayer();
Expand Down
35 changes: 34 additions & 1 deletion ecal/core/src/pubsub/ecal_subscriber_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
**/

#include "ecal_subscriber_impl.h"
#include "tracing/tracing.h"
#include <ecal/config.h>
#include <ecal/log.h>
#include <ecal/process.h>
Expand Down Expand Up @@ -95,6 +96,19 @@ namespace eCAL
m_topic_id.topic_id.host_name = m_attributes.host_name;
m_topic_id.topic_id.process_id = m_attributes.process_id;

// record topic metadata for tracing
{
eCAL::tracing::STopicMetadata meta;
meta.entity_id = m_subscriber_id;
meta.process_id = m_attributes.process_id;
meta.host_name = m_attributes.host_name;
meta.topic_name = m_attributes.topic_name;
meta.encoding = m_topic_info.encoding;
meta.type_name = m_topic_info.name;
meta.direction = eCAL::tracing::topic_direction::subscriber;
eCAL::tracing::CTraceProvider::getInstance().addTopicMetadata(meta);
}

// start transport layers
InitializeLayers();
StartTransportLayer();
Expand Down Expand Up @@ -375,6 +389,15 @@ namespace eCAL

size_t CSubscriberImpl::ApplySample(const Payload::TopicInfo& topic_info_, const char* payload_, size_t size_, long long id_, long long clock_, long long time_, size_t /*hash_*/, eTLayerType layer_)
{

eCAL::tracing::CReceiveSpan receive_span(
m_subscriber_id,
topic_info_,
clock_,
layer_,
eCAL::tracing::operation_type::receive
);

// ensure thread safety
const std::lock_guard<std::mutex> lock(m_receive_callback_mutex);
if (!m_created) return(0);
Expand Down Expand Up @@ -452,7 +475,17 @@ namespace eCAL

// execute it
const std::lock_guard<std::mutex> exec_lock(m_connection_map_mtx);
(m_receive_callback)(topic_id, m_connection_map[pub_info].data_type_info, cb_data);
{
eCAL::tracing::CReceiveSpan receive_span(
m_subscriber_id,
topic_info_,
clock_,
layer_,
eCAL::tracing::operation_type::callback_execution
);


(m_receive_callback)(topic_id, m_connection_map[pub_info].data_type_info, cb_data); }
processed = true;
}
}
Expand Down
18 changes: 18 additions & 0 deletions ecal/core/src/readwrite/shm/ecal_writer_shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ namespace eCAL
}
}

void CDataWriterSHM::SetTracingInfo(uint64_t entity_id_, int32_t process_id_)
{
for (auto& memory_file : m_memory_file_vec)
{
memory_file->SetTracingInfo(entity_id_, process_id_);
}
}

Registration::LayerParShm CDataWriterSHM::GetConnectionParameter()
{
Registration::LayerParShm layer_par_shm;
Expand Down Expand Up @@ -207,6 +215,16 @@ namespace eCAL
return false;
}
}
// Propagate tracing info to newly created memory files if it has been set
if (m_tracing_entity_id != 0)
{
SetTracingInfo(m_tracing_entity_id, m_tracing_process_id);
}
// Propagate tracing info to newly created memory files if it has been set
if (m_tracing_entity_id != 0)
{
SetTracingInfo(m_tracing_entity_id, m_tracing_process_id);
}

return true;
}
Expand Down
6 changes: 6 additions & 0 deletions ecal/core/src/readwrite/shm/ecal_writer_shm.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace eCAL
void ApplySubscription(const std::string& host_name_, int32_t process_id_, const EntityIdT& topic_id_, const std::string& conn_par_) override;
void RemoveSubscription(const std::string& host_name_, int32_t process_id_, const EntityIdT& topic_id_) override;

void SetTracingInfo(uint64_t entity_id_, int32_t process_id_);

Registration::LayerParShm GetConnectionParameter() override;

protected:
Expand All @@ -69,5 +71,9 @@ namespace eCAL
ProcessIDTopicIDSetT m_process_id_topic_id_set_map;

std::shared_ptr<CMemFileMap> m_memfile_map;

// Store tracing info to propagate to memory files
uint64_t m_tracing_entity_id{0};
int32_t m_tracing_process_id{0};
};
}
Loading