Skip to content

fix: Add safeguards for addToTrace#1490

Merged
ellisong merged 3 commits into
mainfrom
NR-366078-addtotrace
Jun 4, 2025
Merged

fix: Add safeguards for addToTrace#1490
ellisong merged 3 commits into
mainfrom
NR-366078-addtotrace

Conversation

@ellisong

Copy link
Copy Markdown
Contributor

Events created with addToTrace API, which have an invalid UNIX timestamp, emit a warning and return without creating the event.

Overview

Added safeguards for addToTrace() API call. It was possible to have negative timestamps before with misuse. This PR does not create the event if the timestamps are negative. A warning is emitted of error code 61 if the timestamps are invalid.

At first I thought that the requirements were to only check that the arguments of the method are valid timestamps, but it makes more sense to me to check that the timestamps in the event creation are valid.

Related Issue(s)

JIRA: https://new-relic.atlassian.net/browse/NR-366078

Testing

Make sure tests pass

@github-actions

github-actions Bot commented May 30, 2025

Copy link
Copy Markdown

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 24.97 kB / 9.47 kB (gzip) 24.97 kB / 9.47 kB (gzip) 0% / 0% (gzip)
lite async-chunk 52.6 kB / 17.45 kB (gzip) 52.6 kB / 17.45 kB (gzip) 0% / 0% (gzip)
pro loader 52.85 kB / 18.58 kB (gzip) 52.91 kB / 18.61 kB (gzip) 0.1% / 0.16% (gzip)
pro async-chunk 91.84 kB / 28.46 kB (gzip) 91.84 kB / 28.46 kB (gzip) 0% / 0% (gzip)
spa loader 61.61 kB / 21.27 kB (gzip) 61.66 kB / 21.31 kB (gzip) 0.09% / 0.17% (gzip)
spa async-chunk 116.46 kB / 35.44 kB (gzip) 116.46 kB / 35.44 kB (gzip) 0% / 0% (gzip)

@codecov

codecov Bot commented May 30, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.71%. Comparing base (66f5eb8) to head (5cf08c0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1490   +/-   ##
=======================================
  Coverage   87.70%   87.71%           
=======================================
  Files         197      197           
  Lines        7746     7749    +3     
  Branches     1554     1555    +1     
=======================================
+ Hits         6794     6797    +3     
  Misses        820      820           
  Partials      132      132           
Flag Coverage Δ
unit-tests 78.73% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented May 30, 2025

Copy link
Copy Markdown

Static Badge

Last ran on June 02, 2025 13:08:32 CDT
Checking merge of (9c41526) into main (265f910)

metal-messiah
metal-messiah previously approved these changes Jun 3, 2025
Comment thread docs/warning-codes.md Outdated
Comment thread src/loaders/api/addToTrace.js Outdated

@cwli24 cwli24 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.

Do you want to make msg 61 specific to the Trace API? Or keep it generic so that maybe we can reuse this warning message for other checks in the agent.

@ellisong ellisong enabled auto-merge (squash) June 4, 2025 17:49
@ellisong ellisong disabled auto-merge June 4, 2025 17:49
@github-actions

github-actions Bot commented Jun 4, 2025

Copy link
Copy Markdown

Supportability Metric Usage Changes:

No matching changes found

Supportability Metrics .md File Changes:

supportability_metrics.md was changed? false

New supportability metrics require changes to supportability_metrics.md, as well as a new PR to Angler. Please ensure an Angler PR is created and linked to this PR.

@ellisong ellisong merged commit e94a36e into main Jun 4, 2025
19 checks passed
@ellisong ellisong deleted the NR-366078-addtotrace branch June 4, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants