Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion rfcMgr/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rfcMgr_SOURCES = rfc_main.cpp rfc_manager.cpp rfc_common.cpp mtlsUtils.cpp rfc_x
rfcMgr_CPPFLAGS = -std=c++17 -Wall -Werror -DRDK_LOGGER -I${top_srcdir}/rfcMgr -I${top_srcdir}/rfcapi/ $(cjson_CFLAGS) $(curl_CFLAGS) $(CFLAGS)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rfcMgr includes the "rdk_otlp_instrumentation.h" header file at line 22 and calls rdk_otlp_init and rdk_otlp_metrics_init, but the Makefile doesn't include the path to find this header. The include path should be added to rfcMgr_CPPFLAGS, similar to what was done in rfcapi/Makefile.am and utils/Makefile.am. Without this, the build will fail with a "header not found" error.

Suggested change
rfcMgr_CPPFLAGS = -std=c++17 -Wall -Werror -DRDK_LOGGER -I${top_srcdir}/rfcMgr -I${top_srcdir}/rfcapi/ $(cjson_CFLAGS) $(curl_CFLAGS) $(CFLAGS)
rfcMgr_CPPFLAGS = -std=c++17 -Wall -Werror -DRDK_LOGGER -I${top_srcdir}/rfcMgr -I${top_srcdir}/rfcapi/ -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/otlp $(cjson_CFLAGS) $(curl_CFLAGS) $(CFLAGS)

Copilot uses AI. Check for mistakes.
AM_LDFLAGS = -L$(PKG_CONFIG_SYSROOT_DIR)/$(libdir)
AM_LDFLAGS += $(cjson_LIBS) $(curl_LIBS)
AM_LDFLAGS += -lrdkloggers -ldwnlutil -lfwutils -lparsejson -lsecure_wrapper -lcurl
AM_LDFLAGS += -lrdkloggers -ldwnlutil -lfwutils -lparsejson -lsecure_wrapper -lcurl -lrdk_otlp

if IS_IARMBUS_ENABLED
rfcMgr_CPPFLAGS += $(IARMBUS_EVENT_FLAG) -I$(PKG_CONFIG_SYSROOT_DIR)${includedir}/rdk/iarmbus
Expand Down
5 changes: 5 additions & 0 deletions rfcMgr/rfc_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "rfc_common.h"
#include "rfc_manager.h"
#include "rdk_otlp_instrumentation.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -87,6 +88,10 @@ int main()

signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);

// Initialize OpenTelemetry instrumentation
rdk_otlp_init("rfcMgr", "1.0.0");
rdk_otlp_metrics_init();

rfc::RFCManager* rfcMgr = new rfc::RFCManager();

Expand Down
4 changes: 2 additions & 2 deletions rfcapi/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if ENABLE_RDKC
librfcapi_la_CPPFLAGS = "-std=c++11" -DLINUX -fPIC -g -O2 -Wall -DRDKC -I${top_srcdir}/../rdklogger/include/
librfcapi_la_LIBADD = -L${top_srcdir}/../rdklogger/src/.libs -lrdkloggers
else
librfcapi_la_CPPFLAGS = "-std=c++11" -DLINUX -fPIC -g -O2 -Wall -I=/usr/include/cjson -I=/usr/include/wdmp-c $(IARMBUS_EVENT_FLAG)
librfcapi_la_LIBADD = -lcurl -lcjson -lrdkloggers
librfcapi_la_CPPFLAGS = "-std=c++11" -DLINUX -fPIC -g -O2 -Wall -I=/usr/include/cjson -I=/usr/include/wdmp-c $(IARMBUS_EVENT_FLAG) -I/mnt/L2_CONTAINER_SHARED_VOLUME/dtracing/rdk_otel_instrumentation/include
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute path "/mnt/L2_CONTAINER_SHARED_VOLUME/dtracing/rdk_otel_instrumentation/include" makes the build non-portable and environment-specific. Consider using a configurable variable or pkg-config to locate the OpenTelemetry instrumentation headers, similar to how other dependencies are handled (e.g., cjson_CFLAGS, curl_CFLAGS).

Suggested change
librfcapi_la_CPPFLAGS = "-std=c++11" -DLINUX -fPIC -g -O2 -Wall -I=/usr/include/cjson -I=/usr/include/wdmp-c $(IARMBUS_EVENT_FLAG) -I/mnt/L2_CONTAINER_SHARED_VOLUME/dtracing/rdk_otel_instrumentation/include
librfcapi_la_CPPFLAGS = "-std=c++11" -DLINUX -fPIC -g -O2 -Wall -I=/usr/include/cjson -I=/usr/include/wdmp-c $(IARMBUS_EVENT_FLAG) $(OTEL_INSTRUMENTATION_CFLAGS)

Copilot uses AI. Check for mistakes.
librfcapi_la_LIBADD = -lcurl -lcjson -lrdkloggers -lrdk_otlp
endif
endif
16 changes: 15 additions & 1 deletion rfcapi/rfcapi.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in rfcapi/rfcapi.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'rfcapi/rfcapi.cpp' (Match: rdk/components/generic/rfc/rdk/components/generic/rfc/1, 702 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/rfc/+archive/RDKB-TEST-RELEASE-1.tar.gz, file: rfcapi/rfcapi.cpp)

Check failure on line 3 in rfcapi/rfcapi.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'rfcapi/rfcapi.cpp' (Match: rdk/components/generic/rfc/rdk/components/generic/rfc/2101, 702 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/rfc/+archive/rdk-dev-2101.tar.gz, file: rfcapi/rfcapi.cpp)
*
* Copyright 2016 RDK Management
*
Expand Down Expand Up @@ -29,6 +29,9 @@
#include <dirent.h>
#include "rfcapi.h"
#include "rdk_debug.h"
#include "rdk_otlp_instrumentation.h"
#include <chrono>
#include <iostream>
using namespace std;

#define LOG_RFCAPI "LOG.RDK.RFCAPI"
Expand Down Expand Up @@ -266,6 +269,7 @@
CURL *curl_handle = NULL;
CURLcode res = CURLE_FAILED_INIT;

//auto startTime = std::chrono::high_resolution_clock::now();
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timing measurement started here will not result in metrics being recorded if the function returns early at lines 279, 294, 300, 305, or 308 (validation failures or fallback to file-based retrieval). This creates incomplete telemetry data where these execution paths won't be tracked. Consider restructuring the code to ensure metrics are recorded for all execution paths, including error cases and fallback scenarios.

Copilot uses AI. Check for mistakes.
if(!strcmp(pcParameterName+strlen(pcParameterName)-1,"."))
{
#ifdef TEMP_LOGGING
Expand Down Expand Up @@ -449,6 +453,11 @@
cJSON_Delete(response_json);
}
}
//auto endTime = std::chrono::high_resolution_clock::now();
//auto timeTaken = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();
// Record metrics (convert microseconds to seconds)
//double duration_seconds = timeTaken / 1000000.0;
//rdk_otlp_metrics_record_parameter_operation(pcParameterName, "get", duration_seconds);
return ret;
}

Expand All @@ -462,7 +471,7 @@
string response;
CURL *curl_handle = NULL;
CURLcode res = CURLE_FAILED_INIT;

//auto startTime = std::chrono::high_resolution_clock::now();
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timing measurement started here will not result in metrics being recorded if the function returns early at line 481 (wildcard/NULL parameter validation failure). This creates incomplete telemetry data where failed operations won't be tracked. Consider restructuring the code to ensure metrics are recorded for all execution paths, including error cases.

Copilot uses AI. Check for mistakes.
if(!strcmp(pcParameterName+strlen(pcParameterName)-1,".") && pcParameterValue == NULL)
{
#ifdef TEMP_LOGGING
Expand Down Expand Up @@ -564,6 +573,11 @@
cJSON_Delete(response_json);
}
}
//auto endTime = std::chrono::high_resolution_clock::now();
//auto timeTaken = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();
// Record metrics (convert microseconds to seconds)
//double duration_seconds = timeTaken / 1000000.0;
//rdk_otlp_metrics_record_parameter_operation(pcParameterName, "get", duration_seconds);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The operation type should be "set" not "get" for the setRFCParameter function. This will cause incorrect metrics to be recorded, making it impossible to distinguish between get and set operations in the telemetry data.

Suggested change
//rdk_otlp_metrics_record_parameter_operation(pcParameterName, "get", duration_seconds);
//rdk_otlp_metrics_record_parameter_operation(pcParameterName, "set", duration_seconds);

Copilot uses AI. Check for mistakes.
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ bin_PROGRAMS += rfctool
endif

