Introduction

Using the Telemetry 2.0 Common Library APIs, RDKV components, processes and scripts can send telemetry data to the T2 component to allow reporting that data without the need for grepping log flies.  Use of the APIs does not preclude writing to logs, but can help reduce the need to grep log files, therefore reducing the CPU load spike for traditional 15 minute telemetry reporting.

Brief Background:

In DCA telemetry, the markers fetched from xconf are grepped in log files and reported in json format to splunk server.

The markers are of 2 types .

  1. Split based markers
  2. Count based markers
Marker TypeSample configuration from xconfDescription with respect to sample configuration
Split based markers
{"header":"WIFI_ACS_1_split","content":"WIFI_ACS_1:","type":"wifihealth.txt","pollingFrequency":"0"}
Expects the value after content "WIFI_ACS_1:"
Count based markers 
{"header":"RF_ERROR_IPV6PingFailed","content":"Ping to IPv6 Gateway Address are failed","type":"SelfHeal.txt.0","pollingFrequency":"0"}
Expects the occurance count of content "Ping to IPv6 Gateway Address are failed"

In T2.0,  the aim is to instrument as many split and count based markers from the component side as possible. These are called "event" markers.

Once a marker is instrumented from component side, its configuration on xconf will be changed  from the configured file name to "<event>" in  'type:' section.

Example: {"header":"WIFI_ACS_1_split","content":"WIFI_ACS_1:","type":<event>","pollingFrequency":"0"}


 Overview of Instrumenting RDKV components with T2 shared library (commonlib) APIs

Steps to instrument split and count based markers from RDKV components side:

  1. Check if that particular device Build have the Telemetry2.0 building capability
  2. Include required headers 
  3. Compile the component with telemetry 2.0 support.
  4. Initialize the module with telemetry
  5. Find the correct place to report a marker .
  6. Use appropriate APIs to report markers and values.
  7. Must check notes
  1. To check if a particular device build have the Telemetry2.0 building capability
    1. Ensure telemetry package is included in package group for video devices
      1. https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/rdk-oe/meta-rdk/+/refs/heads/rdk-next/recipes-core/packagegroups/packagegroup-rdk-media-common.bb 
  2. Include required headers / declare enough sized telemetry buffer and send events to T2 with t2_event_s() api
    1. For C/CPP:
      1. #include <telemetry_busmessage_sender.h>
    2. For Scripts:
      1. source /lib/rdk/t2Shared_api.sh
  3. To compile a component with Telemetry2.0 if it is enabled for that device
    1. Add depends to telemetry module in respective component recipe with - DEPENDS_append = "telemetry"
    2. Update the LD_FLAGS to link with telemetry_msgsender library.
  4. Initialize the module with telemetry
    1. Initialization needs to be done only once at the very initial stage of application / module.  Note that the component itself does not need to check the T2 RFC; this will be done within the T2 Common Library code when the t2_ functions are called.
    2. Actual init calls in wrapper function is t2_init :
      void ReportT2Event::initialize() {
              t2_init("receiver");
          }
  5. Find the correct place to report a marker
    1. Previously  in DCA telemetry, a marker is reported based on the xconf configured "content" string -  when the content string is found in corresponding configured filename configured under 'type:' section .
      1.  /* Refer :  {"header": "WIFI_INFO_Hotspot_client_connected", "content": "Added case, Client with:", "type": "Hotspotlog.txt.0","pollingFrequency":"0"} */
      2. So, find the right place where the content string is being written to the corresponding log file in order to event a marker in T2.0.
        1. https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/hotspot/+/refs/heads/rdk-next/source/hotspotfd/cosa_hotspot_dml.c (Line number 144 gives the idea) CcspTraceInfo(("Added case, Client with MAC:%s will be added\n", l_cMacAddr));
      3. Once the place is decided, use the right API to report Marker and values. 
        1. For markers without "_split" suffix, the marker data is just a count of the number of times the marker is received.  In this case, the t2_event_d API can be used because the marker data passed to the API is not important.
          1. Example:  t2_event_d("WIFI_INFO_Hotspot_client_connected", 1); in https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/hotspot/+/refs/heads/rdk-next/source/hotspotfd/cosa_hotspot_dml.c
        2. For markers with "_split" suffix, the marker data is important, so use the API most appropriate to the marker data.  For instance, if the marker data is a string, use t2_event_s.  But if marker data is numeric, use one of t2_event_d or t2_event_f.  Also note that testing must ensure the string used for marker data matches the string expected by legacy telemetry.
          1. Example : t2_event_s("acs_split", pStr); in https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspTr069Pa/+/refs/heads/rdk-next/source-embedded/DslhManagementServer/ccsp_management_server_pa_api.c#767
  6. Use appropriate APIs to event markers and values
    1. In RDKB we have logs coming from both scripts and component's code (code in C). From which markers are reported/grepped.
    2. List of APIs :
      1. To report markers from components
        • t2_event_s(char* marker, char* value) - To send _split marker with string value to T2
          • Usage:
            • t2_event_s("xh_mac_3_split", "xh_MAC_value”);
            • t2_event_s("xh_mac_3_split", strBuff); /* where strBuff contains the string value to be reported for this marker */
          • NOTE: The instrumented component could use a static buffer or do a buffer malloc itself; but T2 common lib makes its own copy regardless, so instrumented component must clean up after itself.
        • t2_event_f(char* marker, double value) - To send marker with double value to T2
          • Usage: t2_event_d("HWREV_split", 2.2);
        • t2_event_d(char* marker, int value) - To send marker with integer value to T2  (or) to report count based markers
      2. To report markers from Scripts.
      3. t2CountNotify  "Marker"- To report count based markers.
  7. Must Check Notes
    1. While instrumenting components
    2. While instrumenting  Scripts
      1. Source the utility script /lib/rdk/t2Shared_api.sh 
      2. Invoke :
        1. t2ValNotify "Marker" "Value" - To report split based markers
        2. t2CountNotify  "Marker" - To report count based markers.

References


  • No labels