Skip to content

Conversation

@cijothomas
Copy link
Member

Though this works, I am wondering if AnyValue should contain variants to store u64 too?

@cijothomas cijothomas requested a review from a team as a code owner March 12, 2025 16:57
@cijothomas
Copy link
Member Author

Though this works, I am wondering if AnyValue should contain variants to store u64 too?

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#type-any
Only signed is required as per spec, so if we get a u64, a reasonable option is to do what this PR is doing...

@codecov
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.6%. Comparing base (66579ac) to head (5f4b837).
Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2795   +/-   ##
=====================================
  Coverage   79.6%   79.6%           
=====================================
  Files        124     124           
  Lines      23179   23219   +40     
=====================================
+ Hits       18461   18501   +40     
  Misses      4718    4718           

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

- `u64` and `usize` values are stored as `opentelemetry::logs::AnyValue::Int`
when conversion is feasible. Otherwise stored as
`opentelemetry::logs::AnyValue::String`. This avoids unnecessary string
allocation when values can be represented in their original types.
Copy link
Member

Choose a reason for hiding this comment

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

nit - indicate it as breaking change, for customers who were expecting u64 to be serialized as string in backends?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am unsure about that. I think it is a bug to convert a u64 to string by default, so this is more like a bug fix. And naturally, every bug fix can be thought of as breaking change to those whole relied on buggy behavior 🤣

We may still do more tweaks here..Do you think it should NOT be done post 1.0?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious. It looks like you have only added record_u64 method implementation. How does it help usize values?

Copy link
Member Author

Choose a reason for hiding this comment

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

tracing fired the u64 callbacks for usize. (they don't have a usize callback)

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we treat this as bug fix. - converting u64 to string, or u64 to i64 both are type conversion.

Copy link
Member Author

Choose a reason for hiding this comment

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

if we get an int, and instead of storing it as int and converting to string - this is what I treat as bug.

Copy link
Member

Choose a reason for hiding this comment

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

I believe as long as end-user is losing its type - it's still a bug. It's a breaking change for me :)

@cijothomas cijothomas merged commit 6b221e4 into open-telemetry:main Mar 13, 2025
23 checks passed
@cijothomas cijothomas deleted the cijothomas/appender-avoid-str branch March 13, 2025 17:31
bantonsson pushed a commit to bantonsson/opentelemetry-rust that referenced this pull request Oct 9, 2025
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.

3 participants