-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Split zipkin span which contains server and client annotations #453
Split zipkin span which contains server and client annotations #453
Conversation
55beced
to
c247c50
Compare
@@ -309,7 +356,10 @@ func (td toDomain) getLogFields(annotation *zipkincore.Annotation) []model.KeyVa | |||
|
|||
func (td toDomain) getSpanKindTag(annotations []*zipkincore.Annotation) (model.KeyValue, bool) { | |||
for _, a := range annotations { | |||
if spanKind, ok := coreAnnotations[a.Value]; ok { | |||
if spanKind, ok := coreClientAnnotations[a.Value]; ok { |
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 have split core annotations to be sure that client kind is always created first. We could keep annotations in one map and then in transformSpan
check which one has been transformed and create missing one based on that
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.
to be sure that client kind is always created first
why does it matter?
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.
Then in transformSpan
I know that only server span kind has to be added.
b124050
to
c53f31b
Compare
Split zipkin span if it contains client and server annotations Signed-off-by: Pavol Loffay <[email protected]>
c53f31b
to
9da8b4b
Compare
Signed-off-by: Pavol Loffay <[email protected]>
@yurishkuro it should be ready for review |
cmd/collector/app/span_handler.go
Outdated
@@ -129,7 +129,7 @@ func (h *zipkinSpanHandler) SubmitZipkinBatch(ctx thrift.Context, spans []*zipki | |||
} | |||
|
|||
// ConvertZipkinToModel is a helper function that logs warnings during conversion | |||
func ConvertZipkinToModel(zSpan *zipkincore.Span, logger *zap.Logger) *model.Span { | |||
func convertZipkinToModel(zSpan *zipkincore.Span, logger *zap.Logger) []*model.Span { | |||
mSpan, err := zipkin.ToDomainSpan(zSpan) |
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.
s/mSpan/mSpans/
var csOk bool | ||
var srOk bool | ||
for _, ann := range zSpan.Annotations { | ||
if ann.Value == "cs" { |
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.
please use constants from zipkincore namespace instead of strings
} | ||
return trace, multierror.Wrap(errors) | ||
} | ||
|
||
func (td toDomain) ToDomainSpan(zSpan *zipkincore.Span) (*model.Span, error) { | ||
jSpan := td.transformSpan(zSpan) | ||
func (td toDomain) ToDomainSpan(zSpan *zipkincore.Span) ([]*model.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.
please make the naming consistent across the board: ToDomainSpans (plural)
TraceID: model.TraceID{High: uint64(traceIDHigh), Low: uint64(zSpan.TraceID)}, | ||
SpanID: model.SpanID(zSpan.ID), | ||
OperationName: zSpan.Name, | ||
ParentSpanID: model.SpanID(parentID), |
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.
missing Flags, StartTime, Duration?
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.
Added with similar impl to zipkin.
} | ||
// if the first span is a client span we create server span and vice-versa. | ||
if spanKindTag.VStr == string(ext.SpanKindRPCClient.Value.(ext.SpanKindEnum)) { | ||
s.Tags = []model.KeyValue{model.String(ext.SpanKindRPCServer.Key, string(ext.SpanKindRPCServer.Value.(ext.SpanKindEnum)))} |
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 cast the value ext.SpanKindRPCServer.Value.(ext.SpanKindEnum)
?
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.
also, why is the first argument SpanKindRPCServer
instead of just SpanKind
?
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 cast the value ext.SpanKindRPCServer.Value.(ext.SpanKindEnum)?
because it fails on cannot convert ext.SpanKindRPCClient.Value (type interface {}) to type string
tags := td.getTags(zSpan.BinaryAnnotations, td.isSpanTag) | ||
if spanKindTag, ok := td.getSpanKindTag(zSpan.Annotations); ok { | ||
var spanKindTag model.KeyValue |
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 don't think you need to capture this tag, the model span has helper methods like span.IsRPCClient()
Signed-off-by: Pavol Loffay <[email protected]>
} | ||
// if the first span is a client span we create server span and vice-versa. | ||
if result[0].IsRPCClient() { | ||
s.Tags = []model.KeyValue{model.String(ext.SpanKindRPCServer.Key, string(ext.SpanKindRPCServer.Value.(ext.SpanKindEnum)))} |
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 this is a lot simpler: model.String(string(ext.SpanKind), string(ext.SpanKindRPCServerEnum))
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.
+1 changed
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay [email protected]
Fixes #451
Zipkin logic is here:
Collector: https://github.com/openzipkin/zipkin/blob/5c8a17620674ada895acf05038bfdb209924a47d/zipkin/src/main/java/zipkin/collector/Collector.java#L143
v1 to v2 model: https://github.com/openzipkin/zipkin/blob/eeeeb3c02b0e0c578eb36c08d80cf2bf400067fc/zipkin/src/main/java/zipkin/internal/V2SpanConverter.java#L46