Skip to content

Commit

Permalink
add additional batch overhead in jaeger agent udp exporter (#2489)
Browse files Browse the repository at this point in the history
* add additional batch overhead in jaeger agent udp exporter

Signed-off-by: Ben Ye <ben.ye@bytedance.com>

* update changelog

Signed-off-by: Ben Ye <ben.ye@bytedance.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
  • Loading branch information
yeya24 and MrAlias committed Jan 4, 2022
1 parent c772d57 commit 776bfdc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Changed

- Jaeger exporter takes into additional 70 bytes overhead into consideration when sending UDP packets (#2489)

### Deprecated

- Deprecate module `"go.opentelemetry.io/otel/sdk/export/metric"`, new functionality available in "go.opentelemetry.io/otel/sdk/metric" module:
Expand Down
11 changes: 8 additions & 3 deletions exporters/jaeger/agent.go
Expand Up @@ -28,8 +28,13 @@ import (
"go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift"
)

// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent
const udpPacketMaxLength = 65000
const (
// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent
udpPacketMaxLength = 65000
// emitBatchOverhead is the additional overhead bytes used for enveloping the datagram,
// synced with jaeger-agent https://github.com/jaegertracing/jaeger-client-go/blob/master/transport_udp.go#L37
emitBatchOverhead = 70
)

// agentClientUDP is a UDP client to Jaeger agent that implements gen.Agent interface.
type agentClientUDP struct {
Expand Down Expand Up @@ -67,7 +72,7 @@ func newAgentClientUDP(params agentClientUDPParams) (*agentClientUDP, error) {
}

if params.MaxPacketSize <= 0 {
params.MaxPacketSize = udpPacketMaxLength
params.MaxPacketSize = udpPacketMaxLength - emitBatchOverhead
}

if params.AttemptReconnecting && params.AttemptReconnectInterval <= 0 {
Expand Down
4 changes: 2 additions & 2 deletions exporters/jaeger/agent_test.go
Expand Up @@ -73,7 +73,7 @@ func TestNewAgentClientUDPWithParamsDefaults(t *testing.T) {
})
assert.NoError(t, err)
assert.NotNil(t, agentClient)
assert.Equal(t, udpPacketMaxLength, agentClient.maxPacketSize)
assert.Equal(t, udpPacketMaxLength-emitBatchOverhead, agentClient.maxPacketSize)

if assert.IsType(t, &reconnectingUDPConn{}, agentClient.connUDP) {
assert.Equal(t, (*log.Logger)(nil), agentClient.connUDP.(*reconnectingUDPConn).logger)
Expand All @@ -97,7 +97,7 @@ func TestNewAgentClientUDPWithParamsReconnectingDisabled(t *testing.T) {
})
assert.NoError(t, err)
assert.NotNil(t, agentClient)
assert.Equal(t, udpPacketMaxLength, agentClient.maxPacketSize)
assert.Equal(t, udpPacketMaxLength-emitBatchOverhead, agentClient.maxPacketSize)

assert.IsType(t, &net.UDPConn{}, agentClient.connUDP)

Expand Down

0 comments on commit 776bfdc

Please sign in to comment.