-
Notifications
You must be signed in to change notification settings - Fork 2
Topic/otel #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Topic/otel #177
Changes from all commits
7961b0b
ef33ba4
9f9574d
5a918df
2b0423d
61e58e2
10feeeb
2b0d2a6
7188b52
50e8c90
612e9ae
b01e292
040a413
3050fa5
4fb41d8
9f80dd1
d3354d5
4a6d862
3c45a9e
7e1371b
8e341e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,145 @@ | ||||||||||||||||||||||||||||||||||||||||
| cmake_minimum_required(VERSION 3.10) | ||||||||||||||||||||||||||||||||||||||||
| project(rrd_otel_cpp_wrapper VERSION 1.0.0 LANGUAGES CXX) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Include GNUInstallDirs to define CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_INCLUDEDIR, etc. | ||||||||||||||||||||||||||||||||||||||||
| include(GNUInstallDirs) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Set C++ standard | ||||||||||||||||||||||||||||||||||||||||
| set(CMAKE_CXX_STANDARD 17) | ||||||||||||||||||||||||||||||||||||||||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Find OpenTelemetry-CPP | ||||||||||||||||||||||||||||||||||||||||
| find_package(opentelemetry-cpp CONFIG QUIET) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Track which method found the package | ||||||||||||||||||||||||||||||||||||||||
| set(FOUND_BY_CMAKE FALSE) | ||||||||||||||||||||||||||||||||||||||||
| set(FOUND_BY_PKGCONFIG FALSE) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if(opentelemetry-cpp_FOUND) | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "OpenTelemetry-CPP found via CMake config") | ||||||||||||||||||||||||||||||||||||||||
| set(FOUND_BY_CMAKE TRUE) | ||||||||||||||||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||||||||||||||||
| # Fall back to pkg-config (common in Yocto) | ||||||||||||||||||||||||||||||||||||||||
| find_package(PkgConfig QUIET) | ||||||||||||||||||||||||||||||||||||||||
| if(PkgConfig_FOUND) | ||||||||||||||||||||||||||||||||||||||||
| # Try different possible package names | ||||||||||||||||||||||||||||||||||||||||
| pkg_check_modules(OPENTELEMETRY QUIET opentelemetry-cpp) | ||||||||||||||||||||||||||||||||||||||||
| if(NOT OPENTELEMETRY_FOUND) | ||||||||||||||||||||||||||||||||||||||||
| pkg_check_modules(OPENTELEMETRY QUIET opentelemetry) | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| if(NOT OPENTELEMETRY_FOUND) | ||||||||||||||||||||||||||||||||||||||||
| # Try individual components | ||||||||||||||||||||||||||||||||||||||||
| pkg_check_modules(OTEL_TRACE QUIET opentelemetry_trace) | ||||||||||||||||||||||||||||||||||||||||
| pkg_check_modules(OTEL_COMMON QUIET opentelemetry_common) | ||||||||||||||||||||||||||||||||||||||||
| pkg_check_modules(OTEL_RESOURCES QUIET opentelemetry_resources) | ||||||||||||||||||||||||||||||||||||||||
| pkg_check_modules(OTEL_OTLP QUIET opentelemetry_otlp_http_exporter) | ||||||||||||||||||||||||||||||||||||||||
| if(OTEL_TRACE_FOUND AND OTEL_COMMON_FOUND) | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "OpenTelemetry-CPP found via pkg-config (individual components)") | ||||||||||||||||||||||||||||||||||||||||
| set(FOUND_BY_PKGCONFIG TRUE) | ||||||||||||||||||||||||||||||||||||||||
| # Combine all the variables | ||||||||||||||||||||||||||||||||||||||||
| set(OPENTELEMETRY_INCLUDE_DIRS ${OTEL_TRACE_INCLUDE_DIRS} ${OTEL_COMMON_INCLUDE_DIRS} ${OTEL_RESOURCES_INCLUDE_DIRS} ${OTEL_OTLP_INCLUDE_DIRS}) | ||||||||||||||||||||||||||||||||||||||||
| set(OPENTELEMETRY_LIBRARIES ${OTEL_TRACE_LIBRARIES} ${OTEL_COMMON_LIBRARIES} ${OTEL_RESOURCES_LIBRARIES} ${OTEL_OTLP_LIBRARIES}) | ||||||||||||||||||||||||||||||||||||||||
| set(OPENTELEMETRY_LIBRARY_DIRS ${OTEL_TRACE_LIBRARY_DIRS} ${OTEL_COMMON_LIBRARY_DIRS} ${OTEL_RESOURCES_LIBRARY_DIRS} ${OTEL_OTLP_LIBRARY_DIRS}) | ||||||||||||||||||||||||||||||||||||||||
| list(REMOVE_DUPLICATES OPENTELEMETRY_INCLUDE_DIRS) | ||||||||||||||||||||||||||||||||||||||||
| list(REMOVE_DUPLICATES OPENTELEMETRY_LIBRARY_DIRS) | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "OpenTelemetry-CPP found via pkg-config") | ||||||||||||||||||||||||||||||||||||||||
| set(FOUND_BY_PKGCONFIG TRUE) | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if(NOT FOUND_BY_CMAKE AND NOT FOUND_BY_PKGCONFIG) | ||||||||||||||||||||||||||||||||||||||||
| message(WARNING "OpenTelemetry-CPP not found via CMake or pkg-config") | ||||||||||||||||||||||||||||||||||||||||
| message(WARNING "Attempting to use direct library linking...") | ||||||||||||||||||||||||||||||||||||||||
| # Last resort: try to find libraries directly | ||||||||||||||||||||||||||||||||||||||||
| find_library(OTEL_TRACE_LIB opentelemetry_trace) | ||||||||||||||||||||||||||||||||||||||||
| find_library(OTEL_COMMON_LIB opentelemetry_common) | ||||||||||||||||||||||||||||||||||||||||
| if(OTEL_TRACE_LIB AND OTEL_COMMON_LIB) | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "OpenTelemetry libraries found directly") | ||||||||||||||||||||||||||||||||||||||||
| set(FOUND_BY_PKGCONFIG TRUE) | ||||||||||||||||||||||||||||||||||||||||
| set(OPENTELEMETRY_LIBRARIES | ||||||||||||||||||||||||||||||||||||||||
| ${OTEL_TRACE_LIB} | ||||||||||||||||||||||||||||||||||||||||
| ${OTEL_COMMON_LIB} | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| # Try to find additional libraries | ||||||||||||||||||||||||||||||||||||||||
| find_library(OTEL_RESOURCES_LIB opentelemetry_resources) | ||||||||||||||||||||||||||||||||||||||||
| find_library(OTEL_OTLP_LIB opentelemetry_otlp_http_exporter) | ||||||||||||||||||||||||||||||||||||||||
| if(OTEL_RESOURCES_LIB) | ||||||||||||||||||||||||||||||||||||||||
| list(APPEND OPENTELEMETRY_LIBRARIES ${OTEL_RESOURCES_LIB}) | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| if(OTEL_OTLP_LIB) | ||||||||||||||||||||||||||||||||||||||||
| list(APPEND OPENTELEMETRY_LIBRARIES ${OTEL_OTLP_LIB}) | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||||||||||||||||
| message(FATAL_ERROR "OpenTelemetry-CPP not found. Please install opentelemetry-cpp package.") | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| message(STATUS "OpenTelemetry-CPP found - building C++ wrapper for remote_debugger") | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||||||||||
| # OpenTelemetry C++ Wrapper Library | ||||||||||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||||||||||
| add_library(rrd_otel_cpp_wrapper STATIC | ||||||||||||||||||||||||||||||||||||||||
| src/rrdOpenTelemetry_cpp_wrapper.cpp | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| target_compile_features(rrd_otel_cpp_wrapper PRIVATE cxx_std_17) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Link OpenTelemetry libraries based on how they were found | ||||||||||||||||||||||||||||||||||||||||
| if(FOUND_BY_CMAKE) | ||||||||||||||||||||||||||||||||||||||||
| # Use CMake targets | ||||||||||||||||||||||||||||||||||||||||
| target_link_libraries(rrd_otel_cpp_wrapper PUBLIC | ||||||||||||||||||||||||||||||||||||||||
| opentelemetry-cpp::trace | ||||||||||||||||||||||||||||||||||||||||
| opentelemetry-cpp::common | ||||||||||||||||||||||||||||||||||||||||
| opentelemetry-cpp::ostream_span_exporter | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+89
to
+97
|
||||||||||||||||||||||||||||||||||||||||
| opentelemetry-cpp::otlp_http_exporter | ||||||||||||||||||||||||||||||||||||||||
| opentelemetry-cpp::resources | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||||||||||||||||
| # Use pkg-config variables | ||||||||||||||||||||||||||||||||||||||||
| target_include_directories(rrd_otel_cpp_wrapper PUBLIC ${OPENTELEMETRY_INCLUDE_DIRS}) | ||||||||||||||||||||||||||||||||||||||||
| target_link_libraries(rrd_otel_cpp_wrapper PUBLIC ${OPENTELEMETRY_LIBRARIES}) | ||||||||||||||||||||||||||||||||||||||||
| target_link_directories(rrd_otel_cpp_wrapper PUBLIC ${OPENTELEMETRY_LIBRARY_DIRS}) | ||||||||||||||||||||||||||||||||||||||||
| if(OPENTELEMETRY_CFLAGS_OTHER) | ||||||||||||||||||||||||||||||||||||||||
| target_compile_options(rrd_otel_cpp_wrapper PUBLIC ${OPENTELEMETRY_CFLAGS_OTHER}) | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| target_include_directories(rrd_otel_cpp_wrapper PUBLIC | ||||||||||||||||||||||||||||||||||||||||
| ${CMAKE_CURRENT_SOURCE_DIR}/src | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Optimize for size | ||||||||||||||||||||||||||||||||||||||||
| if(NOT MSVC) | ||||||||||||||||||||||||||||||||||||||||
| target_compile_options(rrd_otel_cpp_wrapper PRIVATE | ||||||||||||||||||||||||||||||||||||||||
| -fno-rtti | ||||||||||||||||||||||||||||||||||||||||
| $<$<CONFIG:Release>:-O3> | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Install library for Makefile to link against | ||||||||||||||||||||||||||||||||||||||||
| install(TARGETS rrd_otel_cpp_wrapper | ||||||||||||||||||||||||||||||||||||||||
| ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||||||||||||||||||||||||||||||||||
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Install header for C code to include | ||||||||||||||||||||||||||||||||||||||||
| install(FILES src/rrdOpenTelemetry_cpp_wrapper.h | ||||||||||||||||||||||||||||||||||||||||
| DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+123
to
+132
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||||||||||
| # Summary | ||||||||||||||||||||||||||||||||||||||||
| # ============================================================================ | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "C++ Wrapper Build Configuration:") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS " C++ Standard: ${CMAKE_CXX_STANDARD}") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS " Build Type: ${CMAKE_BUILD_TYPE}") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS " Install Prefix: ${CMAKE_INSTALL_PREFIX}") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS " Output Library: librrd_otel_cpp_wrapper.a") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "NOTE: Main binary built by existing Makefile") | ||||||||||||||||||||||||||||||||||||||||
| message(STATUS "") | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+144
to
+145
|
||||||||||||||||||||||||||||||||||||||||
| message(STATUS "NOTE: Main binary built by existing Makefile") | |
| message(STATUS "") | |
| message(STATUS "NOTE:") | |
| message(STATUS " The main remotedebugger binary is built by the existing Autotools/Makefile") | |
| message(STATUS " build system. This CMake project only builds and installs the") | |
| message(STATUS " librrd_otel_cpp_wrapper library that remotedebugger expects to link against.") | |
| message(STATUS "") | |
| message(STATUS " To integrate this wrapper into your normal build/install flow, ensure that") | |
| message(STATUS " you run the following (or equivalent) commands in addition to the Autotools") | |
| message(STATUS " build, so that librrd_otel_cpp_wrapper is available at link time:") | |
| message(STATUS "") | |
| message(STATUS " mkdir -p build && cd build") | |
| message(STATUS " cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX}") | |
| message(STATUS " cmake --build .") | |
| message(STATUS " cmake --install .") | |
| message(STATUS "") | |
| message(STATUS " If this step is skipped, remotedebugger may fail to link because") | |
| message(STATUS " librrd_otel_cpp_wrapper cannot be found.") | |
| message(STATUS "") |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,20 +6,27 @@ | |||||
| # limitations under the License. | ||||||
| ########################################################################## | ||||||
|
|
||||||
| bin_PROGRAMS = remotedebugger | ||||||
| bin_PROGRAMS = remotedebugger rrdTestApp | ||||||
|
|
||||||
| remotedebuggerincludedir = $(includedir)/rrd | ||||||
| rrdTestAppincludedir = $(includedir)/rrd | ||||||
|
||||||
| rrdTestAppincludedir = $(includedir)/rrd |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test app target is named "rrdTestApp", but the source file and in-app docs refer to "rrdTraceTestApp". Consider renaming the target to match the documented name (or update the documentation strings) to avoid confusion for users and scripts.
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C++ wrapper implementation file 'rrdOpenTelemetry_cpp_wrapper.cpp' is not included in the remotedebugger_SOURCES list. This file contains the actual OpenTelemetry SDK integration that is called from rrdOpenTelemetry.c. Without compiling and linking this file, the build will fail with undefined references to functions like rrdOtel_Initialize_Cpp, rrdOtel_StartSpan_Cpp, etc. Add 'rrdOpenTelemetry_cpp_wrapper.cpp' to the remotedebugger_SOURCES variable.
| remotedebugger_SOURCES = rrdMain.c rrdEventProcess.c rrdJsonParser.c rrdRunCmdThread.c rrdCommandSanity.c rrdDynamic.c rrdExecuteScript.c rrdMsgPackDecoder.c rrdInterface.c uploadRRDLogs.c rrd_config.c rrd_sysinfo.c rrd_logproc.c rrd_archive.c rrd_upload.c rrdOpenTelemetry.c | |
| remotedebugger_SOURCES = rrdMain.c rrdEventProcess.c rrdJsonParser.c rrdRunCmdThread.c rrdCommandSanity.c rrdDynamic.c rrdExecuteScript.c rrdMsgPackDecoder.c rrdInterface.c uploadRRDLogs.c rrd_config.c rrd_sysinfo.c rrd_logproc.c rrd_archive.c rrd_upload.c rrdOpenTelemetry.c rrdOpenTelemetry_cpp_wrapper.cpp |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rrdTestApp_LDFLAGS references libraries that may not be needed for the test application. The test app only uses RBUS APIs and doesn't appear to need -lwebconfig_framework, -lmsgpackc, -ltrower-base64, -lsecure_wrapper, -lfwutils, -luploadstblogs, or -lz. This could cause unnecessary build dependencies or linking errors if these libraries aren't available. Consider using only the minimal set of libraries needed for the test app, likely just -lrbus and -lrdkloggers.
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rrdTestApp_LDADD variable is not defined, but rrdTestApp_LDFLAGS is. This means rrdTestApp won't link against the libraries specified in remotedebugger_LDADD (like -lfwutils, -luploadstblogs, -lz). The test app should either have its own rrdTestApp_LDADD or should not require these libraries. If RBUS functionality is needed for the test app, ensure it links against all required libraries.
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remotedebugger binary is linked with the OpenTelemetry C++ wrapper library and dependencies, but rrdOpenTelemetry_cpp_wrapper.cpp is not listed in remotedebugger_SOURCES. The wrapper library needs to be built separately (presumably by CMake as indicated in CMakeLists.txt) and then linked. However, there's no clear indication in this Makefile that the C++ wrapper library will be built first or is available. Consider adding a dependency or build rule to ensure the C++ wrapper is built before linking.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,10 @@ typedef struct mbuffer { | |
| bool inDynamic; | ||
| bool appendMode; | ||
| deepsleep_event_et dsEvent; | ||
| /* OpenTelemetry trace context for distributed tracing */ | ||
| char *traceParent; | ||
| char *traceState; | ||
| uint64_t spanHandle; | ||
| } data_buf; | ||
|
Comment on lines
+100
to
104
|
||
|
|
||
| /*Structure for Message Header*/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "rrdInterface.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "rrdRunCmdThread.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "rrdRunCmdThread.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "rrdOpenTelemetry.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+22
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "rrdRunCmdThread.h" | |
| #include "rrdOpenTelemetry.h" | |
| #include "rrdRunCmdThread.h" | |
| #if !defined(GTEST_ENABLE) | |
| #include "rrdOpenTelemetry.h" | |
| #endif |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for OpenTelemetry functions. If rrdOtel_GenerateContext, rrdOtel_SetContext, or rbusHandle_SetTraceContextFromString fail, the code continues without checking return values. While trace context failures may not be critical to the main functionality, ignoring these errors could lead to silent trace loss and make debugging difficult. Consider logging errors when these operations fail.
| rrdOtel_GenerateContext(&ctx); | |
| rrdOtel_SetContext(&ctx); | |
| rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| int otelStatus = rrdOtel_GenerateContext(&ctx); | |
| if (otelStatus != 0) | |
| { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: rrdOtel_GenerateContext failed with status %d\n", __FUNCTION__, __LINE__, otelStatus); | |
| } | |
| otelStatus = rrdOtel_SetContext(&ctx); | |
| if (otelStatus != 0) | |
| { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: rrdOtel_SetContext failed with status %d\n", __FUNCTION__, __LINE__, otelStatus); | |
| } | |
| rbusError_t traceRc = rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| if (traceRc != RBUS_ERROR_SUCCESS) | |
| { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: rbusHandle_SetTraceContextFromString failed with error [%d]\n", __FUNCTION__, __LINE__, traceRc); | |
| } |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return values from rrdOtel_GenerateContext, rrdOtel_SetContext, and rbusHandle_SetTraceContextFromString are ignored. If any of these fail, the code proceeds and logs events as if tracing is set up, which can lead to confusing/incorrect telemetry. Check and handle these return codes (and avoid leaving a partially-initialized context active).
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value from rrdOtel_GenerateContext and rrdOtel_SetContext is not checked. If these calls fail (e.g., return non-zero), the code continues to call rbusHandle_SetTraceContextFromString with potentially uninitialized ctx values. Add error checking and handle failures appropriately.
| rbusValue_Init(&value); | |
| rbusValue_SetString(value,"root"); | |
| /* Generate and set trace context before RBUS operation */ | |
| rrd_otel_context_t ctx; | |
| rrdOtel_GenerateContext(&ctx); | |
| rrdOtel_SetContext(&ctx); | |
| rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| rbusValue_Init(&value); | |
| rbusValue_SetString(value,"root"); | |
| /* Generate and set trace context before RBUS operation */ | |
| rrd_otel_context_t ctx; | |
| int otelRet = rrdOtel_GenerateContext(&ctx); | |
| if (otelRet != 0) | |
| { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: rrdOtel_GenerateContext failed (ret=%d), proceeding without trace context\n", __FUNCTION__, __LINE__, otelRet); | |
| } | |
| else | |
| { | |
| otelRet = rrdOtel_SetContext(&ctx); | |
| if (otelRet != 0) | |
| { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: rrdOtel_SetContext failed (ret=%d), proceeding without trace context\n", __FUNCTION__, __LINE__, otelRet); | |
| } | |
| else | |
| { | |
| rbusError_t traceRc = rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| if (traceRc != RBUS_ERROR_SUCCESS) | |
| { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: rbusHandle_SetTraceContextFromString failed with error [%d], proceeding without trace context\n", __FUNCTION__, __LINE__, traceRc); | |
| } | |
| } | |
| } |
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as in rrdInterface.c: rrdOtel_LogEvent is called when no span is active. A trace context is generated and set (lines 162-165), but no span is created before calling rrdOtel_LogEvent at line 170. According to the rrdOtel_LogEvent implementation, it requires an active span to log events to, so this call will fail. A span should be created before calling LogEvent.
| rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| rc = rbus_set(rrdRbusHandle, RRD_WEBCFG_FORCE_SYNC, value, NULL); | |
| /* Log the operation in trace */ | |
| rrdOtel_LogEvent("rbus_set", RRD_WEBCFG_FORCE_SYNC); | |
| rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| /* Start a span for the RBUS operation so that events are recorded correctly */ | |
| rrdOtel_StartSpan("rbus_set"); | |
| rc = rbus_set(rrdRbusHandle, RRD_WEBCFG_FORCE_SYNC, value, NULL); | |
| /* Log the operation in trace */ | |
| rrdOtel_LogEvent("rbus_set", RRD_WEBCFG_FORCE_SYNC); | |
| /* End the span after logging the operation */ | |
| rrdOtel_EndSpan(); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These calls ignore return codes (rrdOtel_GenerateContext/SetContext and rbusHandle_SetTraceContextFromString) and then call rrdOtel_LogEvent without ever starting a span (LogEvent currently no-ops when no span is active). Either create a span around this RBUS operation and handle failures, or skip logging when tracing isn't available.
| /* Generate and set trace context before RBUS operation */ | |
| rrd_otel_context_t ctx; | |
| rrdOtel_GenerateContext(&ctx); | |
| rrdOtel_SetContext(&ctx); | |
| rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| rc = rbus_set(rrdRbusHandle, RRD_WEBCFG_FORCE_SYNC, value, NULL); | |
| /* Log the operation in trace */ | |
| rrdOtel_LogEvent("rbus_set", RRD_WEBCFG_FORCE_SYNC); | |
| /* Clear trace context after operation */ | |
| rbusHandle_ClearTraceContext(rrdRbusHandle); | |
| /* Generate and set trace context before RBUS operation */ | |
| rrd_otel_context_t ctx; | |
| int otelGenRc = rrdOtel_GenerateContext(&ctx); | |
| int otelSetRc = 0; | |
| rbusError_t rbusTraceRc = RBUS_ERROR_BUS_ERROR; | |
| int tracingEnabled = 0; | |
| if (otelGenRc == 0) | |
| { | |
| otelSetRc = rrdOtel_SetContext(&ctx); | |
| if (otelSetRc == 0) | |
| { | |
| rbusTraceRc = rbusHandle_SetTraceContextFromString(rrdRbusHandle, ctx.traceParent, ctx.traceState); | |
| if (rbusTraceRc == RBUS_ERROR_SUCCESS) | |
| { | |
| tracingEnabled = 1; | |
| } | |
| } | |
| } | |
| rc = rbus_set(rrdRbusHandle, RRD_WEBCFG_FORCE_SYNC, value, NULL); | |
| /* Log the operation in trace, if tracing is available */ | |
| if (tracingEnabled) | |
| { | |
| rrdOtel_LogEvent("rbus_set", RRD_WEBCFG_FORCE_SYNC); | |
| /* Clear trace context after operation */ | |
| rbusHandle_ClearTraceContext(rrdRbusHandle); | |
| } |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak: The rbusValue_t initialized with rbusValue_Init is never released. After the rbus_set call and before the function returns, rbusValue_Release(value) should be called to free the allocated resources.
| rbusHandle_ClearTraceContext(rrdRbusHandle); | |
| rbusHandle_ClearTraceContext(rrdRbusHandle); | |
| rbusValue_Release(value); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected. Multiple lines (160-161, 165-166, 169, 173-174) use tabs instead of spaces. The codebase appears to use spaces for indentation (4 spaces per level based on surrounding code). Replace tabs with spaces to maintain consistent formatting throughout the file.
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation: Tab characters are mixed with spaces on lines 160, 161, 165, 169, 173. This violates the consistent spacing pattern used throughout the rest of the file.
Convert tabs to spaces to match the existing code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library is built as STATIC but this may cause issues if multiple binaries in the same process try to use it, as each will have its own copy of the global state (g_wrapper, etc.). If this wrapper is only used by the remotedebugger binary this is fine, but if shared across multiple binaries, consider building as SHARED instead to ensure a single instance of the global state.