Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Fix buffer size counting bug and add logging to UDP sender #151

Merged
merged 4 commits into from
Aug 28, 2017

Conversation

yurishkuro
Copy link
Member

Resolves #150

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 99.242% when pulling 0788eda on fix-packet-size into 5bd0763 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 99.242% when pulling 8ea74cc on fix-packet-size into 5bd0763 on master.

// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

declare class dgram$Socket {
Copy link
Contributor

Choose a reason for hiding this comment

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

I've never seen this naming convention. Is this part of ES6's style?

if (bufferResult.err) {
console.log('err', bufferResult.err);
if (writeResult.err) {
this._logger.error(`error writing Thrift object: ${writeResult.err}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to emit a metric here?

Copy link
Member Author

Choose a reason for hiding this comment

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

the sender is not integrated with metrics currently. Also the two new errors are a sign of misconfiguration, not something that can keep happening repeatedly, thus I think the logs are a lot more useful.

// that's why in the constructor we also add a general on('error') handler.
this._client.send(thriftBuffer, 0, thriftBuffer.length, this._port, this._host, (err, sent) => {
if (err) {
this._logger.error(`error sending spans over UDP: ${err}, packet size: ${writeResult.offset}, bytes sent: ${sent}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

Copy link
Contributor

@black-adder black-adder left a comment

Choose a reason for hiding this comment

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

Given our clients look exactly the same, I'll check if the other clients have this issue.

@@ -0,0 +1,33 @@
// @flow
// Copyright (c) 2016 Uber Technologies, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

we should update the license.sh to say 2017

this._batch.spans.push(span);
if (this._byteBufferSize < this._maxSpanBytes) {
this._totalSpanBytes += spanSize;
if (this._totalSpanBytes < this._maxSpanBytes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this extra logic is needed? ie if totalspanbytes == maxspanbytes, the next time round it will be flushed on L118. Do we really need this extra check that has only a 1 byte tolerance?

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 total + spanSize is less than max packet size, we don't flush (diff could be 1 byte or 50Kb, whichever)
  • if total + spanSize is exactly the max packet size, we can flush the buffer including the current span, rather than flushing a smaller buffer and keeping the current span for the next flush

minor optimization, but seems worth it given that it doesn't complicate the code that much.

@oibe
Copy link
Contributor

oibe commented Aug 28, 2017

For the most part looks good to me. The only real concern is whether or not we should emit a metric on error logs.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 99.242% when pulling 7ecb905 on fix-packet-size into 5bd0763 on master.

@yurishkuro yurishkuro merged commit 51e40ec into master Aug 28, 2017
@yurishkuro yurishkuro deleted the fix-packet-size branch February 26, 2018 20:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants