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

Add ByteBuffer field type marshaling support to exporter. #6686

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

Conversation

jhalliday
Copy link
Contributor

The marshaling utility code has not previously needed to support encoding of ByteBuffer type fields, as they are not used by any existing protocol. With the creation of the new experimental profiling signal type, that changes.

#6680 adds support for marshaling the new signal, but converts the ByteBuffer field into byte[] first, which is not ideal. To allow the ByteBuffer to be passed directly to the serialization code, we add support through Serializer and MarshalerUtil. The bulk of the change is in CodedOutputStream, the upstream protobuf version of which has ByteBuffer support already, so this is really just reinstating it in the fork.

In so doing, I've opted to keep the data handling behaviour based on 'buffer capacity, not position/limit' semantics of the protobuf lib for consistency, though that may be seen as running contrary to the intended API usage semantics of ByteBuffer. What we expose at the user API level may or may not be the same - ProfileContainerMarshaler currently uses position/limit instead.

@jhalliday jhalliday requested a review from a team September 5, 2024 10:39
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

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

Project coverage is 89.91%. Comparing base (b927d9d) to head (38dcbbf).

Files with missing lines Patch % Lines
...y/exporter/internal/marshal/CodedOutputStream.java 0.00% 26 Missing ⚠️
...etry/exporter/internal/marshal/JsonSerializer.java 0.00% 4 Missing ⚠️
...elemetry/exporter/internal/marshal/Serializer.java 0.00% 4 Missing ⚠️
...metry/exporter/internal/marshal/MarshalerUtil.java 0.00% 3 Missing ⚠️
...try/exporter/internal/marshal/ProtoSerializer.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6686      +/-   ##
============================================
- Coverage     90.10%   89.91%   -0.19%     
  Complexity     6541     6541              
============================================
  Files           728      728              
  Lines         19695    19735      +40     
  Branches       1935     1938       +3     
============================================
- Hits          17746    17745       -1     
- Misses         1349     1389      +40     
- Partials        600      601       +1     

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

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Let's wait to merge until we can incorporate into #6680 to ensure this works with testing.

@jhalliday
Copy link
Contributor Author

This is currently deliberately decoupled from the profiling exporter work, though that's clearly its intended use case in the short term. Are you saying you'd like me to bundle in here the code change to profiling that uses this, rather than doing the linkup as a separate change later?
I tested this locally with a simple class that assumes the existing byte[] handling is right and checks that using ByteBuffer instead gives the same results, but felt that was a bit of a hack, so it's not included.

@jack-berg
Copy link
Member

Are you saying you'd like me to bundle in here the code change to profiling that uses this, rather than doing the linkup as a separate change later?

Yes, let's wire this into the profile marshaler where we see it being used, since that allows us to get some test coverage.

(Sorry for the delay. I missed your reply.)

Use new code in profiling marshaling.
@jhalliday
Copy link
Contributor Author

Not a problem. Done.

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.

2 participants