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 http json example #1835

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

Conversation

ramgdev
Copy link
Contributor

@ramgdev ramgdev commented May 27, 2024

Fixes #1763
Design discussion issue (if applicable) #

Changes

Use string value for event attribute

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)

@ramgdev ramgdev requested a review from a team as a code owner May 27, 2024 04:05
Copy link

codecov bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.0%. Comparing base (4df74e8) to head (1c01581).

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1835     +/-   ##
=======================================
- Coverage   75.0%   75.0%   -0.1%     
=======================================
  Files        122     122             
  Lines      20279   20279             
=======================================
- Hits       15212   15211      -1     
- Misses      5067    5068      +1     

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

@ramgdev
Copy link
Contributor Author

ramgdev commented May 27, 2024

@lalitb @TommyCpp please take a look at the changes when you get a chance. I had to disable the call to serialize int values to string so it works correctly when deserializing from JSON. I think JSON deserializer expects StringValue for all string attribute values.

My editor picked up some formatting changes in addition.

{
// Serialize any_value::Value using its own implementation
// If value is None, it will be serialized as such
match value {
Some(any_value) => match &any_value.value {
Some(Value::IntValue(i)) => serialize_i64_to_string(i, serializer),
//Some(Value::IntValue(i)) => serialize_i64_to_string(i, serializer),
Copy link
Member

Choose a reason for hiding this comment

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

@ramgdev does commenting it out resolve the export issue? From my understanding, proto i64/u64 should be converted to JSON strings."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lalitb yes, this change fixes the exporter issue in the example. I see this in the JSON mapping doc JSON value will be a decimal string. Either numbers or strings are accepted. Since using numbers in serialization help with deserializing back into either standalone value or value wrapped in opentelemetry::Value enum, this should work imho.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if I am looking at the wrong place. Looks like the attribute spec is asking int64 to be encoded as number, not string. https://opentelemetry.io/docs/specs/otel/common/#attribute

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the int64 type is supported as number for attributes, however when it is converted to JSON, it should string as per the proto-JSON mapping doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't that introduce ambiguity for deserializer without the explicit use of Value::String during serialization?

@lalitb
Copy link
Member

lalitb commented Jun 5, 2024

@ramgdev Please go through the fix mentioned in the comment here. Do you think it resolves this issue also ?

@ramgdev
Copy link
Contributor Author

ramgdev commented Jun 5, 2024

@ramgdev Please go through the fix mentioned in the comment here. Do you think it resolves this issue also ?

@lalitb thanks. It looks like it will take care of this issue as well. I will wait to test it after that PR merges and remove the edits from proto.rs in this PR.

@lalitb lalitb mentioned this pull request Jun 7, 2024
4 tasks
@lalitb
Copy link
Member

lalitb commented Jun 18, 2024

@ramgdev Please go through the fix mentioned in the comment here. Do you think it resolves this issue also ?

@lalitb thanks. It looks like it will take care of this issue as well. I will wait to test it after that PR merges and remove the edits from proto.rs in this PR.

@ramgdev fyi - #1882 is merged.

@ramgdev ramgdev requested a review from lalitb June 19, 2024 03:31
@ramgdev ramgdev requested a review from lalitb June 21, 2024 02:10
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM with nit change. Thanks for the PR.

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.

OTLP Exporter with http/json is not working
4 participants