-
Notifications
You must be signed in to change notification settings - Fork 288
Update udpTransport to only send Jaeger.thrift #147
Conversation
black-adder
commented
May 2, 2017
•
edited
Loading
edited
- Need to remove the notion of peer in span.go and use the tags instead
- Update thrift_span.go to accommodate the above change
- Pass in logger to transport layer so that it can log errors if the batch is too big and our checks didn't suffice
"github.com/uber/jaeger-client-go/thrift-gen/agent" | ||
"github.com/uber/jaeger-client-go/thrift-gen/jaeger" | ||
"github.com/uber/jaeger-client-go/thrift-gen/sampling" | ||
"github.com/uber/jaeger-client-go/thrift-gen/zipkincore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aye since MockAgent has to implement EmitZipkinBatch until it can be removed from thrift.idl
|
||
const defaultUDPSpanServerHostPort = "localhost:5775" | ||
const defaultUDPSpanServerHostPort = "localhost:6831" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
port 5775 on the agent is for zipkin-compact, 6831 is for jaeger-compact
if s.process == nil { | ||
s.process = &j.Process{ | ||
ServiceName: span.tracer.serviceName, | ||
Tags: buildTags(span.tracer.tags), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this ever change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, tracer level tags are set once in the constructor and that's it.
@@ -78,14 +79,19 @@ func NewAgentClientUDP(hostPort string, maxPacketSize int) (*AgentClientUDP, err | |||
|
|||
// EmitZipkinBatch implements EmitZipkinBatch() of Agent interface | |||
func (a *AgentClientUDP) EmitZipkinBatch(spans []*zipkincore.Span) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is gonna go away right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but to remove it here I need to remove it from the thrift.idl and to do that I need to remove this from all the clients first. So just stubbing out for now.
span.go
Outdated
} | ||
if !handled { | ||
s.tags = append(s.tags, Tag{key: key, value: value}) | ||
if !handler(s, key, value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think once we switch to jaeger.thrift, the only special handler we need is for sampling.priority
jaeger_span.go
Outdated
// buildJaegerSpan builds jaeger span based on internal span. | ||
func buildJaegerSpan(span *Span) *j.Span { | ||
// BuildJaegerSpan builds jaeger span based on internal span. | ||
func BuildJaegerSpan(span *Span) *j.Span { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BuildJaegerThrift(Span) would be better name. And the file name jaeger_thrift_span.go
.
propagation_test.go
Outdated
@@ -102,7 +102,7 @@ func TestSpanPropagator(t *testing.T) { | |||
sp.duration, sp.startTime = exp.duration, exp.startTime | |||
} | |||
assert.Equal(t, exp.context, sp.context, formatName) | |||
assert.Equal(t, expTags, sp.tags, formatName) | |||
assert.Equal(t, expTags, sp.tags[1:] /*skip span.kind tag*/, formatName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if no code in the test has changed, why does the outcome change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ext.RPCServerOption(childCtx) adds the span.kind=server tag which was previously handled 'specially'
reporter_test.go
Outdated
s.Equal(2, len(zSpan.Annotations), "expecting two annotations for events") | ||
s.Equal(len(expected), len(zSpan.BinaryAnnotations), | ||
span := s.collector.Spans()[0] | ||
s.Equal(2, len(span.logs), "expecting two annotations for events") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fix message. "expecting two logs" ?
reporter_test.go
Outdated
s.Equal(len(expected), len(zSpan.BinaryAnnotations), | ||
span := s.collector.Spans()[0] | ||
s.Equal(2, len(span.logs), "expecting two annotations for events") | ||
s.Equal(len(expected), len(span.tags), | ||
"expecting %d binary annotations", len(expected)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fix message - shouldn't be mentioning annotations anywhere
@@ -127,13 +122,9 @@ func (s *reporterSuite) TestClientSpanAnnotations() { | |||
sp.Finish() | |||
s.flushReporter() | |||
s.Equal(2, len(s.collector.Spans())) | |||
zSpan := s.collector.Spans()[0] // child span is reported first | |||
s.EqualValues(zSpan.ID, sp2.(*Span).context.spanID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a flag to use / not-use zipkin's one-span-per-rpc model? I'd expect the span ID check to be there.
assert.True(t, overhead <= emitSpanBatchOverhead, | ||
"test %d, n=%d, expected overhead %d <= %d", i, n, overhead, emitSpanBatchOverhead) | ||
overhead := transport.Len() - n*spanSize - processSize | ||
assert.True(t, overhead <= emitBatchOverhead, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add t.Logf("span count: %d, overhead: %d", n, overhead)
? I am curious if it's less than 30 bytes now - I don't like leaving unexplained magic numbers in the code.
require.Equal(t, 1, len(spans), "agent should have received the span") | ||
assert.Equal(t, span.Name, spans[0].Name) | ||
batches := agent.GetJaegerBatches() | ||
require.Equal(t, 1, len(batches), "agent should have received the batch") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require 1 span
transport_udp_test.go
Outdated
spans := agent.GetZipkinSpans() | ||
require.Equal(t, test.expectSpansFlushed, len(spans), test.description) | ||
batches := agent.GetJaegerBatches() | ||
if test.expectSpansFlushed > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not an equivalent test - what if this condition is false?
@@ -149,23 +176,29 @@ func TestUDPSenderAppend(t *testing.T) { | |||
if test.expectFlush { | |||
time.Sleep(5 * time.Millisecond) | |||
} | |||
spans := agent.GetZipkinSpans() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could minimize the changes to the tests if you extract spans
var from batch[0]
.
@@ -132,11 +159,11 @@ func TestUDPSenderAppend(t *testing.T) { | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may want to add another control variable expectBatchesFlushed
to avoid doing if
statements in the test
54fc44f
to
4666122
Compare
cea1de5
to
8ad14a5
Compare