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

Flatten field + fix u64 to string serde #1911

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

Conversation

hwrdtm
Copy link

@hwrdtm hwrdtm commented Jul 4, 2024

Changes

This PR:

  • Is a continuation of what was originally surfaced Fix serde #1856.
  • Flattens some data and value fields in order to be consistent with the JSON schema implemented on the OTEL Collector
    • See here for the struct defs and JSON tags
    • Also see here for an example resource metric in JSON
  • Adds more fields to be correctly doing serde between u64 and String
  • Without both of these changes the ./expected/metrics.json file wouldn't even deserialize correctly.

Testing

  • Run cargo test --workspace --all-features --test grpc_build -- --nocapture to generate grpc files. Running the first time is expected to fail, as it will create the files.
  • Run cargo test --workspace --all-features --test metrics 'test_serde' -- --nocapture to run the new test case introduced in this PR.

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)

cc @lalitb

@hwrdtm hwrdtm requested a review from a team as a code owner July 4, 2024 18:38
Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.9%. Comparing base (cdf5f03) to head (4a92519).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1911   +/-   ##
=====================================
  Coverage   74.9%   74.9%           
=====================================
  Files        122     122           
  Lines      20308   20308           
=====================================
  Hits       15217   15217           
  Misses      5091    5091           

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

@lalitb lalitb self-assigned this Jul 8, 2024
@hwrdtm
Copy link
Author

hwrdtm commented Jul 12, 2024

Any thoughts here?

@lalitb
Copy link
Member

lalitb commented Jul 12, 2024

Thanks for the PR @hwrdtm . Will review it tomorrow.

.expect("Failed to serialize metrics");

// Write to file.
let mut file = File::create("./expected/serialized_metrics.json").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use tempfile here

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.

None yet

3 participants