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 PartialEq for Value in opentelemetry-stdout #1955

Merged
merged 3 commits into from
Jul 24, 2024

Conversation

fiadliel
Copy link
Contributor

@fiadliel fiadliel commented Jul 23, 2024

Fixes #1952

Changes

PartialEq's previous implementation could call itself again with the same arguments. Here the underlying values are extracted and compared. If the enum types are different, false is returned.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

PartialEq's previous implementation called back to
itself with the same arguments. Here we extract the
underlying value and compare them.

If the enum types are different, it returns false.
@fiadliel fiadliel requested a review from a team July 23, 2024 06:57
Copy link

linux-foundation-easycla bot commented Jul 23, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: fiadliel / name: Gary Coady (6ff74ed)
  • ✅ login: lalitb / name: Lalit Kumar Bhasin (86a0c44, 97aa59b)

Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 74.9%. Comparing base (57bcd59) to head (86a0c44).

Files Patch % Lines
opentelemetry-stdout/src/common.rs 0.0% 14 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1955     +/-   ##
=======================================
- Coverage   74.9%   74.9%   -0.1%     
=======================================
  Files        122     122             
  Lines      20375   20387     +12     
=======================================
  Hits       15276   15276             
- Misses      5099    5111     +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

(Value::Array(a), Value::Array(oa)) => a.eq(oa),
(Value::KeyValues(kv), Value::KeyValues(okv)) => kv.eq(okv),
(Value::BytesValue(b), Value::BytesValue(ob)) => b.eq(ob),
(Value::Bool(_), _) => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a simpler wild card pattern instead?

_ => false,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My concern was that if a new variant were added to Value, PartialEq would compile but have an incorrect result. With this version, there would be a compile error. But if you favor conciseness, I can change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point!

@lalitb lalitb merged commit 2b026d9 into open-telemetry:main Jul 24, 2024
24 of 25 checks passed
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.

[Bug]: Stack overflow in opentelemetry-stdout
3 participants