Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added transaction ID to ErrorTrace event #1954

Merged

Conversation

svetlanabrennan
Copy link
Contributor

@svetlanabrennan svetlanabrennan commented Jan 18, 2024

Description

We need to add the transaction id to ErrorTrace event to link Transactions to Traces.

Added transaction.id as the last field of the Error Trace JSON payload if the error occurs within a transaction.

Example error trace payload:

[
  "BSr1H3OtQKJhADnLvCAdVaVlqrHUAAgBAAAnIQEAAMwQAgQgHVy5AwAGMTEuOYWZ0ZXItMw",
  [
    0,
    "WebTransaction/Expressjs/GET//error-stack",
    "Expected ',' or '}' after property value in JSON at position 47",
    "SyntaxError",
    {
      "userAttributes": {},
      "agentAttributes": {
        "spanId": "4c6c496ad0492950",
        "request.headers.host": "localhost:3000",
        "request.headers.userAgent": "curl/8.4.0",
        "request.headers.accept": "*/*",
        "request.method": "GET",
        "request.uri": "/error-stack",
        "http.statusCode": "500",
        "http.statusText": "Internal Server Error",
        "response.headers.contentSecurityPolicy": "default-src 'none'",
        "response.headers.contentType": "text/html; charset=utf-8",
        "response.headers.contentLength": 1228
      },
      "intrinsics": {
        "totalTime": 0.009906432625,
        "error.expected": false
      },
      "stack_trace": [ // snipped ]
    },
    "80e1fa9afe5439fb" // Transaction ID
  ]
]

How to Test

Updated some unit tests. Added unit tests that confirm transaction id is added to error trace json when distributed tracking is both turned off and turned on.

Related Issues

Closes #1951

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (60e57a1) 97.03% compared to head (73c52fc) 97.03%.
Report is 2 commits behind head on main.

❗ Current head 73c52fc differs from pull request most recent head 4f4bf29. Consider uploading reports for the commit 4f4bf29 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1954   +/-   ##
=======================================
  Coverage   97.03%   97.03%           
=======================================
  Files         215      215           
  Lines       40372    40373    +1     
=======================================
+ Hits        39176    39177    +1     
  Misses       1196     1196           
Flag Coverage Δ
integration-tests-16.x 78.88% <100.00%> (+<0.01%) ⬆️
integration-tests-18.x 79.16% <100.00%> (+0.01%) ⬆️
integration-tests-20.x 79.15% <100.00%> (-0.03%) ⬇️
unit-tests-16.x 91.12% <100.00%> (+<0.01%) ⬆️
unit-tests-18.x 91.11% <100.00%> (+<0.01%) ⬆️
unit-tests-20.x 91.11% <100.00%> (+<0.01%) ⬆️
versioned-tests-16.x 74.00% <100.00%> (-0.03%) ⬇️
versioned-tests-18.x 74.02% <100.00%> (-0.03%) ⬇️
versioned-tests-20.x 74.03% <100.00%> (-0.03%) ⬇️

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.

@svetlanabrennan svetlanabrennan marked this pull request as ready for review January 19, 2024 22:38
@bizob2828 bizob2828 changed the title feat: Add transaction ID to ErrorTrace event feat: Added transaction ID to ErrorTrace event Jan 22, 2024
lib/errors/index.js Outdated Show resolved Hide resolved
test/unit/errors/error-collector.test.js Outdated Show resolved Hide resolved
test/unit/errors/error-collector.test.js Outdated Show resolved Hide resolved
test/unit/errors/error-collector.test.js Outdated Show resolved Hide resolved
@svetlanabrennan
Copy link
Contributor Author

@bizob2828 I've fixed the tests checking the transaction id is present as you suggested since I have access to the transaction.id in the tests.

jsumners-nr
jsumners-nr previously approved these changes Jan 22, 2024
test/unit/api/api-set-user-id.test.js Outdated Show resolved Hide resolved
Co-authored-by: James Sumners <jsumners@newrelic.com>
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

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

🚢 🇮🇹

@bizob2828 bizob2828 merged commit 5d0ebcd into newrelic:main Jan 22, 2024
20 checks passed
Node.js Engineering Board automation moved this from Needs PR Review to Done: Issues recently completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Node.js Engineering Board
  
Done: Issues recently completed
Development

Successfully merging this pull request may close these issues.

Node - Errors Inbox: Always link Transactions to Traces
3 participants