Skip to content

Commit a334d54

Browse files
committed
Telemetry integration
Summary: Integrating telemetry T2 markers into Rialto Type: Fix Test Plan: UT/CT, Fullstack Jira: RDKEMW-16516
1 parent 5a092bb commit a334d54

26 files changed

Lines changed: 496 additions & 57 deletions

cmake/Findtelemetry.cmake

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#
2+
# If not stated otherwise in this file or this component's LICENSE file the
3+
# following copyright and licenses apply:
4+
#
5+
# Copyright 2026 Sky UK
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
if(NOT NATIVE_BUILD)
21+
find_path(TELEMETRY_INCLUDE_DIR NAMES telemetry_busmessage_sender.h)
22+
find_library(TELEMETRY_LIBRARY NAMES telemetry_msgsender)
23+
24+
message(STATUS "Telemetry include dir: ${TELEMETRY_INCLUDE_DIR}")
25+
message(STATUS "Telemetry library: ${TELEMETRY_LIBRARY}")
26+
27+
include(FindPackageHandleStandardArgs)
28+
find_package_handle_standard_args(TELEMETRY DEFAULT_MSG TELEMETRY_LIBRARY TELEMETRY_INCLUDE_DIR)
29+
30+
mark_as_advanced(TELEMETRY_INCLUDE_DIR TELEMETRY_LIBRARY)
31+
32+
if(TELEMETRY_FOUND AND NOT TARGET telemetry)
33+
add_library(telemetry SHARED IMPORTED)
34+
set_target_properties(telemetry PROPERTIES
35+
IMPORTED_LOCATION "${TELEMETRY_LIBRARY}"
36+
INTERFACE_INCLUDE_DIRECTORIES "${TELEMETRY_INCLUDE_DIR}")
37+
endif()
38+
else()
39+
include(ExternalProject)
40+
set_property(DIRECTORY PROPERTY EP_BASE "${CMAKE_CURRENT_BINARY_DIR}/third-party")
41+
42+
ExternalProject_Add(
43+
telemetry-source
44+
GIT_REPOSITORY https://github.com/rdkcentral/telemetry.git
45+
GIT_TAG develop
46+
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/third-party
47+
BUILD_IN_SOURCE 1
48+
CONFIGURE_COMMAND ""
49+
BUILD_COMMAND make
50+
INSTALL_COMMAND ""
51+
)
52+
53+
ExternalProject_Get_Property(telemetry-source SOURCE_DIR)
54+
55+
set(TELEMETRY_INCLUDE_DIR ${SOURCE_DIR}/include)
56+
set(TELEMETRY_LIBRARY ${SOURCE_DIR}/lib/libtelemetry_msgsender.so)
57+
58+
message(STATUS "Telemetry include dir (native): ${TELEMETRY_INCLUDE_DIR}")
59+
message(STATUS "Telemetry library (native): ${TELEMETRY_LIBRARY}")
60+
61+
add_library(telemetry SHARED IMPORTED)
62+
set_target_properties(telemetry PROPERTIES
63+
IMPORTED_LOCATION "${TELEMETRY_LIBRARY}"
64+
INTERFACE_INCLUDE_DIRECTORIES "${TELEMETRY_INCLUDE_DIR}"
65+
IMPORTED_NO_SONAME TRUE
66+
)
67+
68+
add_dependencies(telemetry telemetry-source)
69+
endif()

logging/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ set(RialtoLogging_INCLUDES
3333
"${CMAKE_CURRENT_SOURCE_DIR}/include"
3434
)
3535

