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

fix(sdk-node): use warn instead of error on unknown OTEL_NODE_RESOURCE_DETECTORS values #5034

Conversation

RichardChukwu
Copy link
Contributor

Which problem is this PR solving?

This PR addresses the issue #4882, which involves logging an unrecognized OTEL_NODE_RESOURCE_DETECTORS value. According to the OpenTelemetry specification, unrecognized enum values should generate a warning rather than an error. The current implementation uses diag.error to log this issue, but it should use diag.warn instead to align with the specification and avoid unnecessary error-level logging.

Fixes: #4882

Short description of the changes

Updated opentelemetry-sdk-node/src/utils.ts and auto-instrumentations-node/src/utils.ts to replace diag.error with diag.warn for handling unrecognized OTEL_NODE_RESOURCE_DETECTORS values.
This change ensures that unrecognized values generate a warning, as specified in the OpenTelemetry SDK environment variable guidelines.

Type of change

Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Ran the existing test suite using npm test to confirm that all tests pass successfully.

  • Manually verified that unrecognized OTEL_NODE_RESOURCE_DETECTORS values log a warning instead of an error.

Checklist:

  • Followed the style guidelines of this project

  • Unit tests have been added (if applicable)

  • Documentation has been updated where necessary

…CTORS values as per issue open-telemetry#4882.

I referenced the OpenTelemetry specification document, which clarified that diag.warn should be used for unrecognized values that don't critically break the system.
@RichardChukwu RichardChukwu requested a review from a team as a code owner October 2, 2024 20:02
Copy link

linux-foundation-easycla bot commented Oct 2, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@RichardChukwu
Copy link
Contributor Author

Hi @matschaffer @weyert this PR is ready for review

@pichlermarc pichlermarc changed the title Changed error logging to warnings for unknown OTEL_NODE_RESOURCE_DETECTORS values as per issue #4882 fix(sdk-node): use warn instead of error on unknown OTEL_NODE_RESOURCE_DETECTORS values Oct 3, 2024
@pichlermarc pichlermarc added bug Something isn't working priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization pkg:sdk-node labels Oct 3, 2024
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.27%. Comparing base (f8ab559) to head (d51bda9).
Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
...ental/packages/opentelemetry-sdk-node/src/utils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5034      +/-   ##
==========================================
- Coverage   93.39%   93.27%   -0.13%     
==========================================
  Files          46      317     +271     
  Lines         712     8194    +7482     
  Branches      120     1640    +1520     
==========================================
+ Hits          665     7643    +6978     
- Misses         47      551     +504     
Files with missing lines Coverage Δ
...ental/packages/opentelemetry-sdk-node/src/utils.ts 85.71% <0.00%> (ø)

... and 265 files with indirect coverage changes

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

@RichardChukwu thanks for fixing this 🙂

I took the liberty to change the PR title. Please also add a changelog entry in ./experimental/CHANGELOG.md (can be categorized as a bugfix) then we can merge this 🙂

bugfix changelog entry
@RichardChukwu RichardChukwu deleted the Changed-error-logging-to-warnings branch October 3, 2024 09:45
@RichardChukwu RichardChukwu restored the Changed-error-logging-to-warnings branch October 3, 2024 09:46
@RichardChukwu
Copy link
Contributor Author

@pichlermarc "I've added the changelog entry as requested. Let me know if anything else is needed. Thanks!"

@RichardChukwu RichardChukwu reopened this Oct 3, 2024
experimental/CHANGELOG.md Outdated Show resolved Hide resolved
@RichardChukwu
Copy link
Contributor Author

Thanks for the approval @maryliag
@pichlermarc please this is good for merge now I guess?

@pichlermarc pichlermarc added this pull request to the merge queue Oct 3, 2024
Merged via the queue into open-telemetry:main with commit e0e2b4a Oct 3, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:sdk-node priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

diag.error about unknown OTEL_NODE_RESOURCE_DETECTORS entry should be diag.warn
3 participants