Skip to content

feat: add injection metadata fields to telemetry forwarder #6203

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

Merged
merged 21 commits into from
Aug 11, 2025

Conversation

sydney-tung
Copy link
Contributor

@sydney-tung sydney-tung commented Jul 30, 2025

What does this PR do?

This change adds additional fields to the telemetry forwarder used during injection. These fields will be used to add additional context that will be surfaced to the end user in the following Figma:
Screenshot 2025-07-03 at 10 39 35 AM
See Injection Metadata for more details.

Motivation

Adding addition information for telemetry forwarder during injection.

Plugin Checklist

Additional Notes

Copy link

github-actions bot commented Jul 30, 2025

Overall package size

Self size: 11.15 MB
Deduped: 110.8 MB
No deduping: 111.18 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | @datadog/libdatadog | 0.7.0 | 35.02 MB | 35.02 MB | | @datadog/native-appsec | 10.1.0 | 20.37 MB | 20.37 MB | | @datadog/native-iast-taint-tracking | 4.0.0 | 11.72 MB | 11.73 MB | | @datadog/pprof | 5.9.0 | 9.77 MB | 10.14 MB | | @opentelemetry/core | 1.30.1 | 908.66 kB | 7.16 MB | | protobufjs | 7.5.3 | 2.95 MB | 5.6 MB | | @datadog/wasm-js-rewriter | 4.0.1 | 2.85 MB | 3.58 MB | | @datadog/native-metrics | 3.1.1 | 1.02 MB | 1.43 MB | | @opentelemetry/api | 1.8.0 | 1.21 MB | 1.21 MB | | jsonpath-plus | 10.3.0 | 617.18 kB | 1.08 MB | | import-in-the-middle | 1.14.2 | 122.36 kB | 850.93 kB | | lru-cache | 10.4.3 | 804.3 kB | 804.3 kB | | source-map | 0.7.4 | 226 kB | 226 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | pprof-format | 2.1.0 | 111.69 kB | 111.69 kB | | @datadog/sketches-js | 2.1.1 | 109.9 kB | 109.9 kB | | lodash.sortby | 4.7.0 | 75.76 kB | 75.76 kB | | ignore | 7.0.5 | 63.38 kB | 63.38 kB | | istanbul-lib-coverage | 3.2.2 | 34.37 kB | 34.37 kB | | rfdc | 1.4.1 | 27.15 kB | 27.15 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB | | @isaacs/ttlcache | 1.4.1 | 25.2 kB | 25.2 kB | | tlhunter-sorted-set | 0.1.0 | 24.94 kB | 24.94 kB | | shell-quote | 1.8.3 | 23.74 kB | 23.74 kB | | limiter | 1.1.5 | 23.17 kB | 23.17 kB | | retry | 0.13.1 | 18.85 kB | 18.85 kB | | semifies | 1.0.0 | 15.84 kB | 15.84 kB | | jest-docblock | 29.7.0 | 8.99 kB | 12.76 kB | | crypto-randomuuid | 1.0.0 | 11.18 kB | 11.18 kB | | ttl-set | 1.0.0 | 4.61 kB | 9.69 kB | | mutexify | 1.4.0 | 5.71 kB | 8.74 kB | | path-to-regexp | 0.1.12 | 6.6 kB | 6.6 kB | | koalas | 1.0.2 | 6.47 kB | 6.47 kB | | module-details-from-path | 1.0.4 | 3.96 kB | 3.96 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

Copy link

codecov bot commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.23%. Comparing base (fa783b4) to head (01780e8).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6203      +/-   ##
==========================================
- Coverage   83.28%   83.23%   -0.06%     
==========================================
  Files         478      476       -2     
  Lines       19802    19802              
==========================================
- Hits        16493    16483      -10     
- Misses       3309     3319      +10     

☔ 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.

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Jul 30, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 01780e8 | Docs | Was this helpful? Give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Jul 30, 2025

Benchmarks

Benchmark execution time: 2025-08-07 19:38:48

Comparing candidate commit 01780e8 in PR branch sydney/feat with baseline commit fa783b4 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1270 metrics, 53 unstable metrics.