36+
find_package(telemetry REQUIRED)
37+
3638
add_library(RialtoLogging STATIC ${RialtoLogging_HEADERS} ${RialtoLogging_SOURCES})
3739
target_include_directories(RialtoLogging PUBLIC "$<BUILD_INTERFACE:${RialtoLogging_INCLUDES}>")
40+
target_link_libraries(RialtoLogging PUBLIC telemetry)
3841
set_target_properties(RialtoLogging PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
3942
set_target_properties(RialtoLogging PROPERTIES POSITION_INDEPENDENT_CODE ON)
4043

@@ -44,7 +47,7 @@ if (EthanLog_FOUND AND RIALTO_ENABLE_ETHAN_LOG)
4447
add_library(RialtoEthanLog STATIC ${RialtoLogging_HEADERS} ${RialtoLogging_SOURCES})
4548
target_include_directories(RialtoEthanLog PUBLIC "$<BUILD_INTERFACE:${RialtoLogging_INCLUDES}>")
4649
target_compile_definitions(RialtoEthanLog PRIVATE USE_ETHANLOG)
47-
target_link_libraries(RialtoEthanLog PUBLIC EthanLog::EthanLog)
50+
target_link_libraries(RialtoEthanLog PUBLIC EthanLog::EthanLog telemetry)
4851
set_target_properties(RialtoEthanLog PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
4952
set_target_properties(RialtoEthanLog PROPERTIES POSITION_INDEPENDENT_CODE ON)
5053
else ()

logging/include/RialtoLogging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern "C"
2727

2828
#include <stdarg.h>
2929
#include <stdint.h>
30+
#include "RialtoTelemetry.h"
3031

3132
/**
3233
* Defined log levels used to set the required output logs for the component

logging/include/RialtoTelemetry.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* If not stated otherwise in this file or this component's LICENSE file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2026 Sky UK
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#ifndef __RIALTO_TELEMETRY_H__
21+
#define __RIALTO_TELEMETRY_H__
22+
23+
#include <telemetry_busmessage_sender.h>
24+
25+
#ifdef __cplusplus
26+
extern "C" {
27+
#endif
28+
29+
#define TELEMETRY_INIT(component) \
30+
do { \
31+
t2_init((char*)component); \
32+
} while(0)
33+
34+
#define TELEMETRY_UNINIT() \
35+
do { \
36+
t2_uninit(); \
37+
} while(0)
38+
39+
#define TELEMETRY_EVENT_STRING(marker, value) \
40+
do { \
41+
t2_event_s((char*)marker, (char*)value); \
42+
} while(0)
43+
44+
#define TELEMETRY_EVENT_FLOAT(marker, value) \
45+
do { \
46+
t2_event_f((char*)marker, (double)value); \
47+
} while(0)
48+
49+
#define TELEMETRY_EVENT_INT(marker, value) \
50+
do { \
51+
t2_event_d((char*)marker, (int)value); \
52+
} while(0)
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
#endif /* __RIALTO_TELEMETRY_H__ */

media/client/common/include/RialtoClientLogging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define RIALTO_CLIENT_LOGGING_H_
2222

2323
#include "RialtoLogging.h"
24+
#include <cstdio>
2425

2526
#ifdef __cplusplus
2627
extern "C"

media/client/ipc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ target_link_libraries (
6767
RialtoPlayerCommon
6868
RialtoEthanLog
6969
RialtoProtobuf
70+
telemetry
7071
)

media/client/ipc/source/ControlIpc.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ bool ControlIpc::getSharedMemory(int32_t &fd, uint32_t &size)
115115
if (ipcController->Failed())
116116
{
117117
RIALTO_CLIENT_LOG_ERROR("failed to get the shared memory due to '%s'", ipcController->ErrorText().c_str());
118+
char telemetryBuff[128] = {0};
119+
snprintf(telemetryBuff, sizeof(telemetryBuff), "Failed to get the shared memory due to '%s'",
120+
ipcController->ErrorText().c_str());
121+
TELEMETRY_EVENT_STRING("Rialto Client - ControllIpc", telemetryBuff);
118122
return false;
119123
}
120124

@@ -152,6 +156,10 @@ bool ControlIpc::registerClient()
152156
if (ipcController->Failed())
153157
{
154158
RIALTO_CLIENT_LOG_ERROR("failed to register client due to '%s'", ipcController->ErrorText().c_str());
159+
char telemetryBuff[128] = {0};
160+
snprintf(telemetryBuff, sizeof(telemetryBuff), "Failed to register client due to '%s'",
161+
ipcController->ErrorText().c_str());
162+
TELEMETRY_EVENT_STRING("Rialto Client - ControllIpc", telemetryBuff);
155163
return false;
156164
}
157165

@@ -181,6 +189,13 @@ bool ControlIpc::registerClient()
181189
RIALTO_CLIENT_LOG_ERROR("Server and Client proto schema versions are not compatible. Server schema version: "
182190
"%s, Client schema version: %s",
183191
kServerSchemaVersion.str().c_str(), kCurrentSchemaVersion.str().c_str());
192+
char telemetryBuff[128] = {0};
193+
snprintf(telemetryBuff, sizeof(telemetryBuff),
194+
"Server and Client proto schema versions are not compatible. Server schema version: "
195+
"%s, Client schema version: %s",
196+
kServerSchemaVersion.str().c_str(), kCurrentSchemaVersion.str().c_str());
197+
TELEMETRY_EVENT_STRING("Rialto Client - ControllIpc", telemetryBuff);
198+
184199
return false;
185200
}
186201

@@ -260,6 +275,9 @@ void ControlIpc::onPing(const std::shared_ptr<firebolt::rialto::PingEvent> &even
260275
if (ipcController->Failed())
261276
{
262277
RIALTO_CLIENT_LOG_ERROR("failed to ack due to '%s'", ipcController->ErrorText().c_str());
278+
char telemetryBuff[128] = {0};
279+
snprintf(telemetryBuff, sizeof(telemetryBuff), "Failed to ack due to '%s'", ipcController->ErrorText().c_str());
280+
TELEMETRY_EVENT_STRING("Rialto Client - ControllIpc", telemetryBuff);
263281
}
264282
}
265283
}; // namespace firebolt::rialto::client

