Skip to content

Commit

Permalink
docs(core): move logger, metrics and tracing samples to telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
roby2014 committed Aug 21, 2024
1 parent 1bb71a1 commit 12c998c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 5 deletions.
5 changes: 3 additions & 2 deletions core/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Logging {#examples-core-logging}
# Logging {#examples-core-tel-logging}

@brief Using the logging system.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Metrics {#examples-core-metrics}
# Metrics {#examples-core-tel-metrics}

@brief Using the metrics system.

Expand Down
7 changes: 7 additions & 0 deletions core/samples/tel/page.md
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions core/samples/tel/tracing/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// [Logging and tracing include]
#include <cubos/core/tel/logging.hpp>
#include <cubos/core/tel/tracing.hpp>

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]
}
2 changes: 1 addition & 1 deletion docs/pages/3_examples/1_core/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 12c998c

Please sign in to comment.