Skip to content

Conversation

@cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Oct 27, 2025

Which problem is this PR solving?

sdk.test.ts in sdk-node appears to be the only place in the codebase that uses a destructured process.env. It even does so inconsistently within the file.

Fixes # N/A

Short description of the changes

This commit updates the test file to use process.env consistently.

Type of change

None of the items in this list really apply.

How Has This Been Tested?

  • Existing test suite.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@cjihrig cjihrig requested a review from a team as a code owner October 27, 2025 18:48
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.16%. Comparing base (74f470e) to head (e231a7d).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6052   +/-   ##
=======================================
  Coverage   95.16%   95.16%           
=======================================
  Files         316      316           
  Lines        9198     9207    +9     
  Branches     2057     2075   +18     
=======================================
+ Hits         8753     8762    +9     
  Misses        445      445           

see 1 file with indirect coverage changes

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

import * as Sinon from 'sinon';
import { NodeSDK } from '../src';
import { env } from 'process';
import * as process from 'process';
Copy link
Contributor

Choose a reason for hiding this comment

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

Process is already in the global scope https://nodejs.org/api/globals.html#process so I think it is safe to remove this line. Also I think this import opens a door to load a package if installed (https://www.npmjs.com/package/process)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I wasn't sure why it was explicitly imported, so I left it there. I have removed it now. FWIW, process is imported in other places in the codebase.

Also I think this import opens a door to load a package if installed

The preferred way to guard against this is to import Node core modules with the node: prefix (for example, node:fs instead of fs). Newer core modules actually requires the prefix (for example, node:sqlite would work, but sqlite would not).

@david-luna david-luna added this pull request to the merge queue Oct 29, 2025
Merged via the queue into open-telemetry:main with commit 4dc99dc Oct 29, 2025
27 checks passed
@otelbot
Copy link
Contributor

otelbot bot commented Oct 29, 2025

Thank you for your contribution @cjihrig! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

@cjihrig cjihrig deleted the sdk-node branch October 29, 2025 14:23
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.

2 participants