Skip to content

RDKCOM-5620: RDKBDEV-3472 Add collection and send timestamps to reports - #403

Open
abdelkarimelhosni wants to merge 2 commits into
rdkcentral:developfrom
abdelkarimelhosni:feature/RDKBDEV-3472-add-ts-sts-timestamps
Open

RDKCOM-5620: RDKBDEV-3472 Add collection and send timestamps to reports#403
abdelkarimelhosni wants to merge 2 commits into
rdkcentral:developfrom
abdelkarimelhosni:feature/RDKBDEV-3472-add-ts-sts-timestamps

Conversation

@abdelkarimelhosni

Copy link
Copy Markdown
Contributor

Description

Add collection and send timestamps to Telemetry 2.0 reports.

  • Add ts during report generation in CollectAndReport().
  • Add sts immediately before HTTP transmission.
  • Store both timestamps as separate objects inside Report[].
  • Express timestamps in milliseconds since Unix epoch.
  • Gate the implementation with T2_ENABLE_STS_TS_TIMESTAMP.
  • Preserve the original payload if JSON parsing or timestamp injection fails.
  • Release the modified payload after the HTTP transmission attempt.

Build option

--enable-t2-enable-sts-ts-timestamp

The feature is disabled by default.

Test results

  • Build with flag enabled: PASS
  • Multiple profiles (TS_STS_A and TS_STS_B): PASS
  • Enabled reports contain ts and sts: PASS
  • sts >= ts: PASS
  • Build with flag disabled: PASS
  • Disabled reports contain neither ts nor sts: PASS
  • mTLS transmission to mockxconf: PASS
  • L1 tests: TO COMPLETE
  • L2 tests: TO COMPLETE'

Add the collection timestamp (ts) during report generation and the send timestamp (sts) immediately before HTTP transmission.

Store both timestamps as separate objects inside the Report array and gate the implementation with T2_ENABLE_STS_TS_TIMESTAMP.

Preserve the original payload if JSON parsing or timestamp injection fails, and release the modified payload after transmission.

Signed-off-by: aelhosni <abdelkarim.elhosni@sfr.com>
Copilot AI review requested due to automatic review settings July 30, 2026 15:19
@abdelkarimelhosni
abdelkarimelhosni requested a review from a team as a code owner July 30, 2026 15:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds optional support for embedding collection (ts) and send (sts) timestamps into Telemetry 2.0 HTTP reports, gated behind a new Autotools configure flag so the default behavior remains unchanged.

Changes:

  • Adds --enable-t2-enable-sts-ts-timestamp (disabled by default) and wires an Automake conditional for compilation.
  • Injects ts (collection time) into the report array during CollectAndReport().
  • Injects sts (send time) into the report payload immediately before HTTP transmission, while preserving the original payload if injection fails.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
source/protocol/http/Makefile.am Conditionally defines T2_ENABLE_STS_TS_TIMESTAMP and links cJSON for the HTTP transport when enabled.
source/protocol/http/curlinterface.c Adds JSON parse/append/re-serialize to inject sts just before http_pool_post().
source/bulkdata/profile.c Appends a ts object to the report array during report generation when enabled.
source/bulkdata/Makefile.am Conditionally defines T2_ENABLE_STS_TS_TIMESTAMP for bulkdata compilation.
configure.ac Introduces --enable-t2-enable-sts-ts-timestamp and Automake conditional ENABLE_T2_ENABLE_STS_TS_TIMESTAMP.
Comments suppressed due to low confidence (1)

source/bulkdata/profile.c:563

  • This comment says the timestamp is added to Report[], but the code actually appends to valArray, whose key is profile->RootName (configurable). The comment should avoid hardcoding the array name to prevent confusion.
                /* Add the collection timestamp as a separate object in Report[]. */

Comment on lines +94 to +96
cJSON *report = cJSON_GetObjectItemCaseSensitive(root, "Report");
if(report != NULL && cJSON_IsArray(report))
{
Comment on lines +90 to +92
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
cJSON *root = cJSON_Parse(payload);
if(root != NULL)
Comment thread source/bulkdata/profile.c
Comment on lines +562 to +566
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
/* Add the collection timestamp as a separate object in Report[]. */
if(valArray != NULL && cJSON_IsArray(valArray))
{
struct timespec collectionTime;
@pradeeptakdas pradeeptakdas changed the title RDKBDEV-3472: Add collection and send timestamps to reports RDKCOM-5620: RDKBDEV-3472: Add collection and send timestamps to reports Jul 30, 2026
@pradeeptakdas pradeeptakdas changed the title RDKCOM-5620: RDKBDEV-3472: Add collection and send timestamps to reports RDKCOM-5620: RDKBDEV-3472 Add collection and send timestamps to reports Jul 30, 2026
Copilot AI review requested due to automatic review settings July 31, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (3)

source/protocol/http/curlinterface.c:93

  • New behavior is added behind T2_ENABLE_STS_TS_TIMESTAMP, but existing unit tests for sendReportOverHTTP() (see source/test/protocol/ProtocolTest.cpp) do not validate timestamp injection or the “preserve original payload on parse/injection failure” requirement. Please add unit tests that run with --enable-t2-enable-sts-ts-timestamp to assert sts is injected into Report[] and that the original payload is used when parsing fails.
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
    cJSON *root = cJSON_Parse(payload);
    if(root != NULL)
    {

source/bulkdata/profile.c:576

  • The new ts injection in CollectAndReport() is not covered by unit tests (there are existing tests for bulkdata/profile behavior under source/test/bulkdata/). Please add tests (built with --enable-t2-enable-sts-ts-timestamp) to validate that generated reports include ts in Report[] and that report generation still succeeds unchanged when timestamp injection fails.
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
                /* Add the collection timestamp as a separate object in Report[]. */
                if(valArray != NULL && cJSON_IsArray(valArray))
                {
                    struct timespec collectionTime;

source/protocol/http/curlinterface.c:102

  • Using CLOCK_REALTIME means the system clock can be adjusted backwards (e.g., NTP/time-sync), which can produce a report where sts < ts even when both timestamps are present. Since the PR acceptance criteria includes sts >= ts, consider clamping sts to at least the existing ts value when injecting it into Report[].
                long long sendTimeMs =
                    (long long)sendTime.tv_sec * 1000LL +
                    sendTime.tv_nsec / 1000000LL;

@AkhilaReddyK7 AkhilaReddyK7 added the community-contribution Contribution from community label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contribution from community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants