diff --git a/core/samples/CMakeLists.txt b/core/samples/CMakeLists.txt index 2f986420e..c19f4fee7 100644 --- a/core/samples/CMakeLists.txt +++ b/core/samples/CMakeLists.txt @@ -26,8 +26,9 @@ macro(make_sample) cubos_common_target_options(${target}) endmacro() -make_sample(DIR "logging") -make_sample(DIR "metrics") +make_sample(DIR "tel/logging") +make_sample(DIR "tel/metrics") +make_sample(DIR "tel/tracing") make_sample(DIR "reflection/basic") make_sample(DIR "reflection/traits/constructible") make_sample(DIR "reflection/traits/fields") diff --git a/core/samples/logging/main.cpp b/core/samples/tel/logging/main.cpp similarity index 100% rename from core/samples/logging/main.cpp rename to core/samples/tel/logging/main.cpp diff --git a/core/samples/logging/page.md b/core/samples/tel/logging/page.md similarity index 99% rename from core/samples/logging/page.md rename to core/samples/tel/logging/page.md index 49bc6701b..8dd684d42 100644 --- a/core/samples/logging/page.md +++ b/core/samples/tel/logging/page.md @@ -1,4 +1,4 @@ -# Logging {#examples-core-logging} +# Logging {#examples-core-tel-logging} @brief Using the logging system. diff --git a/core/samples/metrics/main.cpp b/core/samples/tel/metrics/main.cpp similarity index 100% rename from core/samples/metrics/main.cpp rename to core/samples/tel/metrics/main.cpp diff --git a/core/samples/metrics/page.md b/core/samples/tel/metrics/page.md similarity index 98% rename from core/samples/metrics/page.md rename to core/samples/tel/metrics/page.md index ad88faa61..013252088 100644 --- a/core/samples/metrics/page.md +++ b/core/samples/tel/metrics/page.md @@ -1,4 +1,4 @@ -# Metrics {#examples-core-metrics} +# Metrics {#examples-core-tel-metrics} @brief Using the metrics system. diff --git a/core/samples/tel/page.md b/core/samples/tel/page.md new file mode 100644 index 000000000..59ab091d4 --- /dev/null +++ b/core/samples/tel/page.md @@ -0,0 +1,7 @@ +# Telemetry {#examples-core-tel} + +@brief Using the @ref core-tel module. + +- @subpage examples-core-tel-logging - @copybrief examples-core-tel-logging +- @subpage examples-core-tel-metrics - @copybrief examples-core-tel-metrics +- @subpage examples-core-tel-tracing - @copybrief examples-core-tel-tracing diff --git a/core/samples/tel/tracing/main.cpp b/core/samples/tel/tracing/main.cpp new file mode 100644 index 000000000..9d842c85a --- /dev/null +++ b/core/samples/tel/tracing/main.cpp @@ -0,0 +1,32 @@ +/// [Logging and tracing include] +#include +#include + +using cubos::core::tel::SpanManager; +/// [Logging and tracing include] + +int main() +{ + cubos::core::tel::Logger::level(cubos::core::tel::Logger::Level::Trace); + + /// [Using macros] + CUBOS_SPAN_INFO("main_span"); + // With this macro, a new RAII guard is created. When dropped, exits the span. + // This indicates that we are in the span for the current lexical scope. + // Logs and metrics from here will be associated with 'main' span. + CUBOS_INFO("hello!"); + + CUBOS_SPAN_TRACE("other_scope"); + CUBOS_INFO("hello again!"); + // ... + /// [Using macros] + + /// [Manually] + SpanManager::Span span("manual_span", CUBOS_SPAN_LEVEL_DEBUG, __FILE__, __LINE__); + SpanManager::enter(&span); + CUBOS_INFO("entered a manual span"); + + SpanManager::exit(); + CUBOS_INFO("after exit manual span"); + /// [Manually] +} diff --git a/docs/pages/3_examples/1_core/main.md b/docs/pages/3_examples/1_core/main.md index 469ea0ecf..ce379950d 100644 --- a/docs/pages/3_examples/1_core/main.md +++ b/docs/pages/3_examples/1_core/main.md @@ -8,7 +8,7 @@ will need to use some of the features of the @ref core library directly. The following examples have fully documented tutorials: -- @subpage examples-core-logging - @copybrief examples-core-logging +- @subpage examples-core-tel - @copybrief examples-core-tel - @subpage examples-core-reflection - @copybrief examples-core-reflection - @subpage examples-core-data - @copybrief examples-core-data - @subpage examples-core-networking - @copybrief examples-core-networking