@sydney-tung sydney-tung marked this pull request as ready for review August 1, 2025 16:40
@sydney-tung sydney-tung requested a review from a team as a code owner August 1, 2025 16:40
@sydney-tung sydney-tung requested a review from tlhunter August 5, 2025 17:09
@@ -16,7 +18,7 @@ describe('sendTelemetry', () => {

beforeEach(() => {
cleanup = telemetryForwarder()
sendTelemetry = proxyquire('../src/guardrails/telemetry', {})
Copy link
Member

Choose a reason for hiding this comment

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

This is pretty weird. It looks like the old proxyquire call here was wrong as that file doesn't exist relative to this file, and that you fixed it. And it's not like the location of this test file moved.

Did you find that running this test file would throw errors and that when you fixed the path it started working? If so we might have a bug in our test suite where we're not properly executing this test file...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait yeah it only worked after I changed the path...

Copy link
Member

Choose a reason for hiding this comment

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

Alright I'm super confused then.

Here are the CI results for a random PR that I found that doesn't contain your changes and I can see that the guardrails tests are running:
https://github.com/DataDog/dd-trace-js/actions/runs/16787347785/job/47541117623?pr=6237

> dd-trace@6.0.0-pre test:trace:guardrails
> mocha -r "packages/dd-trace/test/setup/mocha.js" "packages/dd-trace/test/guardrails/**/*.spec.js"



  sendTelemetry
    ✔ should send telemetry (114ms)
    no duplicates
      ✔ should not send `abort` more than once in the same call (105ms)
      ✔ should not send `abort` more than once in a different call (105ms)
      ✔ should not send `abort.integration` more than once if tags are the same in the same call (104ms)
      ✔ should not send `abort.integration` more than once if tags are the same in a different call (105ms)


  5 passing (844ms)

--------------|---------|----------|---------|---------|-------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------|---------|----------|---------|---------|-------------------
All files     |   87.03 |       65 |   35.71 |   88.23 |                   
 log.js       |     100 |    35.71 |       0 |     100 | 20-29             
 telemetry.js |   84.09 |    79.16 |   44.44 |   85.36 | 11,16,53,66,70,74 
 util.js      |     100 |      100 |     100 |     100 |                   
--------------|---------|----------|---------|---------|-------------------
Done in 1.66s.

And here are is the test results for your PR:
https://github.com/DataDog/dd-trace-js/actions/runs/16756190382/job/47439327513?pr=6203

> dd-trace@6.0.0-pre test:trace:guardrails
> mocha -r "packages/dd-trace/test/setup/mocha.js" "packages/dd-trace/test/guardrails/**/*.spec.js"



  sendTelemetry
    ✔ should send telemetry (108ms)
    no duplicates
      ✔ should not send `abort` more than once in the same call (105ms)
      ✔ should not send `abort` more than once in a different call (105ms)
      ✔ should not send `abort.integration` more than once if tags are the same in the same call (104ms)
      ✔ should not send `abort.integration` more than once if tags are the same in a different call (104ms)
    Error scenarios and metadata
      ✔ should set error metadata when telemetry forwarder fails to spawn
      ✔ should set error metadata when telemetry forwarder exits with non-zero code
      ✔ should set error metadata when writing to telemetry forwarder fails
      ✔ should set success metadata when telemetry forwarder exits successfully


  9 passing (852ms)

--------------|---------|----------|---------|---------|-------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
--------------|---------|----------|---------|---------|-------------------
All files     |   93.93 |     67.5 |   57.14 |   95.23 |                   
 log.js       |     100 |    35.71 |      25 |     100 | 20-29             
 telemetry.js |   92.85 |    83.33 |   66.66 |   94.33 | 11,16,56          
 util.js      |     100 |      100 |     100 |     100 |                   
--------------|---------|----------|---------|---------|-------------------
Done in 1.64s.

Based on the location of the files I believe your change is correct:

dd-trace-js/packages/dd-trace/test/guardrails/ $ node
Welcome to Node.js v22.18.0.
Type ".help" for more information.
> let proxyquire = require('proxyquire')
undefined
> proxyquire('../src/guardrails/telemetry', {})
Uncaught Error: Cannot find module '../src/guardrails/telemetry'
Require stack:
- <repl>
    at Function._resolveFilename (node:internal/modules/cjs/loader:1365:15)
    at Proxyquire._disableModuleCache (/Users/thomas.hunter/Projects/dd-trace-js/node_modules/proxyquire/lib/proxyquire.js:248:19)
    at Proxyquire._disableCache (/Users/thomas.hunter/Projects/dd-trace-js/node_modules/proxyquire/lib/proxyquire.js:216:15)
    at Proxyquire._withoutCache (/Users/thomas.hunter/Projects/dd-trace-js/node_modules/proxyquire/lib/proxyquire.js:172:27)
    at Proxyquire.load (/Users/thomas.hunter/Projects/dd-trace-js/node_modules/proxyquire/lib/proxyquire.js:136:15) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '<repl>' ]
}
> proxyquire('../../src/guardrails/telemetry', {})
[Function: noop]

I see that @watson introduced this test file in commit f97d2cd so I'd like him to take a look. There might be some shenanigans in CI that allow the old code to work?

@tlhunter tlhunter dismissed their stale review August 6, 2025 21:14

Changes were made

@sydney-tung sydney-tung merged commit 5873c88 into master Aug 11, 2025
686 checks passed
@sydney-tung sydney-tung deleted the sydney/feat branch August 11, 2025 17:24
@dd-octo-sts dd-octo-sts bot mentioned this pull request Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants