Skip to content

Commit 4cedbea

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 4cedbea

25 files changed

Lines changed: 575 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: 41 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
@@ -27,27 +28,60 @@ set(RialtoLogging_SOURCES
2728
source/LogFileHandle.cpp
2829
source/LogFileHandle.h
2930
source/RialtoLogging.cpp
31+
source/RialtoTelemetry.cpp
3032
)
3133

3234
set(RialtoLogging_INCLUDES
3335
"${CMAKE_CURRENT_SOURCE_DIR}/include"
3436
)
3537

3638
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)
39+
target_include_directories(RialtoLogging PUBLIC
40+
"$<BUILD_INTERFACE:${RialtoLogging_INCLUDES}>"
41+
)
4042

43+
# Telemetry support
44+
if(CMAKE_TELEMETRY_2_0_REQUIRED)
45+
message(STATUS "Telemetry 2.0 support enabled")
46+
find_package(telemetry REQUIRED)
47+
add_definitions( -DRIALTO_TELEMETRY_SUPPORT=1 )
48+
target_compile_definitions(RialtoLogging PUBLIC RIALTO_TELEMETRY_SUPPORT=1)
49+
target_include_directories(RialtoLogging PUBLIC ${TELEMETRY_INCLUDE_DIRS})
50+
target_link_libraries(RialtoLogging PUBLIC ${TELEMETRY_LIBRARIES})
51+
else()
52+
message(STATUS "Telemetry support disabled (stub mode)")
53+
endif()
54+
55+
set_target_properties(RialtoLogging PROPERTIES
56+
CXX_STANDARD 17
57+
CXX_STANDARD_REQUIRED ON
58+
CXX_EXTENSIONS OFF
59+
POSITION_INDEPENDENT_CODE ON
60+
)
61+
62+
# EthanLog support
4163
find_package(EthanLog)
4264
if (EthanLog_FOUND AND RIALTO_ENABLE_ETHAN_LOG)
4365
message(STATUS "EthanLog is enabled")
4466
add_library(RialtoEthanLog STATIC ${RialtoLogging_HEADERS} ${RialtoLogging_SOURCES})
4567
target_include_directories(RialtoEthanLog PUBLIC "$<BUILD_INTERFACE:${RialtoLogging_INCLUDES}>")
4668
target_compile_definitions(RialtoEthanLog PRIVATE USE_ETHANLOG)
4769
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 ()
70+
if(CMAKE_TELEMETRY_2_0_REQUIRED)
71+
message(STATUS "Telemetry 2.0 support enabled")
72+
target_compile_definitions(RialtoEthanLog PUBLIC RIALTO_TELEMETRY_SUPPORT=1)
73+
target_include_directories(RialtoEthanLog PUBLIC ${TELEMETRY_INCLUDE_DIRS})
74+
target_link_libraries(RialtoEthanLog PUBLIC ${TELEMETRY_LIBRARIES})
75+
else()
76+
message(STATUS "Telemetry support disabled (stub mode)")
77+
endif()
78+
set_target_properties(RialtoEthanLog PROPERTIES
79+
CXX_STANDARD 17
80+
CXX_STANDARD_REQUIRED ON
81+
CXX_EXTENSIONS OFF
82+
POSITION_INDEPENDENT_CODE ON
83+
)
84+
else()
5185
message(STATUS "EthanLog is disabled")
5286
add_library(RialtoEthanLog ALIAS RialtoLogging)
53-
endif ()
87+
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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
void TELEMETRY_INIT(const char* component);
35+
void TELEMETRY_UNINIT();
36+
void TELEMETRY_EVENT_STRING(const char* marker, const char* value);
37+
void TELEMETRY_EVENT_FLOAT(const char* marker, float value);
38+
void TELEMETRY_EVENT_INT(const char* marker, int value);
39+
40+
#else /* stub implementation if telemetry not enabled */
41+
42+
inline void TELEMETRY_INIT(const char* component) {}
43+
inline void TELEMETRY_UNINIT() {}
44+
inline void TELEMETRY_EVENT_STRING(const char* marker, const char* value) {}
45+
inline void TELEMETRY_EVENT_FLOAT(const char* marker, float value) {}
46+
inline void TELEMETRY_EVENT_INT(const char* marker, int value) {}
47+
48+
#endif /* RIALTO_TELEMETRY_SUPPORT */
49+
50+
#ifdef __cplusplus
51+
}
52+
#endif
53+
54+
#endif /* RIALTO_TELEMETRY_H_ */

logging/source/RialtoTelemetry.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
#include "RialtoLogging.h"
21+
#include <cstring>
22+
#include <cstdio>
23+
24+
#ifdef __cplusplus
25+
extern "C"
26+
{
27+
#endif
28+
29+
#define RIALTO_TELEMETRY_LOG_MIL(fmt, args...) RIALTO_LOG_MIL(RIALTO_COMPONENT_SERVER, fmt, ##args)
30+
31+
#ifdef __cplusplus
32+
}
33+
#endif
34+
35+
#ifdef RIALTO_TELEMETRY_SUPPORT
36+
37+
void TELEMETRY_INIT(const char* component)
38+
{
39+
RIALTO_TELEMETRY_LOG_MIL("Telemetry initialized for: %s", component);
40+
printf("Telemetry initialized for: %s", component);
41+
// Copy into a mutable buffer: t2_init takes char* and may write to it,
42+
// so passing a const/string-literal directly is undefined behavior.
43+
char buf[64];
44+
strncpy(buf, component, sizeof(buf) - 1);
45+
buf[sizeof(buf) - 1] = '\0';
46+
t2_init(buf);
47+
}
48+
49+
void TELEMETRY_UNINIT()
50+
{
51+
t2_uninit();
52+
}
53+
54+
void TELEMETRY_EVENT_STRING(const char* marker, const char* value)
55+
{
56+
RIALTO_LOG_MIL(RIALTO_COMPONENT_SERVER, "Telemetry marker: %s, value: %s", marker, value);
57+
printf("Telemetry marker: %s, value: %s", marker, value);
58+
t2_event_s(const_cast<char*>(marker), const_cast<char*>(value));
59+
}
60+
61+
void TELEMETRY_EVENT_FLOAT(const char* marker, float value)
62+
{
63+
t2_event_f(const_cast<char*>(marker), static_cast<double>(value));
64+
}
65+
66+
void TELEMETRY_EVENT_INT(const char* marker, int value)
67+
{
68+
t2_event_d(const_cast<char*>(marker), static_cast<int>(value));
69+
}
70+
71+
#endif /* RIALTO_TELEMETRY_SUPPORT */

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)