media/client/ipc/source/IpcClient.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "IpcClient.h"
2121
#include "RialtoClientLogging.h"
22-
#include <utility>
2322

2423
namespace firebolt::rialto::client
2524
{
@@ -159,6 +158,10 @@ void IpcClient::processIpcThread()
159158
if (!m_disconnecting)
160159
{
161160
RIALTO_CLIENT_LOG_ERROR("The ipc channel unexpectedly disconnected, destroying the channel");
161+
char telemetryBuff[128] = {0};
162+
snprintf(telemetryBuff, sizeof(telemetryBuff),
163+
"The ipc channel unexpectedly disconnected, destroying the channel");
164+
TELEMETRY_EVENT_STRING("Rialto Client - IpcClient", telemetryBuff);
162165

163166
// Safe to destroy the ipc objects in the ipc thread as the client has already disconnected.
164167
// This ensures the channel is destructed and that all ongoing ipc calls are unblocked.
@@ -192,7 +195,7 @@ std::shared_ptr<ipc::IBlockingClosure> IpcClient::createBlockingClosure()
192195
// check which thread we're being called from, this determines if we pump
193196
// event loop from within the wait() method or not
194197
if (m_ipcThread.get_id() == std::this_thread::get_id())
195-
return m_blockingClosureFactory->createBlockingClosurePoll(std::move(ipcChannel));
198+
return m_blockingClosureFactory->createBlockingClosurePoll(ipcChannel);
196199
else
197200
return m_blockingClosureFactory->createBlockingClosureSemaphore();
198201
}

media/client/ipc/source/MediaKeysCapabilitiesIpc.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ std::shared_ptr<IMediaKeysCapabilitiesIpcFactory> IMediaKeysCapabilitiesIpcFacto
3636
catch (const std::exception &e)
3737
{
3838
RIALTO_CLIENT_LOG_ERROR("Failed to create the media keys capabilities ipc factory, reason: %s", e.what());
39+
char telemetryBuff[128] = {0};
40+
snprintf(telemetryBuff, sizeof(telemetryBuff),
41+
"Failed to create the media keys capabilities ipc factory, reason: %s", e.what());
42+
TELEMETRY_EVENT_STRING("Rialto Client - MediaKeysCapabilitiesIpc", telemetryBuff);
3943
}
4044

4145
return factory;
@@ -58,6 +62,10 @@ std::shared_ptr<IMediaKeysCapabilities> MediaKeysCapabilitiesIpcFactory::getMedi
5862
catch (const std::exception &e)
5963
{
6064
RIALTO_CLIENT_LOG_ERROR("Failed to create the media keys capabilities ipc, reason: %s", e.what());
65+
char telemetryBuff[128] = {0};
66+
snprintf(telemetryBuff, sizeof(telemetryBuff),
67+
"Failed to create the media keys capabilities ipc, reason: %s", e.what());
68+
TELEMETRY_EVENT_STRING("Rialto Client - MediaKeysCapabilitiesIpc", telemetryBuff);
6169
}
6270

6371
MediaKeysCapabilitiesIpcFactory::m_mediaKeysCapabilitiesIpc = mediaKeysCapabilitiesIpc;
@@ -115,6 +123,10 @@ std::vector<std::string> MediaKeysCapabilitiesIpc::getSupportedKeySystems()
115123
if (ipcController->Failed())
116124
{
117125
RIALTO_CLIENT_LOG_ERROR("failed to get supported key systems due to '%s'", ipcController->ErrorText().c_str());
126+
char telemetryBuff[128] = {0};
127+
snprintf(telemetryBuff, sizeof(telemetryBuff), "Failed to get supported key systems due to '%s'",
128+
ipcController->ErrorText().c_str());
129+
TELEMETRY_EVENT_STRING("Rialto Client - MediaKeysCapabilitiesIpc", telemetryBuff);
118130
return {};
119131
}
120132

@@ -144,6 +156,10 @@ bool MediaKeysCapabilitiesIpc::supportsKeySystem(const std::string &keySystem)
144156
if (ipcController->Failed())
145157
{
146158
RIALTO_CLIENT_LOG_ERROR("failed to supports key system due to '%s'", ipcController->ErrorText().c_str());
159+
char telemetryBuff[128] = {0};
160+
snprintf(telemetryBuff, sizeof(telemetryBuff), "Failed to support key systems due to '%s'",
161+
ipcController->ErrorText().c_str());
162+
TELEMETRY_EVENT_STRING("Rialto Client - MediaKeysCapabilitiesIpc", telemetryBuff);
147163
return false;
148164
}
149165

@@ -175,6 +191,10 @@ bool MediaKeysCapabilitiesIpc::getSupportedKeySystemVersion(const std::string &k
175191
{
176192
RIALTO_CLIENT_LOG_ERROR("failed to get supported key system version due to '%s'",
177193
ipcController->ErrorText().c_str());
194+
char telemetryBuff[128] = {0};
195+
snprintf(telemetryBuff, sizeof(telemetryBuff), "Failed to get supported key system versions due to '%s'",
196+
ipcController->ErrorText().c_str());
197+
TELEMETRY_EVENT_STRING("Rialto Client - MediaKeysCapabilitiesIpc", telemetryBuff);
178198
return false;
179199
}
180200
version = response.version();
@@ -207,6 +227,10 @@ bool MediaKeysCapabilitiesIpc::isServerCertificateSupported(const std::string &k
207227
{
208228
RIALTO_CLIENT_LOG_ERROR("failed to check if server certificate is supported due to '%s'",
209229
ipcController->ErrorText().c_str());
230+
char telemetryBuff[128] = {0};
231+
snprintf(telemetryBuff, sizeof(telemetryBuff), "Failed to check if server certificate is supported due to '%s'",
232+
ipcController->ErrorText().c_str());
233+
TELEMETRY_EVENT_STRING("Rialto Client - MediaKeysCapabilitiesIpc", telemetryBuff);
210234
return false;
211235
}
212236

0 commit comments

Comments
 (0)