Skip to content

Commit a7ba470

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 a7ba470

22 files changed

Lines changed: 530 additions & 8 deletions

cmake/Findtelemetry.cmake

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
include(FindPackageHandleStandardArgs)
25+
find_package_handle_standard_args(TELEMETRY DEFAULT_MSG TELEMETRY_LIBRARY TELEMETRY_INCLUDE_DIR)
26+
27+
mark_as_advanced(TELEMETRY_INCLUDE_DIR TELEMETRY_LIBRARY)
28+
29+
if(TELEMETRY_FOUND)
30+
set(TELEMETRY_LIBRARIES ${TELEMETRY_LIBRARY})
31+
set(TELEMETRY_INCLUDE_DIRS ${TELEMETRY_INCLUDE_DIR})
32+
else()
33+
set(TELEMETRY_LIBRARIES "")
34+
set(TELEMETRY_INCLUDE_DIRS "")
35+
endif()
36+
else()
37+
set(TELEMETRY_INCLUDE_DIRS "")
38+
set(TELEMETRY_LIBRARIES "")
39+
endif()

logging/CMakeLists.txt

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

2020
set(RialtoLogging_HEADERS
2121
include/RialtoLogging.h
22+
include/RialtoTelemetry.h
2223
)
2324

2425
set(RialtoLogging_SOURCES
@@ -34,20 +35,51 @@ set(RialtoLogging_INCLUDES
3435
)
3536

3637
add_library(RialtoLogging STATIC ${RialtoLogging_HEADERS} ${RialtoLogging_SOURCES})
37-
target_include_directories(RialtoLogging PUBLIC "$<BUILD_INTERFACE:${RialtoLogging_INCLUDES}>")
38-
set_target_properties(RialtoLogging PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
39-
set_target_properties(RialtoLogging PROPERTIES POSITION_INDEPENDENT_CODE ON)
38+
target_include_directories(RialtoLogging PUBLIC
39+
"$<BUILD_INTERFACE:${RialtoLogging_INCLUDES}>"
40+
)
4041

42+
# Telemetry support
43+
if(CMAKE_TELEMETRY_2_0_REQUIRED)
44+
message(STATUS "Telemetry 2.0 support enabled")
45+
find_package(telemetry REQUIRED)
46+
target_compile_definitions(RialtoLogging PUBLIC RIALTO_TELEMETRY_SUPPORT=1)
47+
target_include_directories(RialtoLogging PUBLIC ${TELEMETRY_INCLUDE_DIRS})
48+
target_link_libraries(RialtoLogging PUBLIC ${TELEMETRY_LIBRARIES})
49+
else()
50+
message(STATUS "Telemetry support disabled (stub mode)")
51+
endif()
52+
53+
set_target_properties(RialtoLogging PROPERTIES
54+
CXX_STANDARD 17
55+
CXX_STANDARD_REQUIRED ON
56+
CXX_EXTENSIONS OFF
57+
POSITION_INDEPENDENT_CODE ON
58+
)
59+
60+
# EthanLog support
4161
find_package(EthanLog)
4262
if (EthanLog_FOUND AND RIALTO_ENABLE_ETHAN_LOG)
4363
message(STATUS "EthanLog is enabled")
4464
add_library(RialtoEthanLog STATIC ${RialtoLogging_HEADERS} ${RialtoLogging_SOURCES})
4565
target_include_directories(RialtoEthanLog PUBLIC "$<BUILD_INTERFACE:${RialtoLogging_INCLUDES}>")
4666
target_compile_definitions(RialtoEthanLog PRIVATE USE_ETHANLOG)
4767
target_link_libraries(RialtoEthanLog PUBLIC EthanLog::EthanLog)
48-
set_target_properties(RialtoEthanLog PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
49-
set_target_properties(RialtoEthanLog PROPERTIES POSITION_INDEPENDENT_CODE ON)
50-
else ()
68+
if(CMAKE_TELEMETRY_2_0_REQUIRED)
69+
message(STATUS "Telemetry 2.0 support enabled")
70+
target_compile_definitions(RialtoEthanLog PUBLIC RIALTO_TELEMETRY_SUPPORT=1)
71+
target_include_directories(RialtoEthanLog PUBLIC ${TELEMETRY_INCLUDE_DIRS})
72+
target_link_libraries(RialtoEthanLog PUBLIC ${TELEMETRY_LIBRARIES})
73+
else()
74+
message(STATUS "Telemetry support disabled (stub mode)")
75+
endif()
76+
set_target_properties(RialtoEthanLog PROPERTIES
77+
CXX_STANDARD 17
78+
CXX_STANDARD_REQUIRED ON
79+
CXX_EXTENSIONS OFF
80+
POSITION_INDEPENDENT_CODE ON
81+
)
82+
else()
5183
message(STATUS "EthanLog is disabled")
5284
add_library(RialtoEthanLog ALIAS RialtoLogging)
53-
endif ()
85+
endif()

logging/include/RialtoLogging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern "C"
2525
{
2626
#endif
2727

28+
#include "RialtoTelemetry.h"
2829
#include <stdarg.h>
2930
#include <stdint.h>
3031

logging/include/RialtoTelemetry.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
#ifdef RIALTO_TELEMETRY_SUPPORT
24+
#include <telemetry_busmessage_sender.h>
25+
#endif
26+
27+
#ifdef __cplusplus
28+
extern "C"
29+
{
30+
#endif
31+
32+
#ifdef RIALTO_TELEMETRY_SUPPORT
33+
34+
#define TELEMETRY_INIT(component) \
35+
do \
36+
{ \
37+
t2_init(const_cast<char *>(component)); \
38+
} while (0)
39+
40+
#define TELEMETRY_UNINIT() \
41+
do \
42+
{ \
43+
t2_uninit(); \
44+
} while (0)
45+
46+
#define TELEMETRY_EVENT_STRING(marker, value) \
47+
do \
48+
{ \
49+
t2_event_s(const_cast<char *>(marker), const_cast<char *>(value)); \
50+
} while (0)
51+
52+
#define TELEMETRY_EVENT_FLOAT(marker, value) \
53+
do \
54+
{ \
55+
t2_event_f(const_cast<char *>(marker), static_cast<double>(value)); \
56+
} while (0)
57+
58+
#define TELEMETRY_EVENT_INT(marker, value) \
59+
do \
60+
{ \
61+
t2_event_d(const_cast<char *>(marker), static_cast<int>(value)); \
62+
} while (0)
63+
64+
#else /* stub implementation if telemetry not enabled */
65+
66+
#define TELEMETRY_INIT(component) \
67+
do \
68+
{ \
69+
} while (0)
70+
#define TELEMETRY_UNINIT() \
71+
do \
72+
{ \
73+
} while (0)
74+
#define TELEMETRY_EVENT_STRING(m, v) \
75+
do \
76+
{ \
77+
} while (0)
78+
#define TELEMETRY_EVENT_FLOAT(m, v) \
79+
do \
80+
{ \
81+
} while (0)
82+
#define TELEMETRY_EVENT_INT(m, v) \
83+
do \
84+
{ \
85+
} while (0)
86+
87+
#endif /* RIALTO_TELEMETRY_SUPPORT */
88+
89+
#ifdef __cplusplus
90+
}
91+
#endif
92+
93+
#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/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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ void IpcClient::processIpcThread()
159159
if (!m_disconnecting)
160160
{
161161
RIALTO_CLIENT_LOG_ERROR("The ipc channel unexpectedly disconnected, destroying the channel");
162+
char telemetryBuff[128] = {0};
163+
snprintf(telemetryBuff, sizeof(telemetryBuff),
164+
"The ipc channel unexpectedly disconnected, destroying the channel");
165+
TELEMETRY_EVENT_STRING("Rialto Client - IpcClient", telemetryBuff);
162166

163167
// Safe to destroy the ipc objects in the ipc thread as the client has already disconnected.
164168
// This ensures the channel is destructed and that all ongoing ipc calls are unblocked.

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)