tr181_SOURCES = tr181utils.cpp trsetutils.cpp
tr181_LDADD = ../rfcapi/.libs/librfcapi.la ../tr181api/.libs/libtr181api.la
tr181_CPPFLAGS = -std=c++0x -Wall -I${top_srcdir}/rfcapi/ -I${top_srcdir}/tr181api/ -I=/usr/include/wdmp-c
tr181_LDADD = ../rfcapi/.libs/librfcapi.la ../tr181api/.libs/libtr181api.la -lrdk_otlp
tr181_CPPFLAGS = -std=c++0x -Wall -I${top_srcdir}/rfcapi/ -I${top_srcdir}/tr181api/ -I=/usr/include/wdmp-c -I/mnt/L2_CONTAINER_SHARED_VOLUME/dtracing/rdk_otel_instrumentation/include
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute path "/mnt/L2_CONTAINER_SHARED_VOLUME/dtracing/rdk_otel_instrumentation/include" makes the build non-portable and environment-specific. Consider using a configurable variable or pkg-config to locate the OpenTelemetry instrumentation headers, similar to how other dependencies are handled.

Suggested change
tr181_CPPFLAGS = -std=c++0x -Wall -I${top_srcdir}/rfcapi/ -I${top_srcdir}/tr181api/ -I=/usr/include/wdmp-c -I/mnt/L2_CONTAINER_SHARED_VOLUME/dtracing/rdk_otel_instrumentation/include
RDK_OTEL_INSTRUMENTATION_CFLAGS ?= -I/mnt/L2_CONTAINER_SHARED_VOLUME/dtracing/rdk_otel_instrumentation/include
tr181_CPPFLAGS = -std=c++0x -Wall -I${top_srcdir}/rfcapi/ -I${top_srcdir}/tr181api/ -I=/usr/include/wdmp-c $(RDK_OTEL_INSTRUMENTATION_CFLAGS)

Copilot uses AI. Check for mistakes.

if IS_IARMBUS_ENABLED
tr181_LDADD += -lIARMBus
Expand Down
17 changes: 15 additions & 2 deletions utils/tr181utils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in utils/tr181utils.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'utils/tr181utils.cpp' (Match: rdk/components/generic/rfc/rdk/components/generic/rfc/1, 345 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/rfc/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: utils/tr181utils.cpp)
*
* Copyright 2018 RDK Management
*
Expand Down Expand Up @@ -40,7 +40,7 @@
#include "trsetutils.h"
#include <fcntl.h>
#include <unistd.h>

#include "rdk_otlp_instrumentation.h"
using namespace std;

static char value_type = 'u';
Expand Down Expand Up @@ -138,6 +138,9 @@
*/
static int getAttribute(char * const paramName)
{
// Start distributed trace (creates parent span and stores context)
rdk_otlp_start_distributed_trace(paramName, "get");

if (id && !strncmp(id, "localOnly", 9)) {
TR181_ParamData_t param;
tr181ErrorCode_t status = getLocalParam(id, paramName, &param);
Expand All @@ -150,6 +153,7 @@
{
cout << __FUNCTION__ << " >> Failed to retrieve : Reason " << getTR181ErrorString(status) << endl;
}
rdk_otlp_finish_distributed_trace();
return status;
}

Expand All @@ -165,7 +169,8 @@
{
cout << __FUNCTION__ << " >> Failed to retrieve : Reason " << getRFCErrorString(status) << endl;
}

// Finish distributed trace (ends parent span)
rdk_otlp_finish_distributed_trace();
return status;
}
/**
Expand All @@ -177,6 +182,8 @@
*/
static int setAttribute(char * const paramName ,char type, char * value)
{
//Start distributed trace (creates parent span and stores context)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comment slashes. The codebase convention is to use "// " with a space after the slashes for inline comments, as seen elsewhere in this file (lines 141, 172, 309).

Suggested change
//Start distributed trace (creates parent span and stores context)
// Start distributed trace (creates parent span and stores context)

Copilot uses AI. Check for mistakes.
rdk_otlp_start_distributed_trace(paramName, "set");
if (id && !strncmp(id, "localOnly", 9)) {
int status = setLocalParam(id, paramName, value);
if(status == 0)
Expand All @@ -187,6 +194,7 @@
{
cout << __FUNCTION__ << " >> Failed to Set Local Param." << endl;
}
rdk_otlp_finish_distributed_trace();
return status;
}

Expand All @@ -203,6 +211,7 @@
else
cout << __FUNCTION__ << " >> Set operation success " << endl;

rdk_otlp_finish_distributed_trace();
return status;
}

Expand Down Expand Up @@ -297,6 +306,10 @@
#ifndef GTEST_ENABLE
int main(int argc, char *argv [])
{
// Initialize OpenTelemetry instrumentation
rdk_otlp_init("tr181", "1.0.0");
rdk_otlp_metrics_init();

if(legacyRfcEnabled() == true)
{
return trsetutil(argc,argv);
Expand Down
Loading