Skip to content

Add RawSpan APIs to the ResponseSender - #124

Open
0xTim wants to merge 1 commit into
mainfrom
rawspan-write
Open

Add RawSpan APIs to the ResponseSender#124
0xTim wants to merge 1 commit into
mainfrom
rawspan-write

Conversation

@0xTim

@0xTim 0xTim commented Aug 27, 2026

Copy link
Copy Markdown
Member

Resolves #123

@0xTim 0xTim added the 🆕 semver/minor Adds new public API. label Aug 27, 2026
Comment on lines +144 to +146
var byteBuffer = ByteBuffer()
byteBuffer.reserveCapacity(bytes.byteCount)
byteBuffer.writeBytes(bytes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The byte buffer allocation here makes this path really sad.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It needs to be copied into a ByteBuffer at some point because that's what the channel handler takes. The HTTP server needs to own the data because of the difference of when NIO returns and when the data actually hits the socket (IIRC this is a documented part of the channel handler). This APIs here at least stops you going from Data/Array/ByteBuffer/whatever type you want, into a unique array back into ByteBuffer in the channel handler

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only reason we need this API is because ByteBuffer does not conform to RangeReplacableContainer nor do the span types.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We'd still have a copy somewhere, unless it was ByteBuffer through the whole stack right? (Assuming RangeReplaceableContainer). Because that's what NIO talks in the channel handler/socket so it needs a copy to convert it in. I don't think ByteBuffer has any mechanism to borrow yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offer ResponseSender.Writer RawSpan APIs

2 participants