RDKCOM-5620: RDKBDEV-3472 Add collection and send timestamps to reports - #403
Open
abdelkarimelhosni wants to merge 2 commits into
Open
Conversation
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>
Contributor
There was a problem hiding this comment.
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 duringCollectAndReport(). - 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 tovalArray, whose key isprofile->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 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; |
Contributor
There was a problem hiding this comment.
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 forsendReportOverHTTP()(seesource/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-timestampto assertstsis injected intoReport[]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
tsinjection inCollectAndReport()is not covered by unit tests (there are existing tests for bulkdata/profile behavior undersource/test/bulkdata/). Please add tests (built with--enable-t2-enable-sts-ts-timestamp) to validate that generated reports includetsinReport[]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 < tseven when both timestamps are present. Since the PR acceptance criteria includessts >= ts, consider clampingststo at least the existingtsvalue when injecting it intoReport[].
long long sendTimeMs =
(long long)sendTime.tv_sec * 1000LL +
sendTime.tv_nsec / 1000000LL;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add collection and send timestamps to Telemetry 2.0 reports.
tsduring report generation inCollectAndReport().stsimmediately before HTTP transmission.Report[].T2_ENABLE_STS_TS_TIMESTAMP.Build option
--enable-t2-enable-sts-ts-timestampThe feature is disabled by default.
Test results
TS_STS_AandTS_STS_B): PASStsandsts: PASSsts >= ts: PASStsnorsts: PASS