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 NaN and Infinity values in logs being coerced into null and causing exception in OTEL collector #4435

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

witoszekdev
Copy link

Which problem is this PR solving?

OpenTelemetry JS logging SDK had a bug where if the log had a NaN, Infinity or -Infinity value, it was treated as a number and returned

{
  doubleValue: null;
}

to Collector, which caused an exception.

Short description of the changes

This PR uses Number.isFinite method to check if the value is in fact a number, and won't be coerced into null by JSON.stringify.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Checklist:

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

@witoszekdev witoszekdev requested a review from a team January 23, 2024 13:03
Copy link

linux-foundation-easycla bot commented Jan 23, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@witoszekdev witoszekdev changed the title Fix NaN and Infinity values being coerced into null Fix NaN and Infinity values in logs being coerced into null and causing exception in OTEL collector Jan 23, 2024
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.23%. Comparing base (4655895) to head (f17141b).
Report is 146 commits behind head on main.

Current head f17141b differs from pull request most recent head 29bc0bf

Please upload reports for the commit 29bc0bf to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4435      +/-   ##
==========================================
- Coverage   92.23%   92.23%   -0.01%     
==========================================
  Files         336      336              
  Lines        9533     9525       -8     
  Branches     2022     2020       -2     
==========================================
- Hits         8793     8785       -8     
  Misses        740      740              
Files Coverage Δ
...l/packages/otlp-transformer/src/common/internal.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

@dyladan
Copy link
Member

dyladan commented Jan 31, 2024

Fix seems straightforward enough, but it seems to me that we are dropping important information here. Is NaN and Infinity really not representable? Is this only affecting JSON or does it also affect protobuf? If it is JSON only, it should be handled somewhere that it doesn't affect the protobuf version, similar to how trace and span ids are handled.

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.

This code is also used for protobuf where it's possible to represent both NaN and +/-Infinity.
As @dyladan said, we're likely loosing some data here and we need to ensure we don't affect the protobuf exporters with this change.

Copy link

github-actions bot commented Apr 1, 2024

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Apr 1, 2024
@trentm trentm removed the stale label Apr 3, 2024
Copy link

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Jun 10, 2024
@github-actions github-actions bot removed the stale label Jun 17, 2024
Copy link

github-actions bot commented Dec 9, 2024

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants